Jump to content
  • Advertisement
Sign in to follow this  
sb01234

[C++] General container of "callable entities"?

This topic is 3614 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

boost::bind, std::mem_fn etc generalize applying function pointers/functors/member function pointers to STL algorithms. Is something similar available (in STL or boost for example) for storing polymorphic mixes of function pointers, functors and member functions? The idea is to do things such as storing polymorphic collections of different "callable entities" in the same STL container, like an std::map mapping from a string to a "callable entity". A possible implementation might be to create an abstract base class defining a function call operator with a signature S and provide subclasses implementing the operator using either of a function pointer, by value-held functor, a member function+an object to invoke it with, etc. Is anything like this available?

Share this post


Link to post
Share on other sites
Advertisement
boost::bind with boost::function. You mentioned it, but apparently you aren't fully aware of its capabilities. If you store std::vector of boost::function, you can use boost::bind to bind any free or member function, and store it in the vector.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!