Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60221 - in sandbox/statistics/detail/assign: boost/assign/auto_size/array boost/assign/auto_size/detail libs/assign/example
From: erwann.rogard_at_[hidden]
Date: 2010-03-05 20:25:52


Author: e_r
Date: 2010-03-05 20:25:51 EST (Fri, 05 Mar 2010)
New Revision: 60221
URL: http://svn.boost.org/trac/boost/changeset/60221

Log:
m
Text files modified:
   sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp | 2 +
   sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp | 76 ++++++++++++++++++++++++---------------
   sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp | 38 ++++++++++++-------
   3 files changed, 72 insertions(+), 44 deletions(-)

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp 2010-03-05 20:25:51 EST (Fri, 05 Mar 2010)
@@ -45,6 +45,8 @@
         typedef typename boost::range_difference<
             ref_array_>::type difference_type;
                 
+ BOOST_STATIC_CONSTANT(int, static_size = N);
+
         iterator begin()
         {
             return boost::begin(this->ref_array());

Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp 2010-03-05 20:25:51 EST (Fri, 05 Mar 2010)
@@ -53,7 +53,8 @@
         // ---- describe ---- //
     
         void describe(std::ostream& os,const top_& e){}
- template<typename E,typename T,int N,template<typename> class Ref,typename P>
+ template<
+ typename E,typename T,int N,template<typename> class Ref,typename P>
         void describe(std::ostream& os,const expr<E,T,N,Ref,P>& e){
             describe(os,e.previous);
             os << ',' << e.ref;
@@ -78,6 +79,43 @@
 
     }
 
+ // ---- next ---- //
+
+ // BUG K>1
+ template<int K,typename E,typename T,int N,
+ template<typename>class Ref,typename P,typename ForwardIterator>
+ typename result_of::expr<T,N+K,Ref,P>::type
+ next_impl(const expr<E,T,N,Ref,P>& e, ForwardIterator first)
+ {
+ typedef boost::mpl::int_<K> k_;
+ return next_impl(k_(),e,first);
+ }
+
+ template<int K,typename E,typename T,int N,
+ template<typename>class Ref,typename P,typename ForwardIterator>
+ typename result_of::expr<T,N+K,Ref,P>::type
+ next_impl(boost::mpl::int_<K>,const expr<E,T,N,Ref,P>& e,
+ ForwardIterator first)
+ {
+ typedef typename result_of::expr<T,N+1,Ref,P>::type next_;
+ next_ n = e(*first);
+ typedef boost::mpl::int_<K-1> k_;
+ return next_impl(k_(),n,boost::next(first));
+ }
+
+ template<typename E,typename T,int N,
+ template<typename>class Ref,typename P,typename ForwardIterator>
+ const typename result_of::expr<T,N,Ref,P>::type&
+ next_impl(boost::mpl::int_<0>,const expr<E,T,N,Ref,P>& e,
+ ForwardIterator first)
+ {
+ std::cout << "debugging only : ";
+ describe(std::cout,e);
+ std::cout << std::endl;
+ return e;
+ }
+
+
     // ---- Collection builder ---- //
 
     template<
@@ -99,7 +137,7 @@
         typedef typename boost::mpl::if_<is_1st_,E,const E&>::type previous_;
         typedef typename next<expr>::type result_type;
 
- // expr( T& r ); // (!= static_generic_list<>)
+ // expr( T& r );
 
         expr(const E& p,T& t):previous(p),ref(t){}
         // Needed by csv.hpp :
@@ -113,7 +151,6 @@
 
         // TODO csv here.
 
-
 // template<typename K,typename ForwardIterator>
 // typename result_of::expr<T,N+K,Ref,P>::type
 // range(ForwardIterator b,ForwardIterator e){
@@ -122,37 +159,16 @@
 // }
 
 // template<typename Range>
-// range(const Range& r)
+// range(const Range& r) // enable if static_size only
+//
+// template<int K,typename Range>
+// range(const Range& r) // valid for dynamic size
 
         mutable previous_ previous;
         mutable ref_ ref;
 
- // private: // temporarily commented out
-
- // BUG K>1
- template<int K,typename ForwardIterator>
- typename result_of::expr<T,N+K,Ref,P>::type
- next_impl(ForwardIterator first)const{
- typedef boost::mpl::int_<K> k_;
- return this->next_impl(k_(),first);
- }
-
- template<int K,typename ForwardIterator>
- typename result_of::expr<T,N+K,Ref,P>::type
- next_impl(boost::mpl::int_<K>,ForwardIterator first)const{
- result_type res = (*this)(*first);
- typedef boost::mpl::int_<K-1> k_;
- return res.next_impl(k_(),boost::next(first));
- }
-
- template<typename ForwardIterator>
- const expr&
- next_impl(boost::mpl::int_<0>,ForwardIterator end)const{
- std::cout << "debugging only : ";
- describe(std::cout,*this);
- std::cout << std::endl;
- return (*this);
- }
+ private:
+ expr();
 
     };
 

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-03-05 20:25:51 EST (Fri, 05 Mar 2010)
@@ -10,6 +10,7 @@
 #include <vector>
 #include <algorithm>
 #include <boost/typeof/typeof.hpp>
+#include <boost/assign/auto_size/detail/has_static_size.hpp> // temporary
 #include <boost/assign/auto_size/ref_list_of.hpp> // temporary
 #include <boost/assign/auto_size/ref_list_of_csv.hpp>
 #include <boost/assign/auto_size/ref_rebind_list_of_csv.hpp>
@@ -22,7 +23,7 @@
 {
     os << "-> example_ref_listof : ";
     using namespace boost::assign;
-
+ using namespace boost::assign::detail::auto_size;
     typedef std::vector<int> ints_;
     typedef boost::array<int,3> array_;
     array_ array;
@@ -35,7 +36,28 @@
         // cref_list_of_csv
 
             int a=1, b=2, c=3;
-
+
+ {
+ // debugging cref_list_of().range()
+ // BUG for K > 1
+ ints_ ints(3);
+ ints[0] = a; ints[1] = b; ints[2] = c;
+ typedef tag::no_policy tag;
+ typedef boost::mpl::int_<3> K_;
+ BOOST_AUTO(tmp,
+ next_impl<K_::value>(
+ cref_list_of<tag>(a)(b)(3)
+ ,boost::begin(ints)
+ )
+ );
+ describe(os,tmp);
+
+ //BOOST_ASSERT(tmp[0] == a);
+ //BOOST_ASSERT(tmp[1] == b);
+ //BOOST_ASSERT(tmp[2] == c);
+
+ }
+/*
         {
                     ints.clear();
 
@@ -44,20 +66,8 @@
             BOOST_ASSERT(ints[0] == a);
             BOOST_ASSERT(ints[1] == b);
             BOOST_ASSERT(ints[2] == c);
-
- // BUG for K > 1
- typedef boost::mpl::int_<3> K_;
- BOOST_AUTO(tmp,cref_list_of(a)(b)(3)
- .next_impl<K_::value>(boost::begin(ints))
- );
-
- BOOST_ASSERT(tmp[0] == a);
- BOOST_ASSERT(tmp[1] == b);
- BOOST_ASSERT(tmp[2] == c);
-// describe(os,tmp);
             
         }
-/*
         {
             array.assign(-1);
             array = cref_list_of_csv(a,b,3);


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