|
Boost Users : |
Subject: Re: [Boost-users] Advise sought for container type
From: joel (joel.falcou_at_[hidden])
Date: 2009-08-30 12:39:30
Archie14 wrote:
> given the class like the one below:
>
> template <typename T> class animal
> {
> public:
> animal (const char* ofname) : _name(ofname) {}
> private:
> typedef T _T;
> std::string _name;
> _T behavior;
> }
>
> class MeatEater {};
> class GrassEather {};
>
> animal<MeatEater> bear ("bear");
> animal<GrassEater> rabbit ("rabbit");
>
> How to store "bear" and "rabbit" instances in a vector?
> Advise is greatly appreciated
Do you knwo in advance how many "Eater" type you'll have ?
If yes : do a std::vector of boost::variant
If no : do a std::vector of boost::any
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
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