Boost logo

Boost Users :

Subject: Re: [Boost-users] [assign] Nested initialization of std containers
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-02-18 13:19:26


Joseph Lisee skrev:
> I am trying to use list_of and map_list_of to initialize a std::vector
> containing std::maps. I am using Boost 1.37 and Mac OS X 10.4 with Apple's G++
> 4.0.1. Here is a complete example:
>
> #include <vector>
> #include <map>
> #include <string>
>
> #include <boost/assign/list_of.hpp>
>
> using namespace boost::assign;
>
> typedef std::map<int, std::string> dict;
> typedef std::vector<dict> list;
>
> int main()
> {
> // Works
> dict d = map_list_of(1,"B")(2,"A");
> list l1 = list_of(d);
>
> // Does not compile
> list l2 = list_of(map_list_of(1,"B")(2,"A"));

try

list l2 = list_of<dict>( ... )

-Thorsten


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