Using Boost Assign to initialise a list of a list.
std::list<std::list<int> > listOfListOfInts = list_of(list_of<int>(1)(2))
(list_of<int>(1)(2));
assert(listOfListOfInts.front().front() == 1);
std::list<std::list<int> > listOfListOfInts = list_of(list_of<int>(1)(2))
(list_of<int>(1)(2));
assert(listOfListOfInts.front().front() == 1);
Note that the inner lists need to the type hint. Visual Studio 2008 caused a compiler crash without it!
keywords for search: nest nested std stl list boost assign list_of initialise
Note: modern C++ has initialisation built in now. Use {} for all initialisation.
No comments:
Post a Comment