Here is a simplified class I have:
class Event {
private:
std::function<void()> m_func;
public:
Event(std::function<void()> func)
: m_func(func)
{}
};
I cannot do implicit conversions on it:
void foo() {}
int main() {
Event evt = foo; //error
evt = []() {}; //error
}
Why is this? std::function
by itself is implicitly convertible to a callable object: std::function<void()> func = []() {}
.