Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59450 - sandbox/statistics/detail/assign/boost/assign
From: erwann.rogard_at_[hidden]
Date: 2010-02-03 15:33:18


Author: e_r
Date: 2010-02-03 15:33:18 EST (Wed, 03 Feb 2010)
New Revision: 59450
URL: http://svn.boost.org/trac/boost/changeset/59450

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp | 19 +++++++++++--------
   1 files changed, 11 insertions(+), 8 deletions(-)

Modified: sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp 2010-02-03 15:33:18 EST (Wed, 03 Feb 2010)
@@ -17,22 +17,22 @@
 #include <boost/ref.hpp>
 #include <boost/array.hpp>
 #include <boost/range.hpp>
+#include <boost/assign/list_of.hpp>
 
 namespace boost{
 namespace assign{
 
 // Usage : vec = cref_list2_of(a)(b)(c)
-
 // The idea of this class was developed in collaboration with P.M.
-
+// Complexity of cref_list2_of for size N : 2*N allocation of references
 template<
         typename T,
         int N,
     typename B
>
 class cref_impl : B{
-
- typedef boost::reference_wrapper<const T> ref_;
+
+ typedef boost::assign_detail::assign_reference<const T> ref_;
 
         typedef cref_impl<T,N,B> this_;
 
@@ -49,6 +49,9 @@
 
         template<typename T1>
     struct array{ typedef boost::array<T1,N+1> type; };
+
+ template<typename T1> // because reference_wrapper has no default constructor
+ struct ref_array : array<boost::assign_detail::assign_reference<const T1> >{};
     
         typedef typename boost::is_same<
             boost::mpl::int_<N>,
@@ -58,7 +61,6 @@
         public:
 
         typedef boost::mpl::bool_<exit_impl_::value> exit_;
-
     
         cref_impl(const T& t):ref(t){}
 
@@ -88,11 +90,12 @@
         // Requirement: C(begin,end) constructor
         template<typename C>
         operator C(){
- // TODO consider either bypassing the array altogether and call push_front
- // to preserve the referenceness of the approach
+ // TODO consider instead:
+ // C c; c.reserve()
+ // and recursively calling push_front
     
             typedef typename boost::range_value<C>::type val_;
- typedef typename array<val_>::type ar_;
+ typedef typename ref_array<val_>::type ar_;
         ar_ ar;
         this->write_to_array(ar,exit_());
         return C(boost::begin(ar),boost::end(ar));


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk