Boost logo

Boost :

Subject: Re: [boost] Interest in a "Heterogenous Container" system?
From: Christian Schladetsch (christian.schladetsch_at_[hidden])
Date: 2009-06-28 20:23:24


On Mon, Jun 29, 2009 at 12:13 PM, Scott McMurray <me22.ca+boost_at_[hidden]>wrote:

> 2009/6/28 Christian Schladetsch <christian.schladetsch_at_[hidden]>:
> > On Mon, Jun 29, 2009 at 12:58 PM, Robert Ramey <ramey_at_[hidden]> 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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk