Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59997 - in sandbox/statistics/detail/assign: boost/assign/auto_size boost/assign/auto_size/detail boost/assign/auto_size/detail/policy libs/assign/example libs/assign/src libs/assign/test
From: erwann.rogard_at_[hidden]
Date: 2010-02-28 14:43:13


Author: e_r
Date: 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
New Revision: 59997
URL: http://svn.boost.org/trac/boost/changeset/59997

Log:
m
Added:
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_interface.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_wrapper.hpp (contents, props changed)
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/policy/
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/policy/array.hpp (contents, props changed)
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/assign_refence_copy.hpp | 2
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp | 233 ++++++++++-----------------------------
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp | 53 ++++----
   sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp | 4
   sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp | 1
   sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp | 15 +-
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 2
   sandbox/statistics/detail/assign/libs/assign/test/speed_csv.cpp | 24 ++--
   8 files changed, 115 insertions(+), 219 deletions(-)

Added: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_interface.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_interface.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,132 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::array_interface.hpp //
+// //
+// (C) Copyright 2010 Erwann Rogard //
+// Use, modification and distribution are subject to the //
+// Boost Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_INTERFACE_ER_2010_HPP
+#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_INTERFACE_ER_2010_HPP
+#include <algorithm>
+#include <boost/array.hpp>
+#include <boost/range.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace auto_size{
+
+ template<typename T,int N,template<typename> class Ref>
+ struct ref_array{
+ typedef boost::array<typename Ref<T>::type,N> type;
+ };
+
+ // Exposes the boost::array interface. The actual array is implemented in a
+ // derived class, D
+ //
+ // Requirements:
+ // D must implement:
+ // const ref_array_& ref_array_impl()const
+ // ref_array& ref_array_impl()
+ template<typename T,int N,template<typename> class Ref,typename D>
+ struct array_interface{
+ typedef typename Ref<T>::type ref_;
+ typedef typename ref_array<T,N,Ref>::type ref_array_;
+
+ typedef ref_ value_type;
+ typedef typename
+ boost::range_iterator<ref_array_>::type iterator;
+ typedef typename boost::range_iterator<
+ const ref_array_>::type const_iterator;
+ typedef typename
+ boost::range_size<ref_array_>::type size_type;
+ typedef typename boost::range_difference<
+ ref_array_>::type difference_type;
+
+ iterator begin()
+ {
+ return boost::begin(this->ref_array());
+ }
+ iterator end()
+ {
+ return boost::end(this->ref_array());
+ }
+
+ const_iterator begin()const
+ {
+ return boost::begin(this->ref_array());
+ }
+ const_iterator end()const
+ {
+ return boost::end(this->ref_array());
+ }
+
+ size_type size() const
+ {
+ return ref_array_::size();
+ }
+ bool empty() const
+ {
+ return !(this->size());
+ }
+
+ typedef typename ref_array_::reference reference;
+ typedef typename
+ ref_array_::const_reference const_reference;
+
+ reference operator[](size_type i){ return (this->ref_array())[i]; }
+ const_reference operator[](size_type i)const{
+ return (this->array())[i]; }
+
+ reference front(){ return (this->ref_array()).front(); }
+ const_reference front() const{ return (this->ref_array()).front(); }
+ reference back(){ return (this->ref_array()).back(); }
+ const_reference back() const{ return (this->ref_array()).back(); }
+
+ void swap(ref_array_& other){ return (this->ref_array()).swap(other); }
+ void assign(const T& val){
+ // Force copy semantics. Suggested by M.P.G on Feb 28th, 2010.
+// ref_array_& ra = this->ref_array();
+// std::fill(ra.begin(), ra.end(), val);
+ return this->ref_array().assign(val);
+ }
+
+ template<typename T1>
+ operator boost::array<T1,N>()const{
+ boost::array<T1,N> ar;
+ std::copy(
+ boost::begin(this->ref_array()),
+ boost::end(this->ref_array()),
+ boost::begin(ar)
+ );
+ return ar;
+ }
+
+ template<typename C>
+ operator C ()const
+ {
+ return C(
+ boost::begin(this->ref_array()),
+ boost::end(this->ref_array())
+ );
+ }
+
+ private:
+
+ ref_array_& ref_array(){
+ return static_cast<D&>(*this).ref_array_impl();
+ }
+
+ const ref_array_& ref_array()const{
+ return static_cast<const D&>(*this).ref_array_impl();
+ }
+
+ };
+
+}// auto_size
+}// detail
+}// assign
+}// boost
+
+#endif

Added: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_wrapper.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/array_wrapper.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,51 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::array_wrapper.hpp //
+// //
+// (C) Copyright 2010 Erwann Rogard //
+// Use, modification and distribution are subject to the //
+// Boost Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_WRAPPER_ER_2010_HPP
+#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_ARRAY_WRAPPER_ER_2010_HPP
+#include <boost/shared_ptr.hpp>
+#include <boost/assign/auto_size/detail/array_interface.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace auto_size{
+
+ template<typename T,int N,template<typename> class Ref>
+ class array_wrapper
+ : public array_interface<T,N,Ref,array_wrapper<T,N,Ref> >
+ {
+
+ typedef typename ref_array<T,N,Ref>::type ref_array_;
+ typedef boost::shared_ptr<ref_array_> smart_ptr_;
+
+ public:
+
+ array_wrapper(smart_ptr_ arg)
+ :ptr(arg){}
+
+ ref_array_& ref_array_impl(){
+ return (*this->ptr);
+ }
+
+ const ref_array_& ref_array_impl()const{
+ return (*this->ptr);
+ }
+
+ private:
+ mutable smart_ptr_ ptr;
+
+ };
+
+}// auto_size
+}// detail
+}// assign
+}// boost
+
+#endif
+

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/assign_refence_copy.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/assign_refence_copy.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/assign_refence_copy.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -24,7 +24,7 @@
         assign_reference_copy()
         { /* intentionally empty */ }
 
- assign_reference_copy( T& r ) : ref_(&r)
+ explicit assign_reference_copy( T& r ) : ref_(&r)
         { }
 
         void operator=( const T& r )

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -13,23 +13,19 @@
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/equal_to.hpp>
-#include <boost/utility/enable_if.hpp>
-#include <boost/shared_ptr.hpp>
+//#include <boost/shared_ptr.hpp>
 #include <boost/type_traits.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/array.hpp>
-#include <boost/range.hpp>
+//#include <boost/array.hpp>
+//#include <boost/range.hpp>
 #include <boost/assign/list_of.hpp> // needed for assign_referene
 #include <boost/assign/auto_size/detail/assign_refence_copy.hpp>
+#include <boost/assign/auto_size/detail/policy/array.hpp>
 
-// Creates a collection of references exposing the boost::array interface and
-// convertible to a range constructible from a pair of iterators.
+// Creates a collection of references.
 //
 // This approach improves upon ref_list_of<int>() by deducing the number of
-// arguments at compile time and factors the reference wrapper into a template.
-// Whereas successive unary function calls is the usual way to create a collec-
-// tion in the Boost.Assign, the auto-size set up optionally provides functions
-// that are overloaded on the number of arguments. See csv.hpp
+// arguments at compile time, and factors both the reference wrapper and the
+// container interface into templates, denoted Ref and P, respectively.
 //
 // Note:
 // In most situations, a reference wrapper that has copy rather than rebind
@@ -57,198 +53,83 @@
             
     typedef boost::mpl::void_ top_;
             
- template<typename T,int N,template<typename> class Ref>
- struct ref_array{
- typedef boost::array<typename Ref<T>::type,N> type;
- };
-
- template<typename L,typename T,int N,template<typename> class Ref>
+ template<typename L,typename T,int N,template<typename> class Ref,
+ typename P>
     struct expr;
             
- template<typename E,typename T,int N,template<typename> class Ref>
+ template<typename E,typename T,int N,template<typename> class Ref,
+ typename P>
     struct next{
- typedef expr<E,T,N,Ref> expr_;
- typedef expr<expr_,T,N+1,Ref> type;
+ typedef expr<E,T,N,Ref,P> expr_;
+ typedef expr<expr_,T,N+1,Ref,P> type;
     };
 
- template<typename T,int N,template<typename> class Ref,typename D>
- struct array_wrapper;
+ struct default_policy;
+
+ struct default_policy{
+
+ template<typename E,typename T,int N,template<typename> class Ref>
+ struct apply{
+ typedef expr<E,T,N,Ref,default_policy> expr_;
+ typedef policy::array<T,N,Ref,expr_> type;
+ };
+ };
 
- template<typename E,typename T,int N,template<typename> class Ref>
- class expr : public array_wrapper<T,N,Ref,expr<E,T,N,Ref> >{
+ template<
+ typename E,typename T,int N,template<typename> class Ref,typename P
+ >
+ class expr : public default_policy::apply<E,T,N,Ref>::type{
         typedef boost::mpl::int_<N> int_n_;
         typedef boost::mpl::int_<1> int_1_;
         typedef typename Ref<T>::type ref_;
 
- typedef array_wrapper<T,N,Ref,expr<E,T,N,Ref> > super_;
+ typedef typename default_policy::apply<E,T,N,Ref>::type super_;
 
         public:
+
         typedef typename
                 boost::mpl::equal_to<int_n_,int_1_>::type is_first_;
         typedef typename
                 boost::mpl::if_<is_first_,E,const E&>::type previous_;
- typedef typename next<E,T,N,Ref>::type next_;
+ typedef typename next<E,T,N,Ref,P>::type next_;
                                 
         expr(const E& p,T& t):previous(p),ref(t){}
 
         typedef next_ result_type;
         next_ operator()(T& t)const{ return next_(*this,t); }
-
+
         mutable previous_ previous;
         mutable ref_ ref;
 
     };
 
- template<typename T,int N,template<typename> class Ref,typename D>
- struct array_wrapper{
- typedef typename Ref<T>::type ref_;
- typedef typename ref_array<T,N,Ref>::type ref_array_;
-
- typedef ref_ value_type;
- typedef typename
- boost::range_iterator<ref_array_>::type iterator;
- typedef typename boost::range_iterator<
- const ref_array_>::type const_iterator;
- typedef typename
- boost::range_size<ref_array_>::type size_type;
- typedef typename boost::range_difference<
- ref_array_>::type difference_type;
-
- iterator begin()
- {
- return boost::begin(this->ref_array());
- }
- iterator end()
- {
- return boost::end(this->ref_array());
- }
-
- const_iterator begin()const
- {
- return boost::begin(this->ref_array());
- }
- const_iterator end()const
- {
- return boost::end(this->ref_array());
- }
-
- size_type size() const
- {
- return ref_array_::size();
- }
- bool empty() const
- {
- return !(this->size());
- }
-
- typedef typename ref_array_::reference reference;
- typedef typename
- ref_array_::const_reference const_reference;
-
- reference operator[](size_type i){ return (this->ref_array())[i]; }
- const_reference operator[](size_type i)const{
- return (this->array())[i]; }
-
- reference front(){ return (this->ref_array()).front(); }
- const_reference front() const{ return (this->ref_array()).front(); }
- reference back(){ return (this->ref_array()).back(); }
- const_reference back() const{ return (this->ref_array()).back(); }
-
- void swap(ref_array_& other){ return (this->ref_array()).swap(other); }
- void assign(const T& val){ return (this->ref_array()).assign(val); }
-
- template<typename T1>
- operator boost::array<T1,N>()const{
- boost::array<T1,N> ar;
- std::copy(
- boost::begin(this->ref_array()),
- boost::end(this->ref_array()),
- boost::begin(ar)
- );
- return ar;
- }
-
- template<typename C>
- operator C ()const
- {
- return C(
- boost::begin(this->ref_array()),
- boost::end(this->ref_array())
- );
- }
-
- // Needed by csv.hpp
- const D& allocated()const{
- this->alloc_if();
- return static_cast<const D&>(*this);
- }
-
- private:
-
- void alloc_if()const{
- if(!this->ptr){
- return this->alloc();
- }
- }
-
- void alloc()const{
- this->ptr = smart_ptr_(new ref_array_);
- write_to_array(*this->ptr,static_cast<const D&>(*this));
- }
-
- protected:
-
- ref_array_& ref_array(){
- this->alloc_if();
- return (*this->ptr);
- }
-
- const ref_array_& ref_array()const{
- this->alloc_if();
- return (*this->ptr);
- }
-
- private:
- typedef boost::shared_ptr<ref_array_> smart_ptr_;
- // Only the last of N expressions needs to instantiate an array,
- // hence a pointer.
- mutable smart_ptr_ ptr;
-
- };
-
     // ---- write_to_array ---- //
 
     typedef boost::mpl::bool_<false> false_;
     typedef boost::mpl::bool_<true> true_;
             
     template<typename A,typename E,typename T,int N,
- template<typename> class Ref>
- void write_to_array(A& a,const expr<E,T,N,Ref>& e){
- typedef expr<E,T,N,Ref> expr_;
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e){
+ typedef expr<E,T,N,Ref,P> expr_;
         typedef typename expr_::is_first_ exit_;
         write_to_array(a,e,exit_());
     }
             
     template<typename A,typename E,typename T,int N,
- template<typename> class Ref>
- void write_to_array(A& a,const expr<E,T,N,Ref>& e,false_ /*exit*/){
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e,false_ /*exit*/){
         a[N-1] = e.ref;
         write_to_array(a,e.previous);
     }
             
     template<typename A,typename E,typename T,int N,
- template<typename> class Ref>
- void write_to_array(A& a,const expr<E,T,N,Ref>& e,true_ /*exit*/){
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e,true_ /*exit*/){
         a[N-1] = e.ref;
     }
 
- // ---- first expr ---- //
-
- template<typename T,template<typename> class Ref>
- struct first_expr{
- typedef detail::auto_size::expr<detail::auto_size::top_,T,1,Ref> type;
- static type call(T& a){ return type(top_(),a); }
- };
+ // ---- ref wrappers ---- //
 
     template<typename T>
     struct ref_copy{
@@ -256,32 +137,40 @@
     };
 
     template<typename T>
- struct first_copy : first_expr<T,ref_copy>{};
-
- template<typename T>
     struct ref_rebind{
         typedef boost::assign_detail::assign_reference<T> type;
     };
 
- template<typename T>
- struct first_rebind : first_expr<T,ref_rebind>{};
+ // ---- first expr ---- //
+
+ template<typename T,template<typename> class Ref,typename P>
+ struct first_expr{
+ typedef detail::auto_size::expr<detail::auto_size::top_,T,1,Ref,P> type;
+ static type call(T& a){ return type(top_(),a); }
+ };
+
+ template<typename T,typename P = default_policy>
+ struct first_copy : first_expr<T,ref_copy,P>{};
+
+ template<typename T,typename P = default_policy>
+ struct first_rebind : first_expr<T,ref_rebind,P>{};
 
     // ---- result_of ---- //
         
- template<typename T,int N,template<typename> class Ref>
+ template<typename T,int N,template<typename> class Ref,typename P>
     struct result_of{
- typedef typename result_of<T,N-1,Ref>::type previous;
- typedef expr<previous,T,N,Ref> type;
+ typedef typename result_of<T,N-1,Ref,P>::type previous;
+ typedef expr<previous,T,N,Ref,P> type;
     };
 
- template<typename T,template<typename> class Ref>
- struct result_of<T,1,Ref> : first_expr<T,Ref>{};
+ template<typename T,template<typename> class Ref,typename P>
+ struct result_of<T,1,Ref,P> : first_expr<T,Ref,P>{};
 
- template<typename T,int N>
- struct result_of_copy : result_of<T,N,ref_copy>{};
+ template<typename T,int N,typename P = default_policy>
+ struct result_of_copy : result_of<T,N,ref_copy,P>{};
 
- template<typename T,int N>
- struct result_of_rebind : result_of<T,N,ref_rebind>{};
+ template<typename T,int N,typename P = default_policy>
+ struct result_of_rebind : result_of<T,N,ref_rebind,P>{};
             
 }// auto_size
 }// detail

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -14,20 +14,22 @@
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/array_wrapper.hpp>
 
-// Let n = BOOST_ASSIGN_CSV_SIZE and a1,...,an objects of type T and
-// Ref an alias for BOOST_ASSIGN_CSV_ref
+// Whereas successive unary function calls is the usual way to create a collec-
+// tion in Boost.Assign, this macro provides, as an alternative, functions that
+// are overloaded on the number of arguments.
+//
+// Let n = BOOST_ASSIGN_CSV_SIZE and a1,...,an objects of type T, Ref an alias
+// for BOOST_ASSIGN_CSV_ref, and w<U,N> and alias for
+// array_wrapper<U,N,BOOST_ASSIGN_CSV_ref>.
+//
 // Usage:
 // BOOST_ASSIGN_CSV(fun) creates for i=2,...,n the following overloads:
-// fun(a1,..,.ai)
-// cfun(a1,..,.ai)
-// which return the same result as calling fun(a1)...(ai) and cfun(a1)...(ai),
-// respectively.
-//
-// Requirements:
-// Valid expression Result
-// fun(a1)(a2)...(an) auto_size::result_of<T,n,Ref>::type
-// cfun(a1)(a2)...(an) auto_size::result_of<const T,n,Ref>::type
+// fun_csv(a1,..,.ai)
+// cfun_csv(a1,..,.ai)
+// which return the same result as calling fun(a1)...(ai).wrapper(), and
+// cfun(a1)...(ai).wrapper(), of type w<T,i> and w<const T,i>, respectively.
 
 #ifndef BOOST_ASSIGN_CSV_SIZE
 #define BOOST_ASSIGN_CSV_SIZE 20
@@ -38,38 +40,37 @@
 #endif
 
 #define BOOST_ASSIGN_CSV_ARG(z,n,arg) (BOOST_PP_CAT(arg,n))
-#define BOOST_ASSIGN_CSV_CALL(fun,N) \
- boost::assign::fun BOOST_PP_ENUM(N,BOOST_ASSIGN_CSV_ARG,~) \
+#define BOOST_ASSIGN_CSV_CALL(fun,N,arg) \
+ boost::assign::fun BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,arg) \
 /**/
 
-
 #define BOOST_ASSIGN_CSV_ITER_UNQUAL(F,T,U,N) \
 namespace boost{ \
 namespace assign{ \
         template<typename T> \
- typename assign::detail::auto_size::result_of< \
- U,N,BOOST_ASSIGN_CSV_ref>::type \
- F(BOOST_PP_ENUM_PARAMS(N, U& _)){ \
- return (boost::assign::F \
- BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_) \
- ).allocated(); \
+ boost::assign::detail::auto_size::array_wrapper< \
+ U,N,BOOST_ASSIGN_CSV_ref> \
+ BOOST_PP_CAT(F,_csv)(BOOST_PP_ENUM_PARAMS(N, U& _)){ \
+ return ( \
+ boost::assign::F BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_) \
+ ).wrapper(); \
     } \
 } \
 } \
 /**/
 
-#define BOOST_ASSIGN_CSV_ITER(fun,N) \
- BOOST_ASSIGN_CSV_ITER_UNQUAL(fun,T,T,N) \
- BOOST_ASSIGN_CSV_ITER_UNQUAL(BOOST_PP_CAT(c,fun),T,const T,N) \
+#define BOOST_ASSIGN_CSV_ITER(F,N) \
+ BOOST_ASSIGN_CSV_ITER_UNQUAL(F,T,T,N) \
+ BOOST_ASSIGN_CSV_ITER_UNQUAL(BOOST_PP_CAT(c,F),T,const T,N) \
 /**/
 
-// overloads begin at n = 2
+// overloads begin at n = 1
 #define BOOST_ASSIGN_CSV_SHIFTED_ITER(z,n,F) \
- BOOST_ASSIGN_CSV_ITER(F,BOOST_PP_ADD(n,2)) \
+ BOOST_ASSIGN_CSV_ITER(F,BOOST_PP_ADD(n,1)) \
 /**/
 
 #define BOOST_ASSIGN_CSV_REPEAT(fun,N) \
- BOOST_PP_REPEAT(BOOST_PP_DEC(N),BOOST_ASSIGN_CSV_SHIFTED_ITER,fun) \
+ BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_SHIFTED_ITER,fun) \
 /**/
 
 #define BOOST_ASSIGN_CSV(fun) \

Added: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/policy/array.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/policy/array.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -0,0 +1,92 @@
+//////////////////////////////////////////////////////////////////////////////
+// assign::detail::policy::array.hpp //
+// //
+// (C) Copyright 2010 Erwann Rogard //
+// Use, modification and distribution are subject to the //
+// Boost Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ASSIGN_AUTO_SIZE_DETAIL_POLICY_ARRAY_ER_2010_HPP
+#define BOOST_ASSIGN_AUTO_SIZE_DETAIL_POLICY_ARRAY_ER_2010_HPP
+#include <boost/shared_ptr.hpp>
+#include <boost/assign/auto_size/detail/array_interface.hpp>
+#include <boost/assign/auto_size/detail/array_wrapper.hpp>
+
+namespace boost{
+namespace assign{
+namespace detail{
+namespace auto_size{
+
+ template<
+ typename E,typename T,int N,
+ template<typename> class Ref,
+ typename P
+ >
+ class expr;
+
+ template<typename T,int N,template<typename> class Ref>
+ struct ref_array;
+
+ template<typename A,typename E,typename T,int N,
+ template<typename> class Ref,typename P>
+ void write_to_array(A& a,const expr<E,T,N,Ref,P>& e);
+
+
+namespace policy{
+
+ // Used as a base of auto_size::expr, exposes the boost::array functionality
+ // and a conversion operator suitable for data-structures that are
+ // constructible from a pair of iterators.
+ template<typename T,int N,template<typename> class Ref,typename D>
+ class array
+ : public array_interface<T,N,Ref,array<T,N,Ref,D> >
+ {
+
+ typedef typename ref_array<T,N,Ref>::type ref_array_;
+
+ void alloc_if()const{
+ if(!this->ptr){
+ return this->alloc();
+ }
+ }
+
+ void alloc()const{
+ this->ptr = smart_ptr_(new ref_array_);
+ write_to_array(*this->ptr,static_cast<const D&>(*this));
+ }
+
+ public:
+
+ typedef array_wrapper<T,N,Ref> wrapper_;
+
+ // Needed by csv.hpp
+ wrapper_ wrapper()const{
+ this->alloc_if();
+ return wrapper_(this->ptr);
+ }
+
+ ref_array_& ref_array_impl(){
+ this->alloc_if();
+ return (*this->ptr);
+ }
+
+ const ref_array_& ref_array_impl()const{
+ this->alloc_if();
+ return (*this->ptr);
+ }
+
+ private:
+ typedef boost::shared_ptr<ref_array_> smart_ptr_;
+ // Only the last of N expressions needs to instantiate an array,
+ // hence a pointer.
+ mutable smart_ptr_ ptr;
+
+ };
+
+}// policy
+}// auto_size
+}// detail
+}// assign
+}// boost
+
+#endif

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -10,11 +10,12 @@
 #define BOOST_ASSIGN_AUTO_SIZE_REF_LIST_OF_ER_2010_HPP
 #include <boost/typeof/typeof.hpp> // tmp.
 #include <boost/assign/auto_size/detail/auto_size.hpp>
+#include <boost/assign/auto_size/detail/array_wrapper.hpp>
 
 // Creates a collection of references exposing the boost::array interface and
 // convertible to a range that is constructible from a pair of iterators. It can
 // be used either as the rhs or lhs of an assignment such as:
-// boost::fill(ref_list_of(a,b,c),0)
+// boost::fill(ref_list_of(a)(b)(c),0)
 // This function supersedes ref_list_of<int>().
 
 namespace boost{
@@ -35,6 +36,7 @@
 }// assign
 }// boost
 
+// Adds csv support, e.g. ref_list_of_csv(a,b,c)
 #define BOOST_ASSIGN_CSV_ref boost::assign::detail::auto_size::ref_copy
 #include <boost/assign/auto_size/detail/csv.hpp>
 BOOST_ASSIGN_CSV(ref_list_of)

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -35,6 +35,7 @@
 }// assign
 }// boost
 
+// Adds csv support, e.g. ref_rebind_list_of_csv(a,b,c)
 #define BOOST_ASSIGN_CSV_ref boost::assign::detail::auto_size::ref_rebind
 #include <boost/assign/auto_size/detail/csv.hpp>
 BOOST_ASSIGN_CSV(ref_rebind_list_of)

Modified: sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -12,6 +12,8 @@
 #include <boost/typeof/typeof.hpp>
 #include <boost/assign/auto_size/ref_rebind_list_of.hpp>
 #include <boost/assign/auto_size/ref_list_of.hpp>
+#include <boost/assign/auto_size/detail/array_wrapper.hpp>
+
 #include <boost/assign/list_of.hpp>
 #include <libs/assign/example/ref_list_of.h>
 
@@ -27,27 +29,28 @@
         // Since operator= calls begin() and end(), no need to test these separately
 
     {
- // cref_list_of
+ // cref_list_of_csv
 
             int a=1, b=2, c=3;
             ints_ ints;
     
         {
                     ints.clear();
- ints = cref_list_of(a,b,3);
+ ints = cref_list_of_csv(a,b,3);
             BOOST_ASSERT(ints[0] == a);
             BOOST_ASSERT(ints[1] == b);
             BOOST_ASSERT(ints[2] == c);
+
         }
         {
             array.assign(-1);
- array = cref_list_of(a,b,3);
+ array = cref_list_of_csv(a,b,3);
             BOOST_ASSERT(array[0] == a);
             BOOST_ASSERT(array[1] == b);
             BOOST_ASSERT(array[2] == c);
         }
         {
- BOOST_AUTO(tmp,ref_list_of(a,b,c));
+ BOOST_AUTO(tmp,ref_list_of_csv(a,b,c));
             std::fill(boost::begin(tmp),boost::end(tmp),0);
             BOOST_ASSERT(a == 0);
             BOOST_ASSERT(b == 0);
@@ -55,12 +58,12 @@
         }
     }
     {
- // ref_rebind_list_of
+ // ref_rebind_list_of_csv
         {
             int a=1, b=2, c=3;
             ints_ ints;
             ints.clear();
- BOOST_AUTO(tmp,cref_rebind_list_of(a,b,c));
+ BOOST_AUTO(tmp,cref_rebind_list_of_csv(a,b,c));
             {
                 ints = tmp;
                 BOOST_ASSERT(ints[0] == a);

Modified: sandbox/statistics/detail/assign/libs/assign/src/main.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/src/main.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/src/main.cpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -7,7 +7,7 @@
 int main (int argc, char * const argv[]) {
 
         example_ref_list_of(std::cout);
- test_speed(std::cout);
+ //test_speed(std::cout);
         test_speed_csv(std::cout);
 // check_static_list_of_auto_size();
 

Modified: sandbox/statistics/detail/assign/libs/assign/test/speed_csv.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/speed_csv.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/test/speed_csv.cpp 2010-02-28 14:43:12 EST (Sun, 28 Feb 2010)
@@ -42,12 +42,12 @@
             timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(v[0]));
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(v[0]));
                 int sz = (int)rng.size();
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;
@@ -68,12 +68,12 @@
                          timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(v[0],v[1],v[2]));
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(v[0],v[1],v[2]));
                 int sz = (int)rng.size();
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;
@@ -95,12 +95,12 @@
                          timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]));
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]));
                 int sz = (int)rng.size();
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;
@@ -122,14 +122,14 @@
                          timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]
                            ,v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18],v[19]
                            ,v[20],v[21],v[22],v[23],v[24],v[25],v[26],v[27],v[28],v[29]));
                 int sz = (int)rng.size();
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;
@@ -153,7 +153,7 @@
             timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(
                                         v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9]
                            ,v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18],v[19]
                            ,v[20],v[21],v[22],v[23],v[24],v[25],v[26],v[27],v[28],v[29]
@@ -166,7 +166,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;
@@ -195,7 +195,7 @@
                          timer_ timer;
             for(int i = 0; i < n; ++i)
             {
- BOOST_AUTO(rng, boost::assign::cref_list_of(
+ BOOST_AUTO(rng, boost::assign::cref_list_of_csv(
                                         v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9]
                            ,v[10],v[11],v[12],v[13],v[14],v[15],v[16],v[17],v[18],v[19]
                            ,v[20],v[21],v[22],v[23],v[24],v[25],v[26],v[27],v[28],v[29]
@@ -216,7 +216,7 @@
                 if(sz != N)
                     os << "ERROR\n";
             }
- os << "cref_list_of(" << N << ") => ";
+ os << "cref_list_of_csv(" << N << ") => ";
         }
         {
                          timer_ timer;


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