Hi,
I have the following code:
#include <iostream>
int foo() {
std::cout << __func__ << std::endl;
}
struct func {
void operator()() {
std::cout << __func__ << std::endl;
}
};
class run {
private:
public:
run() {
std::cout << "THIS SHOULD NOT HAVE BEEN CALLED 1" << std::endl;
}
run(const run&) {
std::cout << "THIS SHOULD NOT HAVE BEEN CALLED 2" << std::endl;
}
template<typename Functor>
run(Functor f) {
std::cout << "CALLED" << std::endl;
f();
}
};
int main() {
run(foo);
run(func());
return 0;
}
My output is:
THIS SHOULD NOT HAVE BEEN CALLED 1
and clearly not what I expected. Any hints?
Thanks