|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60812 - in sandbox/statistics/detail/assign: boost/assign/auto_size/array boost/assign/auto_size/check boost/assign/auto_size/detail boost/assign/auto_size/range libs/assign/doc libs/assign/example libs/assign/src
From: erwann.rogard_at_[hidden]
Date: 2010-03-24 16:28:51
Author: e_r
Date: 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
New Revision: 60812
URL: http://svn.boost.org/trac/boost/changeset/60812
Log:
m
Added:
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert.hpp
- copied, changed from r60800, /sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp
Removed:
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert_l.hpp
Text files modified:
sandbox/statistics/detail/assign/boost/assign/auto_size/array/interface.hpp | 26 ++--
sandbox/statistics/detail/assign/boost/assign/auto_size/check/all.hpp | 18 +-
sandbox/statistics/detail/assign/boost/assign/auto_size/check/chain.hpp | 2
sandbox/statistics/detail/assign/boost/assign/auto_size/check/example2.hpp | 2
sandbox/statistics/detail/assign/boost/assign/auto_size/detail/expr.hpp | 15 --
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain.hpp | 22 ++-
sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert.hpp | 213 ++++++++++++++++++++++++++++-----------
sandbox/statistics/detail/assign/boost/assign/auto_size/range/convert_range.hpp | 28 ++--
sandbox/statistics/detail/assign/boost/assign/auto_size/range/iterator_converter.hpp | 16 +-
sandbox/statistics/detail/assign/libs/assign/doc/index.html | 51 ++++++---
sandbox/statistics/detail/assign/libs/assign/example/range.cpp | 7 +
sandbox/statistics/detail/assign/libs/assign/src/main.cpp | 14 +-
12 files changed, 260 insertions(+), 154 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 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -98,9 +98,11 @@
const_reference back() const{ return (this->ref_array()).back(); }
void swap(array_interface& other){
- //typedef boost::mpl::int_<N> int_n_;
- //this->swap_impl(other,int_n_());
- std::swap(this->ref_array(),other.ref_array());
+ typedef boost::mpl::int_<N> int_n_;
+ this->swap_impl(other,int_n_());
+ // Previously :
+ // std::swap(this->ref_array(),other.ref_array());
+ // did not pass check_copy_array.
}
void assign(const T& val){
@@ -165,16 +167,16 @@
typedef boost::mpl::bool_<false> false_;
typedef boost::mpl::bool_<true> true_;
- //void swap_impl(array_interface& other,boost::mpl::int_<0>){}
+ void swap_impl(array_interface& other,boost::mpl::int_<0>){}
- //template<int N1>
- //void swap_impl(array_interface& other,boost::mpl::int_<N1>){
- // reference lhs = (*this)[N1-1];
- // reference rhs = (other)[N1-1];
- // lhs.swap(rhs);
- // typedef boost::mpl::int_<N1-1> next_int_;
- // this->swap_impl(other,next_int_());
- //}
+ template<int N1>
+ void swap_impl(array_interface& other,boost::mpl::int_<N1>){
+ reference lhs = (*this)[N1-1];
+ reference rhs = (other)[N1-1];
+ lhs.swap(rhs);
+ typedef boost::mpl::int_<N1-1> next_int_;
+ this->swap_impl(other,next_int_());
+ }
void assign(const T& val,true_ /*copy semantics*/){
// Force copy semantics. Suggested by M.P.G on Feb 28th, 2010.
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 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -19,7 +19,6 @@
#include <boost/assign/auto_size/check/constants.hpp>
#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/converter.hpp>
#include <boost/assign/auto_size/check/copy_array.hpp>
@@ -30,6 +29,8 @@
#include <boost/assign/auto_size/check/lifo.hpp>
#include <boost/assign/auto_size/check/rebind_array.hpp>
#include <boost/assign/auto_size/check/example2.hpp>
+#include <boost/assign/auto_size/check/chain_convert_r.hpp>
+#include <boost/assign/auto_size/check/chain_convert_l.hpp>
#define BOOST_ASSIGN_AS_CHECK_all(fun) \
namespace boost{ \
@@ -45,14 +46,17 @@
BOOST_ASSIGN_AS_CHECK_copy_iterator \
BOOST_ASSIGN_AS_CHECK_copy_array \
BOOST_ASSIGN_AS_CHECK_rebind_array \
+ BOOST_ASSIGN_AS_CHECK_comparison_op \
BOOST_ASSIGN_AS_CHECK_converter(std::list<T>) \
BOOST_ASSIGN_AS_CHECK_converter(std::vector<T>) \
+ BOOST_ASSIGN_AS_CHECK_adapter_lifo(std::stack<T>) \
+ BOOST_ASSIGN_AS_CHECK_adapter_fifo(std::queue<T>) \
typedef boost::array<T,8> ar8_; \
BOOST_ASSIGN_AS_CHECK_converter(ar8_) \
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 \
+ BOOST_ASSIGN_AS_CHECK_chain_convert_r \
+ BOOST_ASSIGN_AS_CHECK_chain_convert_l \
+ BOOST_ASSIGN_AS_CHECK_example2 \
} \
void BOOST_PP_CAT(fun,_int)(){ fun<int>(); } \
} \
@@ -61,10 +65,4 @@
} \
/**/
-/*
- BOOST_ASSIGN_AS_CHECK_chain \
- BOOST_ASSIGN_AS_CHECK_example2 \
-*/
#endif
-
-
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 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -39,7 +39,7 @@
BOOST_AUTO(tmp1,BOOST_ASSIGN_AS_CHECK_ref3(a1,b1,c1)); \
BOOST_AUTO(tmp2,BOOST_ASSIGN_AS_CHECK_ref3(d1,e1,f1)); \
BOOST_AUTO(tmp3,BOOST_ASSIGN_AS_CHECK_ref2(g1,h1)); \
- boost::copy(chain_r(ar1)(ar2)(ar3),std::ostream_iterator<T>(std::cout," ")); \
+ boost::copy(chain_convert_r(ar1)(ar2)(ar3),std::ostream_iterator<T>(std::cout," ")); \
check_iterator_impl( boost::begin( chain_r(ar1)(ar2)(ar3) ) ); \
} \
/**/
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/check/example2.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/check/example2.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/check/example2.hpp 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -11,7 +11,7 @@
#include <vector>
#include <iterator>
#include <boost/range/algorithm/copy.hpp>
-#include <boost/assign/auto_size/chain_convert.hpp>
+#include <boost/assign/auto_size/range/chain_convert_l.hpp>
#define BOOST_ASSIGN_AS_CHECK_example2 \
{ \
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-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -56,7 +56,7 @@
namespace detail{
namespace auto_size{
- // ---- fwd declare ---- //
+ // ---- template parameters ---- //
// expr<> keeps a reference to a new element and links to the previous
// collection.
@@ -129,20 +129,11 @@
result_type operator()(T& t)const{ return result_type(*this,t); }
- //private:
- //template<int Nshift,typename A,typename E1,int N1>
- //friend void write_to_array(A& a,const expr<E1,T,N1,R,P>& e,false_);
-
- //template<int Nshift,typename A,typename E1,int N1>
- //friend void write_to_array(A& a,const expr<E1,T,N1,R,P>& e,true_);
-
- //template<int Nshift,typename A,typename E1,int N1>
- //friend void write_to_array(A& a,const expr<E1,T,N1,R,P>& e);
-
mutable previous_ previous;
mutable ref_ ref;
-// expr();
+ private:
+ expr();
};
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain.hpp 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -23,7 +23,7 @@
// developed by MPG, but allows lvalues.
// Usage : Let r1, r2 and r3 denote lvalues of ranges,
-// boost::copy( from, boost::begin( chain_l(r1)(r2)(r3) ) );
+// boost::copy( input, 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.
@@ -72,7 +72,8 @@
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_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_;
@@ -84,29 +85,30 @@
typedef typename
chain_impl::facade_of_expr<E,R1,is_first,add_const>::type facade_;
-
- template<typename R2>
- struct result_impl : chain_impl::next_expr<this_,R2,add_const>{};
facade_& facade(){ return (*this); }
const facade_& facade()const{ return (*this); }
+ // lvalue constructors
explicit expr(R1& r1):facade_(r1){}
explicit expr(E& p, R1& r1)
:hold_previous_(p),
facade_(boost::chain(this->previous.facade(),r1))
{ }
+
+ // rvalue constructors
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);
+ // unary operators
+ template<typename R2>
+ struct result_impl : chain_impl::next_expr<this_,R2,add_const>{};
template<typename R2>
typename result_impl<R2>::type
- operator()(R2& r2,typename enable<R2,use_lvalue>::type* = 0)
+ operator()(R2& r2,typename enable<R2,!add_const>::type* = 0)
{
typedef typename result_impl<R2>::type res_;
return res_(*this,r2);
@@ -114,7 +116,7 @@
template<typename R2>
typename result_impl<R2>::type
- operator()(const R2& r2,typename enable<R2,use_rvalue>::type* = 0)const
+ operator()(const R2& r2,typename enable<R2,add_const>::type* = 0)const
{
typedef typename result_impl<R2>::type res_;
return res_(*this,r2);
@@ -122,7 +124,7 @@
};
- template<typename R1,bool add_const = false>
+ template<typename R1,bool add_const>
struct first_expr{
typedef boost::mpl::void_ top_;
typedef chain_impl::expr<top_,R1,true,add_const> type;
Copied: sandbox/statistics/detail/assign/boost/assign/auto_size/range/chain_convert.hpp (from r60800, /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.hpp 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -8,9 +8,11 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_DETAIL_RANGE_CHAIN_CONVERT_L_ER_2010_HPP
#define BOOST_ASSIGN_DETAIL_RANGE_CHAIN_CONVERT_L_ER_2010_HPP
-#include <boost/mpl/int.hpp>
#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/mpl/inherit.hpp>
#include <boost/mpl/void.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/range/chain.hpp>
@@ -20,10 +22,13 @@
#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>
+#include <boost/assign/auto_size/range/chain.hpp>
+
+#include <boost/mpl/assert.hpp> // tmp
+#include <boost/type_traits/is_reference.hpp> // tmp
// Usage : Let r1, r2 and r3 denote lvalue-ranges.
-// boost::copy( from, boost::begin( chain_convert_l(r1)(r2)(r3) ) );
+// boost::copy( input, 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.
@@ -32,67 +37,79 @@
namespace boost{
namespace assign{
namespace detail{
-namespace chain_convert_l_impl{
+namespace chain_convert_impl{
+
+ // ---- template parameters ---- //
-// template<typename E,typename Rng1,bool is_first,typename V,typename R> class expr;
+ // L : converted_range::list<> or empty base if rvalue
+ // E : chain_impl::expr<>
+ // Rng1 : a range to chain to
+ // is_first : indicator
+ // V : a value conversion parameter
+ // R : a reference conversion parameter
+ // ---- fwd decl ---- //
template<typename L,typename E,typename Rng1,
- bool is_first,typename V,typename R> class expr;
+ bool is_first,typename V,typename R,bool add_const> class expr;
+
+
+ // ---- traits ---- //
- // 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>
+ // Returns the implementation of expr<L,E,Rng1,is_first,V,R> for any L
+ template<typename E,typename Rng1,
+ bool is_first,typename V,typename R,bool add_const>
struct impl_of_expr
{
+ typedef typename chain_impl::sel_const<Rng1,add_const>::type cr1_;
typedef typename
- detail::result_of::convert_range<Rng1,V,R>::type conv_r1_;
+ detail::result_of::convert_range<cr1_,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 impl_of_expr<E,Rng1,true,V,R>
+ template<typename E,typename Rng1,typename V,typename R,bool add_const>
+ struct impl_of_expr<E,Rng1,true,V,R,add_const>
{
- 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 typename chain_impl::sel_const<Rng1,add_const>::type cr1_;
+ typedef typename result_of::convert_range<cr1_,V,R>::type conv_r1_;
+ typedef typename chain_impl::first_expr<conv_r1_,add_const>::type type;
};
typedef boost::mpl::void_ top_;
+ template<typename L,typename Rng1,bool is_first,
+ typename V,typename R,bool add_const>
+ struct sel_list : boost::mpl::eval_if_c<
+ add_const,
+ boost::mpl::identity<boost::mpl::inherit<boost::mpl::empty_base> >,
+ boost::mpl::identity<converted_range::list<L,Rng1,is_first,V,R> >
+ >{
+ // mpl::inherit<> is needed to avoid expr<> inheriting from 2 empty
+ // bases.
+ };
+
+ // ---- chainer ---- //
template<typename L,typename E,typename Rng1,
- bool is_first,typename V,typename R>
+ bool is_first,typename V,typename R,bool add_const>
class expr :
- converted_range::list<L,Rng1,is_first,V,R>,
- public impl_of_expr<E,Rng1,is_first,V,R>::type
+ sel_list<L,Rng1,is_first,V,R,add_const>::type,
+ public impl_of_expr<E,Rng1,is_first,V,R,add_const>::type
{
- typedef expr<L,E,Rng1,is_first,V,R> this_;
+ typedef expr<L,E,Rng1,is_first,V,R,add_const> this_;
public:
+
+ // bases
+ typedef typename sel_list<L,Rng1,is_first,V,R,add_const>::type list_;
+ typedef typename impl_of_expr<E,Rng1,
+ is_first,V,R,add_const>::type impl_;
+ public:
+
// 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
+
+ // lvalue constructors
explicit expr(Rng1& r1)
:list_(r1),
impl_(this->converted_range)
@@ -101,15 +118,27 @@
:list_(l,r1),
impl_(e,this->converted_range)
{}
+
+ // rvalue constructors
+ explicit expr(const Rng1& r1)
+ :impl_(convert_range<V,R>(r1))
+ {}
+ explicit expr(const E& e,const Rng1& r1)
+ :impl_(e,convert_range<V,R>(r1))
+ {}
// unary operators
template<typename Rng2>
struct result_impl
- : chain_convert_l_impl::next_expr<list_,impl_,Rng2>{};
-
+ { typedef expr<list_,impl_,Rng2,false,V,R,add_const> type; };
+
+ template<typename R2,bool b>
+ struct enable : boost::enable_if_c<b>{};
+
+
template<typename Rng2> // Warning : overrides base.
typename result_impl<Rng2>::type
- operator()(Rng2& r2)
+ operator()(Rng2& r2,typename enable<Rng2,!add_const>::type* = 0)
{
typedef typename result_impl<Rng2>::type res_;
return res_(
@@ -119,55 +148,119 @@
);
}
+ template<typename Rng2> // Warning : overrides base.
+ typename result_impl<Rng2>::type
+ operator()(const Rng2& r2,
+ typename enable<Rng2,add_const>::type* = 0)const
+ {
+ typedef typename result_impl<Rng2>::type res_;
+ return res_(
+ static_cast<const impl_&>(*this),
+ r2
+ );
+ }
+
};
- template<typename Rng1,typename V,
- typename R = typename detail::convert_range_reference<Rng1,V>::type>
+ // ---- traits ---- //
+
+ template<typename Rng1,typename V,typename R, bool add_const>
struct first_expr{
- typedef expr<top_,top_,Rng1,1,V,R> type;
- static type call(Rng1& r1){ return type(r1); }
+ typedef chain_convert_impl::expr<top_,top_,Rng1,1,V,R,add_const> type;
+ typedef typename chain_impl::sel_const<Rng1,add_const>::type cr1_;
+ static type call(cr1_& r1){ return type(r1); }
};
- template<typename Rng1>
+ template<typename Rng1,typename V,
+ typename R = typename detail::convert_range_reference<Rng1,V>::type>
+ struct first_expr_l : chain_convert_impl::first_expr<Rng1,V,R,false>{};
+
+ // It's necessary to take add_const<V> or else non-rvalues may occur e.g.
+ // Rng1 = array<ref_wrapper<int>,1> and V = int, then R = int*.
+ template<typename Rng1,typename V,
+ typename R = typename detail::convert_range_reference<const Rng1,
+ typename boost::add_const<V>::type>::type>
+ struct first_expr_r
+ : chain_convert_impl::first_expr<
+ Rng1,typename boost::add_const<V>::type,R,true>{};
+
+ template<typename Rng1,bool add_const>
struct deduce_value{
typedef typename boost::range_reference<Rng1>::type from_;
- typedef typename reference_traits::convert_to<from_>::type to_;
- typedef typename boost::remove_reference<to_>::type type;
+ typedef typename reference_traits::convert_to<from_>::type ref_to_;
+ typedef typename boost::remove_reference<ref_to_>::type to_;
+ typedef typename chain_impl::sel_const<to_,add_const>::type type;
};
-
}// chain_convert_l_impl
}// detail
+ // lvalue
+
template<typename V,typename R,typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<Rng1,V,R>::type
+ typename detail::chain_convert_impl::first_expr_l<Rng1,V,R>::type
chain_convert_l(Rng1& r1,
typename boost::disable_if<boost::is_same<R,use_default> >::type* = 0
){
- typedef detail::chain_convert_l_impl::first_expr<Rng1,V,R> caller_;
+ typedef detail::chain_convert_impl::first_expr_l<Rng1,V,R> caller_;
return caller_::call(r1);
}
template<typename V,typename R,typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<Rng1,V>::type
+ typename detail::chain_convert_impl::first_expr_l<Rng1,V>::type
chain_convert_l(Rng1& r1,
typename boost::enable_if<boost::is_same<R,use_default> >::type* = 0
){
- typedef detail::chain_convert_l_impl::first_expr<Rng1,V> caller_;
+ typedef detail::chain_convert_impl::first_expr_l<Rng1,V> caller_;
return caller_::call(r1);
}
template<typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<
+ typename detail::chain_convert_impl::first_expr_l<
Rng1,
- typename detail::chain_convert_l_impl::deduce_value<Rng1>::type
+ typename detail::chain_convert_impl::deduce_value<Rng1,false>::type
>::type
chain_convert_l(Rng1& r1)
{
- typedef typename detail::chain_convert_l_impl::deduce_value<
- Rng1
+ typedef typename detail::chain_convert_impl::deduce_value<
+ Rng1,false
+ >::type val_;
+ typedef detail::chain_convert_impl::first_expr_l<Rng1,val_> caller_;
+ return caller_::call(r1);
+ }
+
+ // rvalue : Warning: if is_const<V> != true, R must be value, not a ref.
+
+ template<typename V,typename R,typename Rng1>
+ typename detail::chain_convert_impl::first_expr_r<Rng1,V,R>::type
+ chain_convert_r(const Rng1& r1,
+ typename boost::disable_if<boost::is_same<R,use_default> >::type* = 0
+ ){
+ typedef detail::chain_convert_impl::first_expr_r<Rng1,V,R> caller_;
+ return caller_::call(r1);
+ }
+
+ template<typename V,typename R,typename Rng1>
+ typename detail::chain_convert_impl::first_expr_r<Rng1,V>::type
+ chain_convert_r(const Rng1& r1,
+ typename boost::enable_if<boost::is_same<R,use_default> >::type* = 0
+ ){
+ typedef detail::chain_convert_impl::first_expr_r<Rng1,V> caller_;
+ return caller_::call(r1);
+ }
+
+ template<typename Rng1>
+ typename detail::chain_convert_impl::first_expr_r<
+ Rng1,
+ typename detail::chain_convert_impl::deduce_value<
+ const Rng1,true>::type
+ >::type
+ chain_convert_r(const Rng1& r1)
+ {
+ typedef typename detail::chain_convert_impl::deduce_value<
+ const Rng1,true
>::type val_;
- typedef detail::chain_convert_l_impl::first_expr<Rng1,val_> caller_;
+ typedef detail::chain_convert_impl::first_expr_r<Rng1,val_> caller_;
return caller_::call(r1);
}
Deleted: 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 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
+++ (empty file)
@@ -1,177 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-// assign::detail::range::chain_convert_l.hpp //
-// //
-// (C) Copyright 2010 Erwann Rogard //
-// Use, modification and distribution are subject to the //
-// Boost Software License, Version 1.0. (See accompanying file //
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
-//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_ASSIGN_DETAIL_RANGE_CHAIN_CONVERT_L_ER_2010_HPP
-#define BOOST_ASSIGN_DETAIL_RANGE_CHAIN_CONVERT_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/type_traits/is_same.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 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.
-
-// TODO follow the model of chain_impl to allow rvalues.
-
-namespace boost{
-namespace assign{
-namespace detail{
-namespace chain_convert_l_impl{
-
-// template<typename E,typename Rng1,bool is_first,typename V,typename R> class expr;
-
- template<typename L,typename E,typename Rng1,
- bool is_first,typename V,typename R> class expr;
-
- // 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 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 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:
-
- // 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
- : chain_convert_l_impl::next_expr<list_,impl_,Rng2>{};
-
- template<typename Rng2> // Warning : overrides base.
- typename result_impl<Rng2>::type
- operator()(Rng2& r2)
- {
- typedef typename result_impl<Rng2>::type res_;
- return res_(
- static_cast<list_&>(*this),
- static_cast<impl_&>(*this),
- r2
- );
- }
-
- };
-
- template<typename Rng1,typename V,
- typename R = typename detail::convert_range_reference<Rng1,V>::type>
- struct first_expr{
- typedef expr<top_,top_,Rng1,1,V,R> type;
- static type call(Rng1& r1){ return type(r1); }
- };
-
- template<typename Rng1>
- struct deduce_value{
- typedef typename boost::range_reference<Rng1>::type from_;
- typedef typename reference_traits::convert_to<from_>::type to_;
- typedef typename boost::remove_reference<to_>::type type;
- };
-
-
-}// chain_convert_l_impl
-}// detail
-
- template<typename V,typename R,typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<Rng1,V,R>::type
- chain_convert_l(Rng1& r1,
- typename boost::disable_if<boost::is_same<R,use_default> >::type* = 0
- ){
- typedef detail::chain_convert_l_impl::first_expr<Rng1,V,R> caller_;
- return caller_::call(r1);
- }
-
- template<typename V,typename R,typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<Rng1,V>::type
- chain_convert_l(Rng1& r1,
- typename boost::enable_if<boost::is_same<R,use_default> >::type* = 0
- ){
- typedef detail::chain_convert_l_impl::first_expr<Rng1,V> caller_;
- return caller_::call(r1);
- }
-
- template<typename Rng1>
- typename detail::chain_convert_l_impl::first_expr<
- Rng1,
- typename detail::chain_convert_l_impl::deduce_value<Rng1>::type
- >::type
- chain_convert_l(Rng1& r1)
- {
- typedef typename detail::chain_convert_l_impl::deduce_value<
- Rng1
- >::type val_;
- typedef detail::chain_convert_l_impl::first_expr<Rng1,val_> caller_;
- return caller_::call(r1);
- }
-
-}// assign
-}// boost
-
-#endif
\ No newline at end of file
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/range/convert_range.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/range/convert_range.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/range/convert_range.hpp 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -15,18 +15,16 @@
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/assign/auto_size/range/iterator_converter.hpp>
-#include <boost/assign/auto_size/traits/reference_traits.hpp>
// Usage:
-// convert_range<T>(r)
-// changes U = range_reference<R>::type to T.
-// convert_range(r)
-// changes U to reference_traits::convert_to<U>::type
+// convert_range<V,R>(r)
+// convert_range<V,use_default>(r)
namespace boost{
namespace assign{
namespace detail{
+// Warning : see the warning of converted_iterator_reference
template<typename Rng,typename V>
struct convert_range_reference
: detail::converted_iterator_reference<
@@ -55,7 +53,7 @@
}// result_of
}// detail
- // convert_range
+ // lvalue
template<typename V,typename R,typename Rng>
typename detail::result_of::convert_range<Rng,V,R>::type
@@ -67,20 +65,22 @@
}
template<typename V,typename R,typename Rng>
- typename detail::result_of::convert_range<const Rng,V,R>::type
- convert_range( const Rng& r,
- typename boost::disable_if<boost::is_same<R,use_default> >::type* = 0)
+ typename detail::result_of::convert_range<Rng,V>::type
+ convert_range( Rng& r,
+ typename boost::enable_if<boost::is_same<R,use_default> >::type* = 0)
{
- typedef detail::result_of::convert_range<const Rng,V,R> caller_;
+ typedef detail::result_of::convert_range<Rng,V> caller_;
return caller_::call( r );
}
+ // rvalue
+
template<typename V,typename R,typename Rng>
- typename detail::result_of::convert_range<Rng,V>::type
- convert_range( Rng& r,
- typename boost::enable_if<boost::is_same<R,use_default> >::type* = 0)
+ typename detail::result_of::convert_range<const Rng,V,R>::type
+ convert_range( const Rng& r,
+ typename boost::disable_if<boost::is_same<R,use_default> >::type* = 0)
{
- typedef detail::result_of::convert_range<Rng,V> caller_;
+ typedef detail::result_of::convert_range<const Rng,V,R> caller_;
return caller_::call( r );
}
Modified: sandbox/statistics/detail/assign/boost/assign/auto_size/range/iterator_converter.hpp
==============================================================================
--- sandbox/statistics/detail/assign/boost/assign/auto_size/range/iterator_converter.hpp (original)
+++ sandbox/statistics/detail/assign/boost/assign/auto_size/range/iterator_converter.hpp 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -21,6 +21,9 @@
namespace assign{
namespace detail{
+// Warning :
+// If range_value<I>::type is const but V isn't, the convertible type is
+// a value, not reference. If a reference is desired, V must also be const.
template<typename I,typename V>
struct converted_iterator_reference{
@@ -28,14 +31,9 @@
typedef typename boost::remove_reference<f_ref_>::type f_val_;
typedef V t_val_;
typedef typename boost::add_reference<V>::type t_ref_;
- typedef typename boost::is_convertible<f_val_,t_val_> necessary_;
typedef typename boost::is_convertible<f_ref_,t_ref_>::type use_ref_;
typedef typename boost::mpl::if_<use_ref_,t_ref_,t_val_>::type type;
-
- static void internal_check(){
- BOOST_MPL_ASSERT((necessary_));
- }
-
+
};
template<typename I, typename V,
@@ -58,7 +56,11 @@
> super_;
converted_iterator(){}
- converted_iterator(const I& base):super_(base){
+ converted_iterator(const I& base):super_(base)
+ {
+ typedef typename boost::iterator_reference<I>::type i_ref_;
+ typedef typename boost::is_convertible<i_ref_,R>::type necessary_;
+ BOOST_MPL_ASSERT((necessary_));
}
};
} //detail
Modified: sandbox/statistics/detail/assign/libs/assign/doc/index.html
==============================================================================
--- sandbox/statistics/detail/assign/libs/assign/doc/index.html (original)
+++ sandbox/statistics/detail/assign/libs/assign/doc/index.html 2010-03-24 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -38,7 +38,7 @@
<li>Function map_list_of()
<li>Function tuple_list_of()
<li>Functions repeat()
, repeat_fun()
and range()
- <li>Function chain_convert()
+ <li>Functions chain_convert_l()
and chain_convert_r()
<li>Functions ref_list_of()
, cref_list_of()
and variants
<li>Functions ref_csv()
, cref_csv()
and variants
<li>A "complicated" example
@@ -64,7 +64,7 @@
<li>Functions repeat()
, repeat_fun()
and
<a href="#ref-repeat"><code>range()</code>
</a></li>
- <li>Function chain_convert()
</li>
+ <li>Functions chain_convert_l()
and chain_convert_r()
</li>
<li>Customizing argument list sizes </li>
</ul>
<li>
@@ -75,7 +75,7 @@
<li> Proxy object list_inserter<>
</li>
<li> Proxy object static_generic_list<>
</li>
<li> Proxy object array_interface<>
</li>
- <li> Proxy object adaptor::chain_convert<>
</li>
+ <li> Proxy object chain_convert_impl::expr<>
</li>
<li> Proxy object expr<>
</li>
<li> Proxy object lazy_array<>
</li>
<li> Proxy object static_array<>
</li>
@@ -145,7 +145,7 @@
<li>Function map_list_of()
<li>Function tuple_list_of()
<li>Functions repeat()
, repeat_fun()
and range()
- <li>Function chain_convert()
+ <li>Functions chain_convert_l()
and chain_convert_r()
<li>Functions ref_list_of()
, cref_list_of()
and variants
<li>Functions ref_csv()
, cref_csv()
and variants
<li>A "complicated" example
@@ -477,7 +477,7 @@
</p>
-<h3><a name="chain_convert">Functions <code>chain_convert_l()</code> and <code>chain_convert_r()</code></a></h3>
+<h3>Functions <code>chain_convert_l()</code> and <code>chain_convert_r()</code><a name="chain_convert"></h3>
While the function range()
works in combination with functions
such as list_of()
, it is not compatible with
@@ -496,9 +496,9 @@
<span class=special>}</span></pre>
</blockquote>
-Notice the suffix 'r' which tells the functions that the arguments should be treated as rvalues. The reference is here.
+Notice the suffix 'r' which tells the function that the arguments should be treated as rvalues. The reference is here.
-<h3>Functions <code>ref_list_of()</code>, <code>cref_list_of()</code> <a name="ref_list_of"> and variants</h3>
+<h3>Functions <code>ref_list_of()</code>, <code>cref_list_of()</code> and variants<a name="ref_list_of"></h3>
When you need to create an anonymous range of values and speed is essential,
these two functions provide what you want. <blockquote>
@@ -835,7 +835,7 @@
<li>Functions repeat()
, repeat_fun()
and
<a href="#ref-repeat"><code>range()</code>
</a></li>
- <li>Function chain_convert()
</li>
+ <li>Functions chain_convert_l()
and chain_convert_r()
</li>
<li>Customizing argument list sizes </li>
</ul>
@@ -1149,7 +1149,7 @@
</p>
- <h3> <a name="ref-chain_convert"> Function <code>chain_convert_l()</code> and <code>chain_convert_r()</a> </h3>
+ <h3> Functions <code>chain_convert_l()</code> and <code>chain_convert_r()<a name="ref-chain_convert"> </h3>
<p> This function serves as a sustitute for range()
within the auto-size framework.
@@ -1159,22 +1159,35 @@
<blockquote>
<table cellpadding=5 border=1>
<tr><th class="head">Parameter</th> <th class="head">Description</th>
- <tr><td><tt>R</tt></td><td>Range</td></tr>
+ <tr><td><tt>L</tt></td><td>Implementation defined</td></tr>
+ <tr><td><tt>E</tt></td><td>Implementation defined</td></tr>
+ <tr><td><tt>V</tt></td><td>A value type</td></tr>
+ <tr><td><tt>R</tt></td><td>A reference type</td></tr>
+ <tr><td><tt>Rng</tt></td><td>A range type</td></tr>
+ <tr><td><tt>add_const</tt></td><td>A boolean value</td></tr>
</table>
</blockquote>
<b>Associated types</b>
+ <blockquote>
+ <table cellpadding=5 border=1>
+ <tr><th class="head">Expression</th> <th class="head">Description<th class="head">Alias</th>
+ <tr><td><tt>chain_convert_impl::expr<L,E,true,V,R,add_const></tt></td><td>Implementation</td><td>Impl<></td></tr>
+ </table>
+ </blockquote>
+
<p>To be defined </p>
<b>Usage</b>
- <p>Let <code>r</code> instance of <code>R</code>
+ <p>Let <code>r</code> instance of <code>Rng</code>
<blockquote>
<table cellpadding=5 border=1>
<tr><th class="head">Expression</th> <th class="head">Result</th>
- <tr><td><tt>chain_convert_l(r)</tt></td><td> adaptor::chain_convert_l<R>
</td></tr>
- <tr><td><tt>chain_convert_r(r)</tt></td><td> adaptor::chain_convert_r<R>
</td></tr>
+ <tr><td><tt>chain_convert_l<V,R>(r)</tt></td><td> Impl<>
</td></tr>
+ <tr><td><tt>chain_convert_l<V,use_default>(r)</tt></td><td> Impl<>
</td></tr>
+ <tr><td><tt>chain_convert_l(r)</tt></td><td> Impl<>
</td></tr>
</table>
</blockquote>
@@ -1192,7 +1205,7 @@
<li> Proxy object expr<>
</li>
<li> Proxy object lazy_array<>
</li>
<li> Proxy object static_array<>
</li>
- <li> Proxy objects adaptor::chain_convert_l<>
and adaptor::chain_convert_r<>
</li>
+ <li> Proxy objects chain_convert_impl::expr<>
</li>
</ul>
<h3>Proxy object <code>converter<></code><a name=ref-converter> </h3>
@@ -1421,7 +1434,7 @@
</table>
</blockquote>
- <h3><a name="ref-list_inserter">Proxy object <code>list_inserter<></code></a></h3>
+ <h3>Proxy object <code>list_inserter<></code><a name="ref-list_inserter"></h3>
<p>
This class is responsible for inserting elements into containers and
@@ -1524,7 +1537,7 @@
chain argument list together in a very space-efficient manner.
</p>
- <h4><a name="ref-array_interface">Proxy object <code>array_interface<></code></a></h4>
+ <h4>Proxy object <code>array_interface<></code><a name="ref-array_interface"></h4>
<p>Exposes most of the <code>boost::array<></code> interface.</p>
<b>Header</b> <code><boost/assign/auto_size/array/interface.hpp></code>
@@ -1676,7 +1689,7 @@
</p>
- <h3><a name="ref-lazy_array">Proxy object <code>lazy_array<></code></a></h3>
+ <h3>Proxy object <code>lazy_array<></code><a name="ref-lazy_array"></h3>
<b>Header</b> <code><boost/assign/auto_size/array/lazy.hpp></code>
<p>
@@ -1724,7 +1737,7 @@
</p>
- <h4><a name="ref-static_array">Proxy object <code>static_array<></code></a></h4>
+ <h4>Proxy object <code>static_array<></code><a name="ref-static_array"></h4>
<b>Header</b> <code><boost/assign/auto_size/array/static.hpp></code>
<p>
<b>Template parameters</b>
@@ -1762,7 +1775,7 @@
</table>
</blockquote>
- <h3><a name="ref-adaptor::chain_convert">Proxy objects <code>adaptor::chain_convert_l<></code> and <code>adaptor::chain_convert_r<></code> </a> </h3>
+ <h3>Proxy object <code>chain_convert_impl::expr<></code><a name="ref-chain_convert_impl"> </h3>
Successive calls to this proxy object joins together collections into one whose dereferenced type is one that is convertible
to from those of the input ranges. In particular, either range may contain reference wrappers if they meet certain traits requirement.
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 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -10,7 +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.hpp>
#include <boost/assign/auto_size/range/chain_convert_l.hpp>
#include <boost/assign/auto_size/range/convert_range.hpp>
@@ -33,11 +33,15 @@
ar_ ar5; ar5.assign( 3 );
ar_ ar6; ar6.assign( 6 );
+ typedef boost::array<detail::assign_reference_copy<val_>,1> ref_array_;
+
{
+
BOOST_AUTO(tmp1,ref_list_of(a)(b));
BOOST_AUTO(tmp2,ref_list_of(c)(d));
BOOST_AUTO(tmp3,ref_list_of(e)(f));
+/*
os << " chain_l(tmp1)(tmp2)(tmp3) = (";
boost::copy(
chain_convert_l(tmp1)(ar5)(tmp3),
@@ -57,6 +61,7 @@
chain_convert_l(ar1)(ar2)(ar3),
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 16:28:47 EDT (Wed, 24 Mar 2010)
@@ -1,18 +1,18 @@
#include <iostream>
#define BOOST_ASSIGN_CHECK_EQUAL(a,b) BOOST_ASSERT(a==b)
-//#include <boost/assign/auto_size/check/ref_list_of.hpp>
-//#include <boost/assign/auto_size/check/ref_csv.hpp>
+#include <boost/assign/auto_size/check/ref_list_of.hpp>
+#include <boost/assign/auto_size/check/ref_csv.hpp>
#undef BOOST_ASSIGN_CHECK_EQUAL
#include <libs/assign/example/range.h>
int main (int argc, char * const argv[]) {
- //using namespace boost::assign::detail::auto_size;
+ using namespace boost::assign::detail::auto_size;
- //check_ref_list_of_int();
- //std::cout << "check_ref_list_of : ok" << std::endl;
- //check_ref_csv_int();
- //std::cout << "check_csv : ok" << std::endl;
+ check_ref_list_of_int();
+ std::cout << "check_ref_list_of : ok" << std::endl;
+ check_ref_csv_int();
+ std::cout << "check_csv : ok" << std::endl;
example_range(std::cout);
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