Boost logo

Boost :

Subject: Re: [boost] Interest in a container which can hold multiple data types?
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2015-05-06 11:35:57


My 2cents as a data point related to this discussion:

I use polymorphic containers in my projects but I had to implement them
myself
as the poly_collection was not available before and it don't always match
my needs.
I realized through usage that I had very different needs for polymorphic
containers
so maybe it would be interesting to some people here to have some info
about use case.
I have interest in seeing polymorphic containers in boost too.

Here is what I use currently:

 - polymorphic collection of vectors:
   This is more or less the poly collection, with no guarantee of order
   but which does guarantee contiguity of values for one type,
   so that it is possible to efficiently go through all the values of one
type.
  I tend to use this for several pool-like systems which provide services
for
  sets of data which should be processed by the same "thread".

 - a container storing only one value per type:
  I use this for some kind of type-identified-messages board system
  where I just store the last message value of each type of message in the
container.
  Of course for one type there can be no value too.
  It's more or less a map<typeid, anyvalue> but the interface is just
simpler.

 - a set, giving guarantee of unique values, but that does take any kind of
value type.
  I have an old review about this, so the code is similar to this:
https://gist.github.com/Klaim/10599137
  (I guess it could be optimized but I'm not an expert)


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