Sorry, it must be to_container() and not to_adapter().

On Wed, Mar 17, 2010 at 1:51 PM, Ovanes Markarian <om_boost@keywallet.com> wrote:

On Wed, Mar 17, 2010 at 1:32 PM, Andrey Torba <andreytorba@gmail.com> wrote:
The code is compilable on msvc but is not on gcc-4.3:

But the problem occurs when i try to initialise std::vector in a class initialization list:
class sss
{
  std::vector<int> v;
  sss()
    : v(boost::assign::list_of(1)(2))
  {}
};

What happens if you call:
sss()
    : v(boost::assign::list_of(1)(2).to_adapter())
  {}

list_of implements 2 members:
implicit conversion opertor to the container type and the to_adapter member. You can cast list_of instance to your vector<int> if that with adapter does not work. Other solution can be:

If you need efficiency, you still can use the vector ctor which reserves the number of items in a vector and than copies
the elements from the list.

sss() : v(2)
{
  v = list_of...;

Regards,
Ovanes