If you want to store one of a limited set of built-in types, consider using boost::variant.
Thanks for the advice. I've looked at this solution (few months ago and for another project).
In my case, there were some reasons no to use it :
- of course it is required to link with boost and it seems to me (personal point of view) that boost does not maintain stable branches and so API is not stable (change of version) or bugs are not fixed in earlier versions. I very like boost but there is a cost of using it. And Boost::variant won't be in the C++0X standard (If I'm right).
- Variant is for built-in types only and that's not my case.
- and finaly maybe less obvious, If you want to let the "user" to be able to implement his own MyValue and to store these obects in this container Variant is not adapted. Moreover the template is limited with 10 arguments (but maybe we can set it higher).