$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r59969 - in sandbox/statistics/detail/assign: boost/assign/auto_size boost/assign/auto_size/detail libs/assign/doc libs/assign/src libs/assign/test
From: erwann.rogard_at_[hidden]
Date: 2010-02-27 20:58:35
Author: e_r
Date: 2010-02-27 20:58:34 EST (Sat, 27 Feb 2010)
New Revision: 59969
URL: http://svn.boost.org/trac/boost/changeset/59969
Log:
m
Text files modified: 
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp   |    11 ++++---                                 
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/csv.hpp         |    54 ++++++++++++++++++++++++++++++++++----- 
   sandbox/statistics/detail/assign/boost/assign/auto_size/ref_list_of.hpp        |     8 +++--                                   
   sandbox/statistics/detail/assign/boost/assign/auto_size/ref_rebind_list_of.hpp |     7 ++++                                    
   sandbox/statistics/detail/assign/libs/assign/doc/cref_list_of2_speed.txt       |    14 +++++-----                              
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp                      |     4 ++                                      
   sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.cpp      |    29 ++------------------                    
   sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.h        |     4 +-                                      
   8 files changed, 80 insertions(+), 51 deletions(-)
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-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -26,22 +26,23 @@
 // convertible to a range constructible from a pair of iterators.
 //
 // 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
-// parameter. In most situations, a reference wrapper that has copy rather than 
+// arguments at compile time, factors the reference wrapper into a template.
+// In most situations, a reference wrapper that has copy rather than 
 // rebind semantics for operator= is preferable.
 //    
 // Acknowledgement: The idea of this class was developed in collaboration 
 // with M.P.G
 //
 // Revision history:
-// Feb 25, 2010 : Completed the boost::array interface
+// Feb 27, 2010 : support for comma separated arguments (csv.hpp)
+// Feb 25, 2010 : Complemented the boost::array interface
 // Feb 21, 2010 : Made member variables mutable and added constness to member 
 // functions where appropriate.
 // Feb 9, 2010 : 
 // 	- Added a template parameter for the reference_wrapper
 // 	- The temporary array in the conversion operator is now assigned by calling 
 // 	begin() and end() rather than write_to_array() to ensure consistency of 
-//  side effect. Negligible loss in	performance
+//  side effect. 
 // Feb 5, 2010 : First version. rebind semantics.
 
 namespace boost{
@@ -181,7 +182,7 @@
             );
         }
 
-		// This needs to be exposed for csv.
+		// Needed by csv.hpp
         const D& allocated()const{
                         this->alloc_if();
             return static_cast<const D&>(*this);
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-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -9,31 +9,71 @@
 #ifndef BOOST_ASSIGN_DETAIL_AUTO_SIZE_DETAIL_CSV_ER_2010_HPP
 #define BOOST_ASSIGN_DETAIL_AUTO_SIZE_DETAIL_CSV_ER_2010_HPP
 #include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/arithmetic/add.hpp>
 #include <boost/preprocessor/repetition/enum.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/assign/auto_size/detail/auto_size.hpp>
 
-// Warning : currently buggy
+// Let n = BOOST_ASSIGN_CSV_SIZE and a1,...,an objects of type T and 
+// Ref an alias for 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
+
+#ifndef BOOST_ASSIGN_CSV_SIZE
+#define BOOST_ASSIGN_CSV_SIZE 20
+#endif
+
+#ifndef BOOST_ASSIGN_CSV_ref
+#error
+#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_ITER(fun,N)										\
+
+
+#define BOOST_ASSIGN_CSV_ITER_UNQUAL(F,T,U,N)								\
 namespace boost{															\
 namespace assign{															\
         template<typename T>													\
-   	typename assign::detail::auto_size::result_of_copy<const T,N>::type		\
-	fun(BOOST_PP_ENUM_PARAMS(N, const T& _)){								\
-        return (boost::assign::fun 											\
-        	BOOST_PP_REPEAT(N,BOOST_ASSIGN_CSV_ARG,_)).allocated(); 		\
+   	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(); 														\
     }																		\
 }																			\
 }																			\
 /**/
 
+#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)			\
+/**/
+
+// overloads begin at n = 2
+#define BOOST_ASSIGN_CSV_SHIFTED_ITER(z,n,F) 								\
+	BOOST_ASSIGN_CSV_ITER(F,BOOST_PP_ADD(n,2))								\
+/**/
 
-// TODO BOOST_PP_REPEAT and parameterize for const-qual/Ref
+#define BOOST_ASSIGN_CSV_REPEAT(fun,N) 										\
+	BOOST_PP_REPEAT(BOOST_PP_DEC(N),BOOST_ASSIGN_CSV_SHIFTED_ITER,fun)		\
+/**/
+
+#define BOOST_ASSIGN_CSV(fun) 												\
+	BOOST_ASSIGN_CSV_REPEAT(fun,BOOST_ASSIGN_CSV_SIZE)						\
+/**/
 
 #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-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -8,9 +8,8 @@
 //////////////////////////////////////////////////////////////////////////////
 #ifndef BOOST_ASSIGN_AUTO_SIZE_REF_LIST_OF_ER_2010_HPP
 #define BOOST_ASSIGN_AUTO_SIZE_REF_LIST_OF_ER_2010_HPP
-#include <boost/typeof/typeof.hpp> // templatetmp.
+#include <boost/typeof/typeof.hpp> // tmp.
 #include <boost/assign/auto_size/detail/auto_size.hpp>
-#include <boost/assign/auto_size/detail/csv.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
@@ -36,6 +35,9 @@
 }// assign
 }// boost
 
-BOOST_ASSIGN_CSV_ITER(cref_list_of,3)
+#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)
+#undef BOOST_ASSIGN_CSV_ref
 
 #endif
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-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -13,7 +13,7 @@
 // Creates a collection of references exposing the boost::array interface and 
 // convertible to a range that is constructible from a pair of iterators. Rebind
 // semantics apply if the collection is the lhs of an assignment:
-// 	cref_rebind_list_of(a)(b)(c).assign(d)
+// 	cref_rebind_list_of(a,b,c).assign(d)
 // Unless this specific feature is needed, ref_list_of() is preferable.
 // Note that this function supersedes ref_list_of<int>().
 
@@ -35,4 +35,9 @@
 }// assign
 }// boost
 
+#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)
+#undef BOOST_ASSIGN_CSV_ref
+
 #endif
Modified: sandbox/statistics/detail/assign/libs/assign/doc/cref_list_of2_speed.txt
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/doc/cref_list_of2_speed.txt	(original)
+++ sandbox/statistics/detail/assign/libs/assign/doc/cref_list_of2_speed.txt	2010-02-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -5,22 +5,22 @@
 
 cref_list_of<>(1) => 0.01 s
 
-cref_list_of(3) => 0.03 s
+cref_list_of(3) => 0.04 s
 
 cref_list_of<>(3) => 0.01 s
 
-cref_list_of(10) => 0.09 s
+cref_list_of(10) => 0.15 s
 
 cref_list_of<>(10) => 0.05 s
 
-cref_list_of(30) => 0.30 s
+cref_list_of(30) => 0.45 s
 
 cref_list_of<>(30) => 0.22 s
 
-cref_list_of(80) => 0.87 s
+cref_list_of(80) => 1.52 s
 
-cref_list_of<>(80) => 0.49 s
+cref_list_of<>(80) => 0.50 s
 
-cref_list_of(160) => 2.05 s
+cref_list_of(160) => 5.30 s
 
-cref_list_of<>(160) => 0.97 s
\ No newline at end of file
+cref_list_of<>(160) => 0.98 s
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-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -1,12 +1,14 @@
 #include <iostream>
 #include <libs/assign/example/cref_list_of2.h>
 #include <libs/assign/test/cref_list_of2_speed.h>
+#include <libs/assign/test/speed_csv.h>
 //#include <libs/assign/test/static_list_of_auto_size.h>
 
 int main (int argc, char * const argv[]) {
 
         example_cref_list_of(std::cout);
-//	test_cref_copy_list_of_speed(std::cout);
+	test_speed(std::cout);
+	test_speed_csv(std::cout);
 //	check_static_list_of_auto_size();
 
         return 0;
Modified: sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.cpp	(original)
+++ sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.cpp	2010-02-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -1,43 +1,22 @@
 //////////////////////////////////////////////////////////////////////////////
-// test::cref_copy_list_of_speed.cpp                                        //
+// test::speed.cpp                                        					//
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 #include <iostream>
 #include <vector>
 #include <string>
-#include <algorithm>
 #include <boost/progress.hpp>
 #include <boost/bind.hpp>
 #include <boost/typeof/typeof.hpp>
 #include <boost/assign/auto_size/ref_list_of.hpp>
+#include <libs/assign/test/speed_common.h>
 #include <libs/assign/test/cref_list_of2_speed.h>
 
 // This file was provided by M.P.G 
 
-// http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx
-inline double uniform_deviate ( int seed )
+void test_speed(std::ostream& os)
 {
-    return seed * ( 1.0 / ( RAND_MAX + 1.0 ) );
-}
-inline int rand(int M, int N) // Range [M..N)
-{   
-    return int(M + uniform_deviate(std::rand()) * (N - M));
-}
-char rand_letter()
-{
-    return char(rand('a', 'z' + 1));
-}
-
-std::string rand_str(int len)
-{
-    std::string result;
-    std::generate_n(std::back_inserter(result), len, &rand_letter);
-    return result;
-}
-
-void test_cref_copy_list_of_speed(std::ostream& os)
-{
-	os << "-> test_cref_listof2_speed : " << std::endl;
+	os << "-> test_speed : " << std::endl;
 
         typedef boost::progress_timer timer_;
     
Modified: sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.h
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.h	(original)
+++ sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.h	2010-02-27 20:58:34 EST (Sat, 27 Feb 2010)
@@ -1,11 +1,11 @@
 //////////////////////////////////////////////////////////////////////////////
-// test::cref_copy_list_of_speed.h                                          //
+// test::speed.h                                                            //
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 #ifndef LIBS_ASSIGN_TEST_CREF_COPY_LIST_OF_SPEED_ER_2010_H
 #define LIBS_ASSIGN_TEST_CREF_COPY_LIST_OF_SPEED_ER_2010_H
 #include <ostream>
 
-void test_cref_copy_list_of_speed(std::ostream&);
+void test_speed(std::ostream&);
 
 #endif