
On Mon, Jun 29, 2009 at 12:13 PM, Scott McMurray <me22.ca+boost@gmail.com>wrote:
2009/6/28 Christian Schladetsch <christian.schladetsch@gmail.com>:
On Mon, Jun 29, 2009 at 12:58 PM, Robert Ramey <ramey@rrsd.com> wrote:
How is this different from a container of <boost/variant.hpp>
boost::variant doesnt support custom allocators. it uses naked new and delete.
A quick test with geordi suggests that it uses placement new, not naked new:
That's true quite often, but it does use naked new and delete to make backups in backup_assign_impl. (that's where I saw the delete and new in the first place). This may or may not be a problem. However, how would you use a std::vector<variant<...> >? struct T0; struct T1; ... struct Tn; typedef std::vector<boost::variant<T0, T1, ... , Tn>, custom_allocator<boost::variant<T0, T1, ... , Tn> > > vec; Does that make much sense? You have to know all the possible types that could go into the container at the point of declaration. This contends with the idea of a general heterogenous collection that can be passsed around and used. Plus the syntax for using such a beast might be awkward. Has anyone tried this in practise? I'll have a quick look... Cheers, Christian.