How does the template parameter of std::function work? (implementation)

后端 未结 5 1229
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 08:45

In Bjarne Stroustrup\'s home page (C++11 FAQ):

struct X { int foo(int); };

std::function f;
f = &X::foo; //pointer to membe         


        
5条回答
  •  星月不相逢
    2020-12-07 09:37

    g++ seems to have an union which may keep either function pointer, member pointer or void pointer which probably points to a functor. Add overloads which appropriately flag which union member is valid and heavy casting to a soup and then it works...

提交回复
热议问题