boostorg / boostorg/signals2

VS2019 / C++ 17, signal::disconnect compile error: syntax error: 'template'

Open
#72 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
89
Forks
61
PR merge metrics
No merged PRs in 30d

Description

Using custom functor, Signals fail to compile with:
signal_template.hpp(537,50): error C2059: syntax error: 'template'

Here:
```
// check for wrapped extended slot
bound_extended_slot_function_type *fp;
fp = (*it)->slot().slot_function().template target();
```

The reason behind is that the signal expects the functor to be the boost::function / std::function, that would contain the target() method.

Minimal example:
```
struct MyFunctorThisComparer
{
MyFunctorThisComparer(const void* this_) {}
bool operator==(const MyFunctorThisComparer& other) const { return true; }
};

struct MyFunctor
{
typedef void result_type;

template
void operator=(F) {}
void operator()() {}

// disconnect by comparison with custom predicate
bool operator==(const MyFunctorThisComparer& other) const { return true; }
operator MyFunctorThisComparer() const { return MyFunctorThisComparer { nullptr }; }
};

void signals_disconnect()
{
boost::signals2::signal<
void(),
//SignalSupport_::AllCall::result_type>,
boost::signals2::optional_last_value::result_type>,
int,
std::less,
MyFunctor > s;

s.connect( &signals_disconnect );
s.disconnect( MyFunctorThisComparer(nullptr) );
}
```

I attempted here to provide the equivalence MyFunctorThisComparer predicate, that would filter out functors. In particular, it would know how to extract 'this' pointer from MyFunctor. However, it could be a more generic predicate.

Boost 1.72.0. However, I have checked the development version - it has the same lines there, so the issue is still present.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.