Boost logo

Boost Users :

Subject: Re: [Boost-users] advice with containers and data types
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-11-02 10:59:22


> i am a newbie to boost and hope, somebody here can give me an advice. i want to change the implementation of an existing container class in one of my projects. It is a container which for the moment is based on a very old roguewave version which should be replaced by boost. main features of this container are:
> - the container is based on a hashmap.
> - the key datatype can be string or int.
> - the value data type can be string, int, double, time, date, the container type itself and another container type.
>
> I thought about implementing the class based on a map container with boost:any as key and value type.

Since the number of possible concrete types for the key and value are fixed, you may want to consider using boost::variant [1] instead of boost::any. For the value type, take a look at recursive variants.

Regards,
Nate

[1] http://www.boost.org/doc/libs/1_51_0/doc/html/variant.html
[2] http://www.boost.org/doc/libs/1_51_0/doc/html/variant/tutorial.html#variant.tutorial.recursive

                                               



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net