Boost logo

Boost :

Subject: Re: [boost] Interest in a container which can hold multiple data types?
From: Boris Rasin (boris_at_[hidden])
Date: 2015-05-05 04:10:54

On 5/5/2015 6:54 AM, James Armstrong wrote:
> So, as it is currently implemented, it doesn't actually make use of
> boost::any or boost::variants. I used a deque<void*> to store addresses of
> the data, and deque<boost::core::typeinfo> to store the data types.
> Therefore, iterating through the container to get the data for datatype T
> simply involves iterating through the deque<boost::core::typeinfo> until a
> type match is found, then casting the void* to a T* for the corresponding
> index.
> There are definitely different ways to take the idea, and maybe there is
> use for multiple types of heterogeneous containers. The way this container
> is setup has the advantage (depending on your viewpoint) that you do not
> have to explicit declare what data types the container will store up
> front. This could be useful in some context where, for instance, you are
> pulling information from a database where you don't quite know up front
> whether certain fields will be numeric or character data until you've
> queried the db. This container can allow you to pop in whatever data-type
> the result is, without having to explicitly list out every possibility up
> front.

Like I already said, all this is also true for std::vector<boost::any>.
So I still don't understand how your container is better than

Boost list run by bdawes at, gregod at, cpdaniel at, john at