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
to store addresses of the data, and dequeboost::core::typeinfo to store the data types. Therefore, iterating through the container to get the data for datatype T simply involves iterating through the dequeboost::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::vectorboost::any. So I still don't understand how your container is better than std::vectorboost::any.