Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59796 - in sandbox/statistics/detail/assign: boost/assign/auto_size/detail libs/assign/src libs/assign/test
From: erwann.rogard_at_[hidden]
Date: 2010-02-20 19:01:12


Author: e_r
Date: 2010-02-20 19:01:11 EST (Sat, 20 Feb 2010)
New Revision: 59796
URL: http://svn.boost.org/trac/boost/changeset/59796

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/auto_size.hpp | 50 ++++++++++++++++++++++++++-------------
   sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 8 ++++--
   sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.cpp | 2
   sandbox/statistics/detail/assign/libs/assign/test/cref_list_of2_speed.h | 8 +++---
   4 files changed, 43 insertions(+), 25 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-20 19:01:11 EST (Sat, 20 Feb 2010)
@@ -68,7 +68,7 @@
         typedef expr<E,T,N,Ref> expr_;
         typedef expr<expr_,T,N+1,Ref> type;
     };
-
+
     template<typename E,typename T,int N,template<typename> class Ref>
     class expr{
         typedef boost::mpl::int_<N> int_n_;
@@ -81,8 +81,8 @@
         typedef typename ref_array<T,N,Ref>::type ref_array_;
         typedef typename next<E,T,N,Ref>::type next_;
 
- previous_ previous;
- ref_ ref;
+ mutable previous_ previous;
+ mutable ref_ ref;
                                 
         expr(T& t):ref(t){} // only for N == 1
         expr(E& p,T& t):previous(p),ref(t){}
@@ -91,7 +91,7 @@
         next_ operator()(T& t){ return next_(*this,t); }
                 
         template<typename T1>
- operator boost::array<T1,N>(){
+ operator boost::array<T1,N>()const{
                 boost::array<T1,N> ar;
                         std::copy(
                     boost::begin(this->ref_array()),
@@ -102,7 +102,7 @@
         }
                 
         template<typename C>
- operator C()
+ operator C()const
         {
             return C(
                     boost::begin(this->ref_array()),
@@ -129,6 +129,17 @@
             this->alloc_if();
             return boost::end(this->ref_array());
         }
+
+ const_iterator begin()const
+ {
+ return boost::begin(this->ref_array());
+ }
+ const_iterator end()const
+ {
+ this->alloc_if();
+ return boost::end(this->ref_array());
+ }
+
         size_type size() const
         {
             return ref_array_::size();
@@ -139,27 +150,32 @@
         }
                 
         private:
- void alloc(){
+
+ void alloc()const{
             this->ptr = smart_ptr_(new ref_array_);
             write_to_array(*this->ptr,*this);
         }
                 
- void alloc_if(){
+ void alloc_if()const{
             if(!this->ptr){
                 return this->alloc();
             }
         }
 
- ref_array_& ref_array(){
- this->alloc_if();
+ const ref_array_& ref_array()const{
+ this->alloc_if();
             return (*this->ptr);
         }
-
+ ref_array_& ref_array(){
+ this->alloc_if();
+ return (*this->ptr);
+ }
+
         typedef boost::shared_ptr<ref_array_> smart_ptr_;
- // Only the last of N expressions needs to instantiate an array, hence a
- // pointer.
- smart_ptr_ ptr;
-
+ // Only the last of N expressions needs to instantiate an array,
+ // hence a pointer.
+ mutable smart_ptr_ ptr;
+
     };
             
     typedef boost::mpl::bool_<false> false_;
@@ -167,7 +183,7 @@
             
     template<typename A,typename E,typename T,int N,
             template<typename> class Ref>
- void write_to_array(A& a,expr<E,T,N,Ref>& e){
+ void write_to_array(A& a,const expr<E,T,N,Ref>& e){
         typedef expr<E,T,N,Ref> expr_;
         typedef typename expr_::is_first_ exit_;
         write_to_array(a,e,exit_());
@@ -175,14 +191,14 @@
             
     template<typename A,typename E,typename T,int N,
             template<typename> class Ref>
- void write_to_array(A& a,expr<E,T,N,Ref>& e,false_ /*exit*/){
+ void write_to_array(A& a,const expr<E,T,N,Ref>& 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,expr<E,T,N,Ref>& e,true_ /*exit*/){
+ void write_to_array(A& a,const expr<E,T,N,Ref>& e,true_ /*exit*/){
         a[N-1] = e.ref;
     }
             

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-20 19:01:11 EST (Sat, 20 Feb 2010)
@@ -1,11 +1,13 @@
 #include <iostream>
 #include <libs/assign/example/cref_list_of2.h>
 #include <libs/assign/test/cref_list_of2_speed.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_list_of_speed(std::cout);
-
- return 0;
+ test_cref_copy_list_of_speed(std::cout);
+
+ 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-20 19:01:11 EST (Sat, 20 Feb 2010)
@@ -1,5 +1,5 @@
 //////////////////////////////////////////////////////////////////////////////
-// test::cref_copy_list_of_speed.cpp //
+// test::cref_copy_list_of_speed.cpp //
 // //
 //////////////////////////////////////////////////////////////////////////////
 #include <iostream>

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-20 19:01:11 EST (Sat, 20 Feb 2010)
@@ -1,11 +1,11 @@
 //////////////////////////////////////////////////////////////////////////////
-// test::cref_list_of_speed.h //
+// test::cref_copy_list_of_speed.h //
 // //
 //////////////////////////////////////////////////////////////////////////////
-#ifndef LIBS_ASSIGN_TEST_CREF_LIST_OF2_SPEED_ER_2010_H
-#define LIBS_ASSIGN_TEST_CREF_LIST_OF2_SPEED_ER_2010_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_list_of_speed(std::ostream&);
+void test_cref_copy_list_of_speed(std::ostream&);
 
 #endif


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