|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60211 - in sandbox/statistics/detail/assign: boost/assign/auto_size/detail libs/assign/example
From: erwann.rogard_at_[hidden]
Date: 2010-03-05 15:47:24
Author: e_r
Date: 2010-03-05 15:47:23 EST (Fri, 05 Mar 2010)
New Revision: 60211
URL: http://svn.boost.org/trac/boost/changeset/60211
Log:
m
Text files modified:
sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp | 48 +++++++++++++++-------------------------
sandbox/statistics/detail/assign/libs/assign/example/ref_list_of.cpp | 7 ++++-
2 files changed, 23 insertions(+), 32 deletions(-)
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 15:47:23 EST (Fri, 05 Mar 2010)
@@ -34,8 +34,7 @@
// Note:
// - In most situations, a reference wrapper that has copy rather than rebind
// semantics for operator= is preferable.
-// - The older counterpart to this class is assign::static_generic_list<>. Any
-// difference between the two interfaces is marked by (!= static_generic_list<>)
+// - The older counterpart to this class is assign::static_generic_list<>.
//
// Acknowledgement: The idea of this class was developed in collaboration
// with M.P.G
@@ -51,6 +50,15 @@
typename E,typename T,int N,template<typename> class Ref,typename P>
class expr;
+ // ---- describe ---- //
+
+ void describe(std::ostream& os,const top_& e){}
+ 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;
+ }
+
// ---- Traits --- //
template<typename E,typename T,int N,template<typename>class Ref,typename P>
@@ -108,19 +116,11 @@
mutable previous_ previous;
mutable ref_ ref;
- // TODO range(ForwardIterator,ForwarIterator)
- // Problem : internally calls range<K>(first). but K must be known
- // at compile time. Maybe some type erasure.
// private: // temporarily commented out
- template<int K, class ForwardIterator >
- typename result_of::expr<T,N+K,Ref,P>::type
- range( ForwardIterator first)const
- {
- return this->next_impl<K>(first);
- }
-
+ typedef boost::shared_ptr<result_type> shared_;
+
template<int K,typename ForwardIterator>
typename result_of::expr<T,N+K,Ref,P>::type
next_impl(ForwardIterator first)const{
@@ -128,36 +128,24 @@
return this->next_impl(k_(),first);
}
- // TODO BUG K>1 runtime error
template<int K,typename ForwardIterator>
typename result_of::expr<T,N+K,Ref,P>::type
next_impl(boost::mpl::int_<K>,ForwardIterator first)const{
- // I thought the shared_ptr would solve the runtime error but not
- typedef boost::shared_ptr<result_type> shared_;
- shared_ shared = shared_(new result_type(*this,*first));
- return (*shared).next_impl<K-1>(boost::next(first));
+ result_type res = (*this)(*first);
+ describe(std::cout,res); // debugging only : fine
+ std::cout << std::endl; // debugging only : fine
+ typedef boost::mpl::int_<K-1> k_;
+ return res.next_impl(k_(),boost::next(first));
}
template<typename ForwardIterator>
- const expr&
+ const expr&
next_impl(boost::mpl::int_<0>,ForwardIterator end)const{
return (*this);
}
};
- // ---- description ---- //
-
- template<typename E,typename T,template<typename> class Ref,typename P>
- void describe(std::ostream& os,const expr<E,T,1,Ref,P>& e){
- os << e.ref;
- }
- 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;
- }
-
// ---- write_to_array ---- //
// Nshift is provided in case some library extension may need it
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 15:47:23 EST (Fri, 05 Mar 2010)
@@ -47,10 +47,13 @@
// BUG for K > 1
BOOST_AUTO(tmp,cref_list_of(a)(b)(3)
- .range<2>(boost::begin(ints))
+ .next_impl<3>(boost::begin(ints))
);
- describe(os,tmp);
+ BOOST_ASSERT(tmp[0] == a);
+ BOOST_ASSERT(tmp[1] == b);
+ BOOST_ASSERT(tmp[2] == c);
+// describe(os,tmp);
}
/*
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