Boost logo

Boost :

Subject: Re: [boost] [mini-review] Update of Boost.Assign (13th-19th of June)
From: er (erwann.rogard_at_[hidden])
Date: 2010-06-20 13:51:13


>> I guess it wouldn't be an insurmountable task to overload csv() on the
>> number of arguments, internally calling list_of(), and returning its
>> results. That's approximately how ref_csv() and ref_list_of() relate to
>> each other.
>
> That sounds sensible. I think there should be such a function.
>

Tentatively I made the change here:

http://svn.boost.org/svn/boost/sandbox/statistics/support/boost/assign/list_of.hpp

Here's an example:

{
     int a = 1, b = 2 ,c = 3;
     std::vector<int> vec = list_of(a).csv(b,c);
     BOOST_ASSERT( vec[0] == 1 );
     BOOST_ASSERT( vec[1] == 2 );
     BOOST_ASSERT( vec[2] == 3 );
}

which can be found here
http://svn.boost.org/svn/boost/sandbox/statistics/support/libs/assign/example/range.cpp

Note that list_of(a).csv(b,c), as opposed to csv(a,b,c), has the
advantage of returning a reference.

There is a separate thread on how to create an empty list, which would
allow something like empty_list_of().csv(a,b,c), which would be more
elegant.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk