$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r59609 - in sandbox/statistics/detail/assign: boost/assign boost/assign/detail libs/assign/example
From: erwann.rogard_at_[hidden]
Date: 2010-02-09 20:11:51
Author: e_r
Date: 2010-02-09 20:11:50 EST (Tue, 09 Feb 2010)
New Revision: 59609
URL: http://svn.boost.org/trac/boost/changeset/59609
Log:
m
Text files modified: 
   sandbox/statistics/detail/assign/boost/assign/cref_list_of2.hpp        |    41 ++++++++++++++++++++++++++++----------- 
   sandbox/statistics/detail/assign/boost/assign/detail/assign_value.hpp  |     5 ++++                                    
   sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp |    10 ++++----                                
   3 files changed, 39 insertions(+), 17 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-09 20:11:50 EST (Tue, 09 Feb 2010)
@@ -30,12 +30,21 @@
     // 	std::vector<T> vec = cref_list_of(a)(b)(c);
     // Usage 2: 
     // 	boost::fill( ref_list_of(a)(b)(c) , 0); 
-	//
-    // For rebind semantics use ref_rebind_list_of(a)(b)(c)
+    // Usage 3:
+    // BOOST_AUTO(tmp,ref_rebind_list_of(a)(b)(c)); boost::fill(tmp,d);
         //    
     // Acknowledgement: The idea of this class was developed in collaboration 
     // with M.P.G
-
+    //
+    // Revision history:
+    // Feb 9, 2010 : 
+    // - Added copy semantics.
+    // - temporary array in conversion operator is now assigned by call to 
+    // begin() and end() rather than write_to_array() to ensure consistency of 
+    // side effect when assigning with rebind semantics. The loss of performan-
+    // ce is neligible in the test.
+    // Feb 5, 2010 : First version. rebind semantics.
+    
 namespace cref_list_of_impl{
             
         typedef boost::mpl::void_ top_;
@@ -89,18 +98,22 @@
                 
         template<typename T1>
         operator boost::array<T1,N>(){
-            typedef boost::array<T1,N> ar_;
-            ar_ ar;
-            write_to_array(ar,*this);
+        	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()
         {
-            ref_array_ ref_array;
-            write_to_array(ref_array,*this);
-            return C(boost::begin(ref_array),boost::end(ref_array));
+            return C(
+            	boost::begin(this->ref_array()),
+                boost::end(this->ref_array())
+            );
         }
                 
         // -------- as container ---- //
@@ -115,13 +128,12 @@
                 
         iterator begin()
         {
-            this->alloc_if();
-            return boost::begin(*this->ptr);
+            return boost::begin(this->ref_array());
         }
         iterator end() 
         {
             this->alloc_if();
-            return boost::end(*this->ptr);
+            return boost::end(this->ref_array());
         }
         size_type size() const
         {
@@ -143,6 +155,11 @@
                 return this->alloc();
             }
         }
+
+		ref_array_& ref_array(){ 
+        	this->alloc_if();
+            return (*this->ptr);
+        }
                 
         typedef boost::shared_ptr<ref_array_> smart_ptr_;
         smart_ptr_ ptr;
Modified: sandbox/statistics/detail/assign/boost/assign/detail/assign_value.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/detail/assign_value.hpp	(original)
+++ sandbox/statistics/detail/assign/boost/assign/detail/assign_value.hpp	2010-02-09 20:11:50 EST (Tue, 09 Feb 2010)
@@ -36,6 +36,11 @@
             return *ref_;
         }
 
+		//template<typename T1>
+		//operator T1()const{
+        //	return *ref_;
+        //}
+
         void swap( assign_value& r )
         {
             std::swap( *ref_, *r.ref_ );
Modified: sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp	(original)
+++ sandbox/statistics/detail/assign/libs/assign/example/cref_list_of2.cpp	2010-02-09 20:11:50 EST (Tue, 09 Feb 2010)
@@ -68,7 +68,7 @@
                 BOOST_ASSERT(ints[1] == b);    
                 BOOST_ASSERT(ints[2] == c);    
         array = array0;
-		array = ref_list_of(a)(b)(c);
+		array = cref_list_of(a)(b)(c);
                 BOOST_ASSERT(array[0] == a);    
                 BOOST_ASSERT(array[1] == b);    
                 BOOST_ASSERT(array[2] == c);    
@@ -114,11 +114,11 @@
                                 BOOST_ASSERT(ints[2] == d);    
             }
             {
-            	// TODO : resolve inconsistency here
+            	// Before rev. Feb 8, 2010,  there was an inconsistency here
                         ints = tmp;
-				BOOST_ASSERT(ints[0] == a);    
-				BOOST_ASSERT(ints[1] == b);    
-				BOOST_ASSERT(ints[2] == c);    
+				BOOST_ASSERT(ints[0] == d);    
+				BOOST_ASSERT(ints[1] == d);    
+				BOOST_ASSERT(ints[2] == d);    
             }
         }