|
Boost Users : |
Subject: Re: [Boost-users] adding elements to a std::container in a single expression
From: Christoph Heindl (christoph.heindl_at_[hidden])
Date: 2011-08-14 02:11:16
On Sun, Aug 14, 2011 at 3:26 AM, Peter Foelsche <foelsche_at_[hidden]> wrote:
> push_back_container<std::vector<something>
>>()._push_back(something1)._push_back(_something2)
>
> Is there some more elegant way to do this?
You might want to have a boost.assign.
#include <boost/assign/list_of.hpp>
using namespace boost::assign;
std::vector<int> = list_of(1)(2)(3)(4);
Or
#include <boost/assign/std/vector.hpp>
using namespace boost::assign;
vector<int> values;
values += 1,2,3,4;
Best regards,
Christoph
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