I wrote some code using boost.function.  Compiling it both in g++4.13 and vc8, I find that I can not declare a struct in function with operator()  and use  boost.function to call it when I use g++. Just like this:

int main() {
    struct int_div {
          float operator()(int x, int y) const { return ((float)x)/y; };
        };
    boost::function<float (int x, int y)> f = int_div();
    std::cout << f(5, 3) << std::endl;
    return 0;
}
When I compile the code above in g++, it give me the error :  请求从 'main()::int_div' 转换到非标量类型 'boost::function<float ()(int, int), std::allocator<void> >'(I use ubuntu chinese.)
but when I move the int_div definition outside of main(), It is ok!
And the code above VC8 can compile it!
why?