|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60798 - in sandbox/statistics/detail/assign: boost/assign boost/assign/auto_size/array boost/assign/auto_size/check boost/assign/auto_size/range libs/assign/example libs/assign/src
From: erwann.rogard_at_[hidden]
Date: 2010-03-24 00:22:52
Author: e_r
Date: 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
New Revision: 60798
URL: http://svn.boost.org/trac/boost/changeset/60798
Log:
m
Text files modified:
sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp | 18 +---
sandbox/statistics/detail/assign/boost/assign/auto_size/check/all.hpp | 4
sandbox/statistics/detail/assign/boost/assign/auto_size/check/chain.hpp | 1
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp | 140 ++++++++++++++++++++-----------------
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_l.hpp | 148 +++++++++++++++++++++++++--------------
sandbox/statistics/detail/assign/boost/assign/chain_convert.hpp | 2
sandbox/statistics/detail/assign/libs/assign/example/range.cpp | 8 +
sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 1
8 files changed, 186 insertions(+), 136 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-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -13,11 +13,11 @@
#include <boost/mpl/int.hpp>
#include <boost/array.hpp>
#include <boost/range.hpp>
-#include <boost/assign/list_of.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <boost/assign/list_of.hpp> // converter<>
#include <boost/assign/auto_size/comparison_op/range.hpp>
-#include <boost/assign/auto_size/reference_wrapper/has_copy_semantics.hpp>
+#include <boost/assign/auto_size/reference_wrapper/has_copy_semantics.hpp> //needed?
#include <boost/assign/auto_size/array/ref.hpp>
-//#include <boost/assign/auto_size/array/converter.hpp>
namespace boost{
namespace assign{
@@ -67,6 +67,7 @@
typedef array_interface_traits<T,N,R> traits;
typedef typename traits::ref_ ref_;
typedef typename traits::ref_array_ ref_array_;
+ typedef array_interface<T,N,R,D> this_;
public:
typedef ref_ value_type;
@@ -109,15 +110,8 @@
// converter
protected:
- typedef assign_detail::converter<
- array_interface<T,N,R,D>,
- typename array_interface_traits<T,N,R>::const_iterator
- > converter_;
-
- friend class assign_detail::converter<
- array_interface<T,N,R,D>,
- typename array_interface_traits<T,N,R>::const_iterator
- >;
+ typedef assign_detail::converter<this_,const_iterator> converter_;
+ friend class assign_detail::converter<this_,const_iterator>;
public:
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/check/all.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/check/all.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/check/all.hpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -20,7 +20,7 @@
#include <boost/assign/auto_size/check/array.hpp>
//#include <boost/assign/auto_size/check/chain.hpp>
-//#include <boost/assign/auto_size/check/comparison_op.hpp>
+#include <boost/assign/auto_size/check/comparison_op.hpp>
#include <boost/assign/auto_size/check/converter.hpp>
#include <boost/assign/auto_size/check/copy_array.hpp>
#include <boost/assign/auto_size/check/copy_iterator.hpp>
@@ -52,6 +52,7 @@
BOOST_ASSIGN_AS_CHECK_converter_sorted(std::set<T>) \
BOOST_ASSIGN_AS_CHECK_adapter_lifo(std::stack<T>) \
BOOST_ASSIGN_AS_CHECK_adapter_fifo(std::queue<T>) \
+ BOOST_ASSIGN_AS_CHECK_comparison_op \
} \
void BOOST_PP_CAT(fun,_int)(){ fun<int>(); } \
} \
@@ -61,7 +62,6 @@
/**/
/*
- BOOST_ASSIGN_AS_CHECK_comparison_op \
BOOST_ASSIGN_AS_CHECK_chain \
BOOST_ASSIGN_AS_CHECK_example2 \
*/
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/check/chain.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/check/chain.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/check/chain.hpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -11,6 +11,7 @@
#include <boost/array.hpp>
#include <boost/typeof/typeof.hpp>
#include <boost/range/algorithm/copy.hpp>
+#include <boost/assign/auto_size/range/chain_r.hpp>
#include <boost/assign/auto_size/range/chain_convert_l.hpp>
#include <boost/assign/auto_size/check/iterator.hpp>
#include <boost/assign/auto_size/check/constants.hpp>
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -13,14 +13,16 @@
#include <boost/mpl/if.hpp>
#include <boost/mpl/void.hpp>
#include <boost/type_traits/is_same.hpp>
-#include <boost/range.hpp>
#include <boost/range/chain.hpp>
#include <boost/assign/auto_size/range/convert_range.hpp>
#include <boost/assign/auto_size/traits/reference_traits.hpp>
#include <boost/assign/auto_size/reference_wrapper/conversion_traits.hpp>
#include <boost/assign/auto_size/range/result_of_chain.hpp>
+#include <boost/assign/auto_size/range/hold_previous.hpp>
+#include <boost/assign/auto_size/range/hold_converted_range.hpp>
+#include <boost/assign/auto_size/range/chain_l.hpp>
-// Usage : Let r1, r2 and r3 denote ranges.
+// Usage : Let r1, r2 and r3 denote lvalue-ranges.
// boost::copy( from, boost::begin( chain_convert_l(r1)(r2)(r3) ) );
// This function does not have the restriction of chain_l that none or all
// of r1, r2, r3 must be reference wrappers.
@@ -30,93 +32,98 @@
namespace detail{
namespace chain_convert_l_impl{
- template<typename E,typename Rng1,int N,typename V,typename R> class expr;
+// template<typename E,typename Rng1,bool is_first,typename V,typename R> class expr;
- template<typename E,typename Rng2>
- struct next_expr{
- typedef typename E::conversion_value val_;
- typedef typename E::conversion_reference ref_;
- typedef expr<E,Rng2,E::static_size+1,val_,ref_> type;
- };
+ template<typename L,typename E,typename Rng1,
+ bool is_first,typename V,typename R> class expr;
- template<typename E,typename Rng1,int N,typename V,typename R>
- struct super_of_expr : result_of::chain<
- typename E::super_,
- typename result_of::convert_range<Rng1,V,R>::type
- >{};
+ // This is the implementation of
+ // expr<L,E,Rng1,is_first,V,R> for any valid E
+ template<typename E,typename Rng1,bool is_first,typename V,typename R>
+ struct impl_of_expr
+ {
+ typedef typename
+ detail::result_of::convert_range<Rng1,V,R>::type conv_r1_;
+ typedef typename E::template result_impl<conv_r1_>::type type;
+ };
template<typename E,typename Rng1,typename V,typename R>
- struct super_of_expr<E,Rng1,1,V,R>{
- typedef typename result_of::convert_range<Rng1,V,R>::type type;
+ struct impl_of_expr<E,Rng1,true,V,R>
+ {
+ typedef typename result_of::convert_range<Rng1,V,R>::type conv_r1_;
+ typedef typename chain_impl::first_expr<conv_r1_,false>::type type;
+ };
+
+ template<typename E,typename Rng1,bool is_first,typename V,typename R>
+ struct facade_of_expr
+ {
+ typedef typename impl_of_expr<E,Rng1,is_first,V,R>::type impl_;
+ typedef typename impl_::facade_ type;
+ };
+
+ // This is the result of expr<L,E,...>::operator(Rng2&)
+ template<typename L,typename E,typename Rng2>
+ struct next_expr{
+ typedef typename L::conversion_value val_;
+ typedef typename L::conversion_reference ref_;
+ typedef expr<L,E,Rng2,false,val_,ref_> type;
};
typedef boost::mpl::void_ top_;
-
- template<typename E,typename Rng1,int N,typename V,typename R>
- class expr : public super_of_expr<E,Rng1,N,V,R>::type{
- typedef boost::mpl::int_<1> int_1_;
- typedef boost::mpl::int_<N> int_n_;
- typedef typename boost::mpl::equal_to<int_1_,int_n_>::type is_first_;
- typedef typename boost::mpl::if_<is_first_,E,E&>::type previous_;
- typedef expr<E,Rng1,N,V,R> this_;
- typedef typename
- result_of::convert_range<Rng1,V,R>::type converted_r1_impl_;
+ template<typename L,typename E,typename Rng1,
+ bool is_first,typename V,typename R>
+ class expr :
+ converted_range::list<L,Rng1,is_first,V,R>,
+ public impl_of_expr<E,Rng1,is_first,V,R>::type
+ {
+ typedef expr<L,E,Rng1,is_first,V,R> this_;
public:
- typedef typename super_of_expr<E,Rng1,N,V,R>::type super_;
- typedef typename boost::mpl::if_<
- is_first_,top_,converted_r1_impl_>::type converted_r1_;
-
+ // types
typedef V conversion_value;
typedef R conversion_reference;
+ typedef typename impl_of_expr<E,Rng1,is_first,V,R>::type impl_;
+ // bases
+ typedef converted_range::list<L,Rng1,is_first,V,R> list_;
+ typedef typename facade_of_expr<E,Rng1,is_first,V,R>::type facade_;
+
+ // constructors
+ explicit expr(Rng1& r1)
+ :list_(r1),
+ impl_(this->converted_range)
+ {}
+ explicit expr(L& l,E& e,Rng1& r1)
+ :list_(l,r1),
+ impl_(e,this->converted_range)
+ {}
+
+ // unary operators
template<typename Rng2>
- struct result_impl : next_expr<this_,Rng2>{};
-
- BOOST_STATIC_CONSTANT(int,static_size = N);
-
- super_& super(){ return (*this); }
- const super_& super()const{ return (*this); }
-
- explicit expr(super_ s):super_(s){}
- explicit expr(E& p, Rng1& r1)
- :previous(p),
- converted_r1(convert_range<V,R>(r1))
- {
- // Do not put in the intialization list bec. super may be
- // intialized first whereas last is required.
- this->super() = boost::chain(
- this->previous.super(),
- this->converted_r1
- );
- }
+ struct result_impl
+ : chain_convert_l_impl::next_expr<list_,impl_,Rng2>{};
- template<typename Rng2>
- typename result_impl<Rng2>::type
- operator()(Rng2& r2){
+ template<typename Rng2> // Warning : overrides base.
+ typename result_impl<Rng2>::type
+ operator()(Rng2& r2)
+ {
typedef typename result_impl<Rng2>::type res_;
- return res_( *this, r2 );
+ return res_(
+ static_cast<list_&>(*this),
+ static_cast<impl_&>(*this),
+ r2
+ );
}
-
- mutable previous_ previous;
- mutable converted_r1_ converted_r1;
+
};
-
template<typename Rng1,typename V,
typename R = typename detail::convert_range_reference<Rng1,V>::type>
struct first_expr{
- typedef expr<top_,Rng1,1,V,R> type;
- typedef typename type::super_ super_;
- static type call(Rng1& r1){
- return type(
- super_(
- convert_range<V,R>(r1)
- )
- );
- }
+ typedef expr<top_,top_,Rng1,1,V,R> type;
+ static type call(Rng1& r1){ return type(r1); }
};
template<typename Rng1>
@@ -126,6 +133,7 @@
typedef typename boost::remove_reference<to_>::type type;
};
+
}// chain_convert_l_impl
}// detail
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_l.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_l.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_l.hpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -8,19 +8,21 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_DETAIL_RANGE_CHAIN_L_ER_2010_HPP
#define BOOST_ASSIGN_DETAIL_RANGE_CHAIN_L_ER_2010_HPP
-#include <boost/mpl/int.hpp>
-#include <boost/mpl/equal_to.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/void.hpp>
-#include <boost/range.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/is_const.hpp>
+#include <boost/utility/enable_if.hpp>
#include <boost/range/chain.hpp>
#include <boost/assign/auto_size/range/result_of_chain.hpp>
+#include <boost/assign/auto_size/range/hold_previous.hpp>
// This is based on
// http://gist.github.com/287791
// developed by MPG, but allows lvalues.
-// Usage : Let r1, r2 and r3 denote ranges,
+// Usage : Let r1, r2 and r3 denote lvalue-ranges,
// boost::copy( from, boost::begin( chain_l(r1)(r2)(r3) ) );
// Note: if either of r, r2 or r3 is a range of reference wrappers, then all
// three also have to.
@@ -28,81 +30,121 @@
namespace boost{
namespace assign{
namespace detail{
-namespace chain_l_impl{
+namespace chain_impl{
- template<typename E,typename R1,int N> class expr;
+ template<typename E,typename R1,bool is_first,bool add_const> class expr;
- template<typename E,typename R2>
+ template<typename E,typename R2,bool add_const>
struct next_expr{
- typedef expr<E,R2,E::static_size+1> type;
+ typedef expr<E,R2,false,add_const> type;
};
-
- template<typename E,typename R1,int N>
- struct super_of_expr : detail::result_of::chain<typename E::super_,R1>{};
- template<typename E,typename R1>
- struct super_of_expr<E,R1,1>{
- typedef boost::sub_range<R1> type;
+ template<typename T,bool b>
+ struct sel_const
+ : boost::mpl::if_c<b,typename boost::add_const<T>::type,T>{};
+
+ template<typename E,typename R1,bool is_first,bool add_const>
+ struct facade_of_expr{
+ typedef typename E::facade_ facade_;
+ typedef typename sel_const<facade_,add_const>::type sel_facade_;
+ typedef typename sel_const<R1,add_const>::type sel_r1_;
+ typedef typename result_of::chain<sel_facade_,sel_r1_>::type type;
};
-
- template<typename E,typename R1,int N>
- class expr : public super_of_expr<E,R1,N>::type{
- typedef boost::mpl::int_<1> int_1_;
- typedef boost::mpl::int_<N> int_n_;
- typedef typename boost::mpl::equal_to<int_1_,int_n_>::type is_first_;
- typedef typename boost::mpl::if_<is_first_,E,E&>::type previous_;
- typedef expr<E,R1,N> this_;
+ template<typename E,typename R1,bool add_const>
+ struct facade_of_expr<E,R1,true,add_const>{
+ typedef typename sel_const<R1,add_const>::type sel_r1_;
+ typedef boost::sub_range<sel_r1_> type;
+ };
+
+ template<typename E,bool is_first,bool add_const>
+ struct sel_hold_previous : boost::mpl::if_c<
+ add_const,
+ boost::mpl::empty_base,
+ detail::hold_previous<E,is_first>
+ >{};
+
+ template<typename E,typename R1,bool is_first,bool add_const>
+ class expr :
+ sel_hold_previous<E,is_first,add_const>::type,
+ public chain_impl::facade_of_expr<E,R1,is_first,add_const>::type
+ {
+ protected:
+ typedef expr<E,R1,is_first,add_const> this_;
+
+ typedef typename sel_hold_previous<E,is_first,add_const>::type hold_previous_;
+
+ typedef typename sel_const<E,add_const>::type sel_e_;
+ typedef typename sel_const<R1,add_const>::type sel_r1_;
+
+ template<typename T,bool b> //a dependence on T is needed
+ struct enable : boost::enable_if_c<b>{};
public:
+
+ typedef typename
+ chain_impl::facade_of_expr<E,R1,is_first,add_const>::type facade_;
template<typename R2>
- struct result_impl : next_expr<this_,R2>{};
-
- BOOST_STATIC_CONSTANT(int,static_size = N);
-
- typedef typename super_of_expr<E,R1,N>::type super_;
-
- super_& super(){ return (*this); }
- const super_& super()const{ return (*this); }
-
- explicit expr(super_ s):super_(s){}
- explicit expr(E& p,super_ s):previous(p),super_(s){}
+ struct result_impl : chain_impl::next_expr<this_,R2,add_const>{};
+
+ facade_& facade(){ return (*this); }
+ const facade_& facade()const{ return (*this); }
+
+ explicit expr(R1& r1):facade_(r1){}
+ explicit expr(E& p, R1& r1)
+ :hold_previous_(p),
+ facade_(boost::chain(this->previous.facade(),r1))
+ { }
+ explicit expr(const R1& r1):facade_(r1){}
+ explicit expr(const E& p, const R1& r1)
+ :facade_(boost::chain(p.facade(),r1))
+ { }
+
+ BOOST_STATIC_CONSTANT(int,use_lvalue = !add_const);
+ BOOST_STATIC_CONSTANT(int,use_rvalue = add_const);
+
+ template<typename R2>
+ typename result_impl<R2>::type
+ operator()(R2& r2,typename enable<R2,use_lvalue>::type* = 0)
+ {
+ typedef typename result_impl<R2>::type res_;
+ return res_(*this,r2);
+ }
template<typename R2>
typename result_impl<R2>::type
- operator()(R2& r2){
+ operator()(const R2& r2,typename enable<R2,use_rvalue>::type* = 0)const
+ {
typedef typename result_impl<R2>::type res_;
- typedef typename res_::super_ super_;
- return res_(
- *this,
- super_(
- boost::chain(this->super(),r2)
- )
- );
+ return res_(*this,r2);
}
- mutable previous_ previous;
};
- typedef boost::mpl::void_ top_;
-
- template<typename R1>
+ template<typename R1,bool add_const = false>
struct first_expr{
- typedef expr<top_,R1,1> type;
- typedef typename type::super_ super_;
- static type call(R1& r1){
- return type(super_(r1));
- }
+ typedef boost::mpl::void_ top_;
+ typedef chain_impl::expr<top_,R1,true,add_const> type;
+ typedef typename sel_const<R1,add_const>::type sel_r1_;
+ static type call(sel_r1_& r1){ return type(r1); }
};
+
-}// chain_l_impl
+}// chain_impl
}// detail
template<typename R1>
- typename detail::chain_l_impl::first_expr<R1>::type
+ typename detail::chain_impl::first_expr<R1,false>::type
chain_l(R1& r1){
- typedef detail::chain_l_impl::first_expr<R1> caller_;
+ typedef detail::chain_impl::first_expr<R1,false> caller_;
+ return caller_::call(r1);
+ }
+
+ template<typename R1>
+ typename detail::chain_impl::first_expr<R1,true>::type
+ chain_r(const R1& r1){
+ typedef detail::chain_impl::first_expr<R1,true> caller_;
return caller_::call(r1);
}
Modified: sandbox/statistics/detail/assign/boost/assign/chain_convert.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/chain_convert.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/chain_convert.hpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -9,6 +9,8 @@
#ifndef BOOST_ASSIGN_CHAIN_CONVERT_ER_2010_HPP
#define BOOST_ASSIGN_CHAIN_CONVERT_ER_2010_HPP
+#include <boost/assign/auto_size/range/chain_l.hpp>
+#include <boost/assign/auto_size/range/chain_r.hpp>
#include <boost/assign/auto_size/range/chain_convert_l.hpp>
#endif
\ No newline at end of file
Modified: sandbox/statistics/detail/assign/libs/assign/example/range.cpp
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/example/range.cpp (original)
+++ sandbox/statistics/detail/assign/libs/assign/example/range.cpp 2010-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -10,6 +10,7 @@
#include <boost/next_prior.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/assign/auto_size/ref_list_of.hpp>
+#include <boost/assign/auto_size/range/chain_l.hpp>
#include <boost/assign/auto_size/range/chain_convert_l.hpp>
#include <boost/assign/auto_size/range/convert_range.hpp>
@@ -31,12 +32,16 @@
ar_ ar4; ar4.assign( 2 );
ar_ ar5; ar5.assign( 3 );
ar_ ar6; ar6.assign( 6 );
-
+
{
BOOST_AUTO(tmp1,ref_list_of(a)(b));
BOOST_AUTO(tmp2,ref_list_of(c)(d));
BOOST_AUTO(tmp3,ref_list_of(e)(f));
+ boost::copy(
+ chain_convert_l(ar1)(ar2),
+ std::ostream_iterator<int>(os," ")
+ );
os << " chain_l(tmp1)(tmp2)(tmp3) = (";
boost::copy(
@@ -58,7 +63,6 @@
std::ostream_iterator<val_>(os," ")
); os << ')' << std::endl;
}
-
os << "<- " << std::endl;
}
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-03-24 00:22:50 EDT (Wed, 24 Mar 2010)
@@ -14,7 +14,6 @@
//check_ref_csv_int();
//std::cout << "check_csv : ok" << std::endl;
-// example_chain(std::cout);
example_range(std::cout);
return 0;
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