Reputation: 13257
I want to store function pointers with different signature in a std::map
as a value
. Is this possible in C++
Upvotes: 1
Views: 198
Reputation: 126
You do not even need to use boost. You can simply use a functor( overload () operator) as a base class and inherit from it for every different function you need.
Upvotes: 0
Reputation: 31567
It is possible by using something like Boost.Any or Boost.Variant. Keep in mind, however, that you will have to remember somehow what the signature of the function stored (hidden) inside the boost::any
object is, so you can retrieve it.
Upvotes: 3