Jump to content
  • Advertisement
Sign in to follow this  
littlekid

C++0x std::function and typedef function pointer

This topic is 2580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hihi,

I was wondering how do I use decltype to get the signature to pass in std::function?

suppose I have


typedef void (*MyFuncCallback)();

std::function<MyFuncCallback> callback_object; //doesn't work --- error: variable 'std::function<void (*)()> callback_object' has initializer but incomplete type

std::function<decltype(MyFuncCallback)> callback_object; //doesn't work either



How should I pass the callback signature to std::function??

I am compiling on gcc 4.6

Share this post


Link to post
Share on other sites
Advertisement
std::function expects a function type, not a function pointer type. boost::remove_pointer will work if MyFuncCallback isn't a member function pointer type, or if you have access to the original function type then that would obviously work, too.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!