[mini-review] Update of Boost.Assign (13th-19th of June)

Dear Boost Developers and Users, Erwann Rogard has implemented an update to Boost.Assign which we shall evaluate during the next week. His extensions allows one to write code like the following: (A) A list of references (to temporaries, in this example): boost::array<int,8> a = cref_csv( 1,5,3,4,2,9,0,7 ) (B) Chained ranges: vector<int> v = vector<int>( 3,1 ) && vector<int>( 3,2 ); If you have comments and suggestions about these new features, please submit a small review or voice your oppinion on the Boost developer list. If you have other feedback for Boost.Assign, now would be a good time to mention them too. If you submit a review, please follow the guidelines here: http://www.boost.org/community/reviews.html#Comments To access the new docs, please see https://svn.boost.org/svn/boost/sandbox/statistics/support/libs/assign/doc/i... To access the new code, please see https://svn.boost.org/svn/boost/sandbox/statistics/support/boost/assign/ best regards Thorsten Ottosen, Review Manager

On 13 Jun 2010, at 21:57, Thorsten Ottosen wrote:
If you have comments and suggestions about these new features, please submit a small review or voice your oppinion on the Boost developer list. If you have other feedback for Boost.Assign, now would be a good time to mention them too.
While independant of this change, I believe Boost.Assign may be ideally suited to use variadic templates. I am already making use of a variadic push_back and container construction, like: push_back(v,1,2,3,4); and: make<std::vector>(1,2,3,4,5); // Makes a std::vector<int> containing 1,2,3,4,5 make_list(1,2,3,4,5); // Makes a list which can be assigned to any standard container, filling it with 1,2,3,4,5. I do not know if it would be best for these to be integrated into the existing library, or kept separate. Chris

Christopher, thanks for inquiring.
and:
make<std::vector>(1,2,3,4,5); // Makes a std::vector<int> containing 1,2,3,4,5 make_list(1,2,3,4,5); // Makes a list which can be assigned to any standard container, filling it with 1,2,3,4,5.
Something similar is already possible before the proposed extension e.g. list_of(1)(2)(3)(4)(5).convert_to_container<std::vector<int> >(); std::vector<int> vec = list_of(1)(2)(3)(4)(5); In the proposed extension, cref_csv(1,2,3,4,5) or cref_list_of(1)(2)(3)(4)(5) can do the same but keep references to the arguments rather than copying them. Also, I have formalized the rules of conversion in the doc: https://svn.boost.org/svn/boost/sandbox/statistics/support/libs/assign/doc/i...

On 14 Jun 2010, at 14:57, er wrote:
Christopher, thanks for inquiring.
and: make<std::vector>(1,2,3,4,5); // Makes a std::vector<int> containing 1,2,3,4,5 make_list(1,2,3,4,5); // Makes a list which can be assigned to any standard container, filling it with 1,2,3,4,5.
Something similar is already possible before the proposed extension e.g.
list_of(1)(2)(3)(4)(5).convert_to_container<std::vector<int> >(); std::vector<int> vec = list_of(1)(2)(3)(4)(5);
Certainly this doesn't add anything new. Personally I prefer the look of (1,2,3,4,5) over (1)(2)(3)(4)(5), now that the core language supports it efficiently. Chris

Personally I prefer the look of (1,2,3,4,5) over (1)(2)(3)(4)(5), now that the core language supports it efficiently.
This is indeed the motivation for cref_csv, which is part of the proposed extension. http://svn.boost.org/svn/boost/sandbox/statistics/support/libs/assign/doc/in...

Christopher Jefferson wrote:
While independant of this change, I believe Boost.Assign may be ideally suited to use variadic templates. I am already making use of a variadic push_back and container construction, like:
push_back(v,1,2,3,4);
As of now, the closest match, as you probably know, is: #include <boost/assign/list_inserter.hpp> push_back(v)(1)(2)(3)(4); With a view to promote separation of responsibility between different functions, perhaps we may (also) consider a new function : push_back_range(const V&,const R&); This would tie in with the proposed extension like this: push_back_range(v,cref_csv(1,2,3,4)); or like this: push_back_range(v, w && cref_csv(1,2,3,4) );

Hi er, On Thu, Jun 17, 2010 at 1:54 AM, er <erwann.rogard@gmail.com> wrote:
Christopher Jefferson wrote:
While independant of this change, I believe Boost.Assign may be ideally suited to use variadic templates. I am already making use of a variadic push_back and container construction, like:
push_back(v,1,2,3,4);
As of now, the closest match, as you probably know, is:
#include <boost/assign/list_inserter.hpp> push_back(v)(1)(2)(3)(4);
With a view to promote separation of responsibility between different functions, perhaps we may (also) consider a new function :
push_back_range(const V&,const R&);
This would tie in with the proposed extension like this:
push_back_range(v,cref_csv(1,2,3,4));
I'd personally be very happy with that functionality and syntax. I assume performance-wise this is not much different from a standard .push_back of each entry seperately? Best, Dee

This would tie in with the proposed extension like this:
push_back_range(v,cref_csv(1,2,3,4));
I'd personally be very happy with that functionality and syntax. I assume performance-wise this is not much different from a standard .push_back of each entry seperately?
Thanks. As already noted by Thorsten, a straightforward solution is boost::push_back( cont, cref_csv(1,2,3,4) );

On Fri, Jun 18, 2010 at 12:19 AM, er <erwann.rogard@gmail.com> wrote:
This would tie in with the proposed extension like this:
push_back_range(v,cref_csv(1,2,3,4));
I'd personally be very happy with that functionality and syntax. I assume performance-wise this is not much different from a standard .push_back of each entry seperately?
Thanks. As already noted by Thorsten, a straightforward solution is
boost::push_back( cont, cref_csv(1,2,3,4) );
Thanks! Dee

With a view to promote separation of responsibility between different functions, perhaps we may (also) consider a new function :
push_back_range(const V&,const R&);
This would tie in with the proposed extension like this:
push_back_range(v,cref_csv(1,2,3,4));
On second thought boost::copy is sufficient: boost::copy(cref_csv(1,2,3,4),std::back_inserter(v)); Also, BOOST_AUTO( tmp, ref_csv(a,b,c,d)); boost::copy( v, boost::begin(tmp)); may come in handy.

er skrev:
With a view to promote separation of responsibility between different functions, perhaps we may (also) consider a new function :
push_back_range(const V&,const R&);
This would tie in with the proposed extension like this:
push_back_range(v,cref_csv(1,2,3,4));
On second thought boost::copy is sufficient:
boost::copy(cref_csv(1,2,3,4),std::back_inserter(v));
Also,
BOOST_AUTO( tmp, ref_csv(a,b,c,d)); boost::copy( v, boost::begin(tmp));
may come in handy.
I would turn my attention to the new Range library: boost::push_back( cont, cref_csv(1,2,3,4) ); http://www.boost.org/doc/libs/1_43_0/libs/range/doc/html/range/reference/alg... -Thorsten
participants (4)
-
Christopher Jefferson
-
Diederick C. Niehorster
-
er
-
Thorsten Ottosen