struct myclass
{
myclass(void(*)()) {}
};
void test1(void(*)()) {}
void test2(myclass) { }
void cb() {}
int main()
{
test1(cb); // works
test2(cb); // works
test1([](){}); // works
test2([](){}); // does not work, why? there's no "explicit" keyword next to myclass.
}
Why this doesn't work?
The following obviously works but I don't want to use it.
test2(myclass([]{}));
Notes: I do not want to accept a std::function<void()>>
and I don't want to create a template<T> myclass(T f) {}
either.