caelestis2
October 13th, 2009, 04:50 AM
The following code works fine with VC express, but not in GCC. Does anyone know why it won't compile? It gives this error:
conversion from ‘main()::functor’ to non-scalar type ‘std::tr1::function<void()>’ requested
Same thing happens if I use boost::function instead of std::tr1::function.
#include <iostream>
#include <tr1/functional>
#include <tr1/functional_hash.h>
void callfunc(std::tr1::function<void()> func) {func();}
int main() {
struct functor {
void operator()(void) {std::cout << "lol" << std::endl;}
};
functor f;
callfunc(f);
}
conversion from ‘main()::functor’ to non-scalar type ‘std::tr1::function<void()>’ requested
Same thing happens if I use boost::function instead of std::tr1::function.
#include <iostream>
#include <tr1/functional>
#include <tr1/functional_hash.h>
void callfunc(std::tr1::function<void()> func) {func();}
int main() {
struct functor {
void operator()(void) {std::cout << "lol" << std::endl;}
};
functor f;
callfunc(f);
}