
On Wed, Feb 9, 2011 at 9:44 PM, Dave Abrahams
Just to be a little less opaque about this, everyone is asking because what you did is very similar to what's done in boost::variant, which led to some very interesting problems described in http://www.boost.org/doc/libs/1_45_0/doc/html/variant/design.html#variant.de... with very non-obvious solutions.
So you might also consider what happens under assignment when the constructor of the new object throws.
Thank you. I realize now that the code I posted will have to become comparatively a lot more complicated to replace boost::any in all situations. I will clean this up when time permits. I was curious if others have solved similar performance problems. I couldn't use boost::variant because I needed it for a message passing library where library user can pass in any message type. boost::variant would have been restrictive if the user wanted to use too many top level types of messages. - Adarsh Soodan