|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66672 - in sandbox/statistics/support/boost/assign/v2: anon chain/aux_ put/compose/functor ref/anon/csv ref/fusion ref/fusion_matrix
From: erwann.rogard_at_[hidden]
Date: 2010-11-21 22:09:13
Author: e_r
Date: 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
New Revision: 66672
URL: http://svn.boost.org/trac/boost/changeset/66672
Log:
(finishing) to add support for c++0x
Text files modified:
sandbox/statistics/support/boost/assign/v2/anon/cont.hpp | 103 +++++++-------
sandbox/statistics/support/boost/assign/v2/anon/csv.hpp | 6
sandbox/statistics/support/boost/assign/v2/chain/aux_/bitwise_or.hpp | 28 ++--
sandbox/statistics/support/boost/assign/v2/put/compose/functor/composer.hpp | 81 ++++++++----
sandbox/statistics/support/boost/assign/v2/put/compose/functor/forward_args.hpp | 140 ++++++++++++++++++---
sandbox/statistics/support/boost/assign/v2/ref/anon/csv/assign_xxx.hpp | 6
sandbox/statistics/support/boost/assign/v2/ref/fusion/link_holder.hpp | 21 +-
sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/container.hpp | 264 ++++++++++++++++++++-------------------
sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/fwd.hpp | 11 -
sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/nth_result_of.hpp | 48 ++++--
10 files changed, 422 insertions(+), 286 deletions(-)
Modified: sandbox/statistics/support/boost/assign/v2/anon/cont.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/anon/cont.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/anon/cont.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -31,14 +31,14 @@
}// anon_aux
namespace result_of_modulo{
-
+
template<typename T,typename F,typename Tag>
struct new_fun<anon_aux::cont<T,F,Tag> >
{
template<typename F1>
struct apply{ typedef anon_aux::cont<T, F1, Tag> type; };
-
+
};
template<typename T,typename F,typename Tag>
@@ -47,9 +47,9 @@
template<typename NewTag>
struct apply{ typedef anon_aux::cont<T, F, NewTag> type; };
-
+
};
-
+
}//result_of_modulo
namespace anon_aux{
@@ -62,22 +62,23 @@
template<typename T,typename F,typename Tag>
- class cont :
+ class cont :
public relational_op_aux::crtp< cont<T,F,Tag> >,
- public put_aux::crtp<
+ public put_aux::crtp<
typename anon_aux::impl<T>::type, F, Tag,
cont<T,F,Tag>,
- cont_modifier_traits<T,F,Tag>
+ cont_modifier_traits<T,F,Tag>
>
{
typedef typename anon_aux::impl<T>::type impl_;
typedef cont_modifier_traits<T,F,Tag> modifier_traits_;
- typedef put_aux::crtp< impl_, F, Tag, cont, modifier_traits_> put_crtp_;
-
+ typedef put_aux::crtp<
+ impl_, F, Tag, cont, modifier_traits_> put_crtp_;
+
typedef put_aux::modifier<Tag> modifier_;
-
+
public:
-
+
typedef T value_type;
typedef typename boost::range_size<impl_>::type size_type;
typedef typename boost::range_iterator<impl_>::type iterator;
@@ -92,68 +93,68 @@
// Required by crtp when Tag or F is modified.
}
- explicit cont( impl_ const& v, F const& f, modifier_ const& m )
+ explicit cont( impl_ const& v, F const& f, modifier_ const& m )
: put_crtp_( f, m ), impl( v )
{
// Required by crtp when Tag or F is modified.
}
-
+
// Deque interface
- iterator begin(){
- return boost::begin( this->impl );
+ iterator begin(){
+ return boost::begin( this->impl );
}
- iterator end(){
- return boost::end( this->impl );
+ iterator end(){
+ return boost::end( this->impl );
}
- const_iterator begin()const{
- return boost::begin( this->impl );
+ const_iterator begin()const{
+ return boost::begin( this->impl );
}
- const_iterator end()const{
- return boost::end( this->impl );
+ const_iterator end()const{
+ return boost::end( this->impl );
}
typedef typename impl_::reference reference;
typedef typename impl_::const_reference const_reference;
typedef typename impl_::difference_type difference_type;
- size_type size()const{
- return this->unwrap().size();
+ size_type size()const{
+ return this->unwrap().size();
}
- size_type max_size()const{
- return this->unwrap().max_size();
+ size_type max_size()const{
+ return this->unwrap().max_size();
}
- bool empty()const{
- return this->unwrap().empty();
+ bool empty()const{
+ return this->unwrap().empty();
}
- reference operator[](size_type n){
- return this->unwrap()[n];
+ reference operator[](size_type n){
+ return this->unwrap()[n];
}
- const_reference operator[](size_type n)const{
- return this->unwrap()[n];
+ const_reference operator[](size_type n)const{
+ return this->unwrap()[n];
}
- reference front(){
- return this->unwrap().front();
+ reference front(){
+ return this->unwrap().front();
}
- const_reference front()const{
- return this->unwrap().front();
+ const_reference front()const{
+ return this->unwrap().front();
}
- reference back(){
- return this->unwrap().back();
+ reference back(){
+ return this->unwrap().back();
}
- const_reference back()const{
- return this->unwrap().back();
+ const_reference back()const{
+ return this->unwrap().back();
}
- void pop_front(){
- this->unwrap().pop_front();
+ void pop_front(){
+ this->unwrap().pop_front();
}
- void pop_back(){
- this->unwrap().pop_back();
+ void pop_back(){
+ this->unwrap().pop_back();
}
- void swap(cont& that){
- this->unwrap().swap( that.unwrap() );
+ void swap(cont& that){
+ this->unwrap().swap( that.unwrap() );
}
- // Note : the modifiers such as push_back() are ommitted as they
+ // Note : the modifiers such as push_back() are ommitted as they
// accessible through the put interface.
// Convert
@@ -162,24 +163,24 @@
BOOST_ASSIGN_V2_CONVERT_OPERATOR_MF
impl_& unwrap()const{ return this->impl; }
-
+
// Relational op
template<typename R>
bool equal_to(const R& r)const{
- return ::boost::iterator_range_detail::equal(
+ return ::boost::iterator_range_detail::equal(
(*this), r );
}
template<typename R>
bool less_than(const R& r)const{
- return ::boost::iterator_range_detail::less_than(
+ return ::boost::iterator_range_detail::less_than(
(*this), r );
}
protected:
mutable impl_ impl;
-
+
};
}// anon_aux
@@ -187,4 +188,4 @@
}// assign
}// boost
-#endif
\ No newline at end of file
+#endif
Modified: sandbox/statistics/support/boost/assign/v2/anon/csv.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/anon/csv.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/anon/csv.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -45,14 +45,14 @@
}//csv_anon_aux
- template<typename T,typename...Args>
+ template<typename T,typename... Args>
typename result_of::anon<T>::type
// implicit conversion to T desired
- csv_anon(T const& t, Args&&...args)
+ csv_anon(const T& t, Args const& ... args)
{
typedef typename result_of::anon<T>::type result_;
result_ result = anon<T>( v2::_nil );
- csv_anon_aux::impl<T>(result, std::forward<Args>(args)...);
+ csv_anon_aux::impl<T>(result, t, args...);
return result;
}
Modified: sandbox/statistics/support/boost/assign/v2/chain/aux_/bitwise_or.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/chain/aux_/bitwise_or.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/chain/aux_/bitwise_or.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -59,21 +59,21 @@
}// chain_aux
-//#define BOOST_ASSIGN_V2_FRAMEWORK_CHAIN(U1, U2) \
-// template<typename Tag,typename R1,typename R2> \
-// typename chain_aux::result<U1, U2, Tag>::type \
-// chain(U1 & r1, U2 & r2) \
-// { \
-// return r1 | adaptor::_chain( r2 ); \
-// } \
-//\
-///**/
+/*#define MACRO(U1, U2) \
+ template<typename Tag,typename R1,typename R2> \
+ typename chain_aux::result<U1, U2, Tag>::type \
+ chain(U1 & r1, U2 & r2) \
+ { \
+ return r1 | adaptor::_chain( r2 ); \
+ } \
+\
+MACRO(R1 , R2 )
+MACRO(R1 , R2 const )
+MACRO(R1 const, R2 )
+MACRO(R1 const, R2 const )
+#undef MACRO
+*/
-//BOOST_ASSIGN_V2_FRAMEWORK_CHAIN(R1 , R2 )
-//BOOST_ASSIGN_V2_FRAMEWORK_CHAIN(R1 , R2 const )
-//BOOST_ASSIGN_V2_FRAMEWORK_CHAIN(R1 const, R2 )
-//BOOST_ASSIGN_V2_FRAMEWORK_CHAIN(R1 const, R2 const )
-//#undef BOOST_ASSIGN_V2_FRAMEWORK_CHAIN
}// v2
}// assign
Modified: sandbox/statistics/support/boost/assign/v2/put/compose/functor/composer.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/put/compose/functor/composer.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/put/compose/functor/composer.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -13,6 +13,7 @@
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/transform.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/vector/vector0.hpp>
#include <boost/mpl/vector/vector10.hpp>
@@ -29,6 +30,8 @@
#include <boost/assign/v2/detail/config/enable_cpp0x.hpp>
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
#include <utility>
+#include <boost/assign/v2/ref/wrapper/cpp0x.hpp>
+#include <boost/mpl/detail/variadic_vector.hpp>
#else
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/cat.hpp>
@@ -62,6 +65,7 @@
template<typename Pars, typename SeqArgs, bool enable_pars>
struct composer_result
{
+
template<typename Args>
struct apply
{
@@ -71,6 +75,7 @@
>::type new_;
typedef composer<Pars, new_> type;
};
+
};
@@ -105,7 +110,10 @@
static_sequence_args_size = boost::mpl::size<SeqArgs>::value
);
- typedef typename boost::mpl::apply1<meta1_, Pars>::type pars_cont_type;
+ typedef typename boost::mpl::apply1<
+ meta1_,
+ Pars
+ >::type pars_cont_type;
typedef typename boost::mpl::apply1<
meta2_,
SeqArgs
@@ -119,6 +127,8 @@
: pars_cont( p ),
seq_args_cont( s ){}
+ // operator%
+
template<typename T>
struct modulo_result
{
@@ -140,52 +150,67 @@
return result_( this->pars_cont( t ), this->seq_args_cont );
}
- template<typename Args>
+ // operator()
+
+ template<typename VecArg>
struct result : boost::mpl::apply1<
composer_result<Pars, SeqArgs, enable_pars>,
- Args
- >
- {};
+ VecArg
+ >{};
- typename result<
- boost::mpl::vector0<>
- >::type
- operator()()const
- {
- typedef boost::mpl::vector0<> args_;
- typedef typename result<args_>::type result_;
- return result_( this->pars_cont, this->seq_args_cont() );
- }
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ protected:
+ template<typename ...RArgs>
+ struct cpp0x_traits
+ {
+ typedef typename boost::mpl::detail::variadic_vector<
+ RArgs...
+ >::type refs_;
+ typedef typename boost::mpl::transform<
+ refs_,
+ ref::wrapper_param<boost::mpl::_>
+ >::type wrapper_params_;
+ typedef typename result<wrapper_params_>::type result_type;
+ };
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ public:
-/*
- template<typename U, typename ...Args>
- typename result<
- boost::mpl::vector<XXX>
- >::type
- operator()( U&& u, Args&&...args )const{
- typedef boost::mpl::vector<XXX> args_;
- typedef typename result<args_>::type result_;
+ template<typename ...RArgs>
+ typename cpp0x_traits<RArgs...>::result_type
+ operator()(RArgs&&...args )const
+ {
+ typedef typename cpp0x_traits<RArgs...>::result_type result_;
return result_(
- this->pars_cont,
+ this->pars_cont,
this->seq_args_cont(
- std::forward<U>( u ),
- std::forward<Args>( args )...
+ std::forward<RArgs>( args )...
)
);
}
-*/
#else
+ protected:
+
typedef functor_aux::crtp_unary_and_up<
composer,
composer_result<Pars, SeqArgs, enable_pars>
> super_t;
- using super_t::operator();
+ public:
+
+ typename result<
+ boost::mpl::vector0<>
+ >::type
+ operator()()const
+ {
+ typedef boost::mpl::vector0<> args_;
+ typedef typename result<args_>::type result_;
+ return result_( this->pars_cont, this->seq_args_cont() );
+ }
+
+ using super_t::operator();
#define MACRO1( z, n, data ) \
( BOOST_PP_CAT(_,n) ) \
Modified: sandbox/statistics/support/boost/assign/v2/put/compose/functor/forward_args.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/put/compose/functor/forward_args.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/put/compose/functor/forward_args.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -9,6 +9,19 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_V2_PUT_COMPOSE_FORWARD_ARGS_ER_2010_HPP
#define BOOST_ASSIGN_V2_PUT_COMPOSE_FORWARD_ARGS_ER_2010_HPP
+#include <cstddef> // std::size_t
+#include <boost/mpl/int.hpp>
+
+#include <boost/assign/v2/ref/fusion_matrix/container.hpp>
+#include <boost/assign/v2/ref/wrapper/framework.hpp>
+#include <boost/assign/v2/ref/wrapper/copy.hpp>
+
+#include <boost/assign/v2/detail/config/enable_cpp0x.hpp>
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+#include <utility>
+// TODO eventually replace by mpl/variadic_template/package_range_c.hpp>
+#include <boost/mpl/detail/variadic_args_to_indices.hpp>
+#else
#include <boost/preprocessor/arithmetic/inc.hpp>
#include <boost/preprocessor/control/expr_if.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
@@ -16,15 +29,9 @@
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
-
#include <boost/mpl/aux_/na.hpp>
-#include <boost/mpl/int.hpp>
-
-//#include <boost/assign/v2/detail/keyword/default.hpp>
#include <boost/assign/v2/detail/config/limit_arity.hpp>
-#include <boost/assign/v2/ref/fusion_matrix/container.hpp>
-#include <boost/assign/v2/ref/wrapper/framework.hpp>
-#include <boost/assign/v2/ref/wrapper/copy.hpp>
+#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
namespace boost{
namespace assign{
@@ -33,56 +40,147 @@
template<
std::size_t N, typename L,typename Tag1, typename Tag2,
- BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
- BOOST_ASSIGN_V2_LIMIT_ARITY,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ typename... Args
+#else
+ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
+ BOOST_ASSIGN_V2_LIMIT_ARITY,
typename T,
boost::mpl::na
)
+#endif
>
class args : ref::wrapper<
ref::assign_tag::copy,
ref::fusion_matrix_aux::container<N, L, Tag1, Tag2,
- BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
+ BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
> const
>
{
- typedef ref::fusion_matrix_aux::container<N, L, Tag1, Tag2,
+ typedef ref::fusion_matrix_aux::container<N, L, Tag1, Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
> value_;
typedef ref::assign_tag::copy assign_tag_;
typedef ref::wrapper<assign_tag_, value_ const> super_t;
-
+
public:
-
+ typedef value_ value_type;
+
args(){};
-
+
args(value_ const& v) : super_t( v ){}
value_ const& value()const{ return this->unwrap(); }
-
+
};
template<
std::size_t N, typename L,typename Tag1, typename Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ typename...Args
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, typename T)
+#endif
>
- args<N, L, Tag1, Tag2,
+ args<N, L, Tag1, Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
>
make_args(
- ref::fusion_matrix_aux::container<N,L,Tag1, Tag2,
+ ref::fusion_matrix_aux::container<N,L,Tag1, Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
> const& v
){
- typedef args<N,L,Tag1, Tag2,
+ typedef args<N,L,Tag1, Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
> result_;
return result_( v );
}
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+
+ template<typename Input, typename I>
+ struct forward_args_helper
+ {
+
+ typedef Input input_;
+ typedef typename input_::value_type value_;
+ template<I Value>
+ struct elem
+ : value_::template static_elem_result<Value>{};
+
+ template<I Value>
+ static typename elem<Value>::type
+ fetch(Input const& input)
+ {
+ typedef boost::mpl::int_<Value> int_;
+ return input.value().static_elem( int_() );
+ };
+
+ template<typename O,typename V, V... Values>
+ static O const& forward(
+ O const& object,
+ Input const& input,
+ ::boost::mpl::er2010::indices<V, Values...>
+ )
+ {
+ return object(
+ fetch<Values>( input )...
+ );
+ }
+
+ };
+
+ template<
+ typename O,
+ std::size_t N, typename L,typename Tag1, typename Tag2,
+ typename...Args
+ >
+ O const&
+ forward_args(
+ O const& object,
+ put_compose_aux::args<N, L, Tag1, Tag2, Args...> const& input
+ )
+ {
+ typedef put_compose_aux::args<N, L, Tag1, Tag2, Args...> input_;
+
+ typedef std::size_t int_;
+ typedef typename ::boost::mpl::er2010::args_to_indices<
+ int_,
+ Args...
+ >::type indices_;
+ typedef forward_args_helper<input_, int_> caller_;
+ return caller_::forward(
+ object,
+ input,
+ indices_()
+ );
+ }
+
+#else
+
#define MACRO1(z, n, data) \
BOOST_PP_COMMA_IF(n)\
- input.value().static_column(\
+ input.value().static_elem(\
boost::mpl::int_<n>()\
)\
/**/
@@ -107,7 +205,7 @@
}\
/**/
-
+
BOOST_PP_REPEAT(
BOOST_PP_INC(BOOST_ASSIGN_V2_LIMIT_ARITY),
MACRO2,
@@ -117,6 +215,8 @@
#undef MACRO1
#undef MACRO2
+#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
+
}// put_compose_aux
}// v2
}// assign
Modified: sandbox/statistics/support/boost/assign/v2/ref/anon/csv/assign_xxx.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/ref/anon/csv/assign_xxx.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/ref/anon/csv/assign_xxx.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -65,15 +65,15 @@
#endif // BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_M
-#ifndef BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_2(NS, TAG)
+#ifndef BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_2
#define BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_2(NS, TAG)\
namespace boost{ \
namespace assign{ \
namespace v2{ \
namespace ref{ \
namespace NS{ \
-BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_M(NS, TAG, T, Args)\
-BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_M(NS, TAG, T const, Args const)\
+BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_M(NS, TAG, T , Args)\
+BOOST_ASSIGN_V2_REF_ANON_CSV_ASSIGN_XXX_M(NS, TAG, T const , Args const)\
} \
} \
} \
Modified: sandbox/statistics/support/boost/assign/v2/ref/fusion/link_holder.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/ref/fusion/link_holder.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/ref/fusion/link_holder.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -21,23 +21,24 @@
template<typename L, bool is_empty = false>
class link_holder{
-
+
typedef ref::assign_tag::copy tag_;
typedef ref::wrapper<tag_, const L> wrapper_;
-
+
public:
-
+
link_holder(){}
link_holder( const L& l) : value( l ){}
-
+
wrapper_ pop()const
{
// Warning : probably inefficient
return value;
}
-
- const L& link()const{ return this->value.unwrap(); }
-
+
+ typedef typename wrapper_::unwrap_type link_type;
+ link_type link()const{ return this->value.unwrap(); }
+
protected:
mutable wrapper_ value;
@@ -45,11 +46,11 @@
template<typename L>
class link_holder<L,true>{
-
+
//link_holder(){}
-
+
void pop()const{}
-
+
};
}// fusion_aux
Modified: sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/container.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/container.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/container.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -9,9 +9,12 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_V2_REF_FUSION_MATRIX_CONTAINER_ER_2010_HPP
#define BOOST_ASSIGN_V2_REF_FUSION_MATRIX_CONTAINER_ER_2010_HPP
+#include <cstddef> // std::size_t
+
#include <boost/mpl/apply.hpp>
#include <boost/mpl/unpack_args.hpp>
-//#include <boost/mpl/aux_/na.hpp>
+#include <boost/mpl/aux_/na.hpp>
+#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/minus.hpp>
#include <boost/mpl/size.hpp>
@@ -26,9 +29,9 @@
#include <boost/assign/v2/detail/config/enable_cpp0x.hpp>
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
#include <utility>
-
+#include <tuple>
+//#include <boost/mpl/detail/variadic_vector.hpp> // TODO remove
#else
-
#include <boost/preprocessor/arithmetic/dec.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/punctuation/comma.hpp>
@@ -42,14 +45,18 @@
#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
-#include <boost/mpl/aux_/na.hpp>
-#include <boost/mpl/eval_if.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/assign/v2/detail/config/limit_arity.hpp>
#include <boost/assign/v2/detail/functor/crtp_unary_and_up.hpp>
#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
+//#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+// for testing purposes only.
+//#include <iostream> // remove
+//#include <boost/tuple/detail/print_tuple.hpp>
+//#endif
+
namespace boost{
struct use_default;
namespace assign{
@@ -57,52 +64,39 @@
namespace ref{
namespace fusion_matrix_aux{
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+
template<
std::size_t N, typename L, typename Tag1, typename Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
typename...Args
- >
- struct meta_result{
-
- typedef fusion_matrix_aux::container<N, L, Tag1, Tag2,
- Args...> this_;
-
- template<typename ... NewArgs>
- struct apply
- {
-
- typedef fusion_matrix_aux::container<
- N + 1,
- this_,
- Tag1,
- Tag2,
- typename wrapper_param<NewArgs>::type...
- > type;
-
- };
-
- };
#else
- template<
- std::size_t N, typename L, typename Tag1, typename Tag2,
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
BOOST_ASSIGN_V2_LIMIT_ARITY,
typename T,
boost::mpl::na
)
+#endif
>
struct meta_result{
typedef fusion_matrix_aux::container<N, L, Tag1, Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+#endif
> this_;
template<
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ typename ... NewArgs
+#else
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
BOOST_ASSIGN_V2_LIMIT_ARITY,
typename U,
boost::mpl::na
)
+#endif
>
struct apply
{
@@ -112,22 +106,24 @@
this_,
Tag1,
Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ NewArgs...
+#else
BOOST_PP_ENUM_PARAMS(
BOOST_ASSIGN_V2_LIMIT_ARITY,
U
)
+#endif
> type;
- };
+ }; // apply
- };
-
-#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
+ }; // meta_result
template<
std::size_t N, typename L, typename Tag1, typename Tag2,
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
- typename... Args
+ typename... Args
#else
BOOST_PP_ENUM_PARAMS(
BOOST_ASSIGN_V2_LIMIT_ARITY,
@@ -158,15 +154,15 @@
>
#endif
{
-
- typedef boost::mpl::int_<0> int0_;
- typedef boost::mpl::int_<1> int1_;
- typedef boost::mpl::int_<N> size_;
- typedef typename boost::mpl::minus<size_,int1_>::type index_;
typedef Tag1 assign_tag_;
template<typename T>
- struct wrapper{ typedef ref::wrapper<assign_tag_,T> type; };
+ struct wrapper{
+ typedef ref::wrapper<
+ assign_tag_,
+ T
+ > type;
+ };
typedef fusion_aux::link_holder<L, N == 0> link_;
@@ -182,15 +178,17 @@
> meta_result_;
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
-// do nothing
+ typedef std::tuple<
+ // typename wrapper<Args>::type... // TODO, instead
+ ref::wrapper<
+ assign_tag_,
+ Args
+ > ...
+ > tuple_;
#else
typedef boost::mpl::na na_;
typedef boost::tuples::null_type null_;
- typedef boost::mpl::vector<
- BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
- > vec_;
-
template<typename T>
struct tuple_elem : boost::mpl::eval_if<
boost::is_same<T, na_>,
@@ -198,7 +196,6 @@
wrapper<T>
>{};
-
#define MACRO(z, n, data) typename tuple_elem<BOOST_PP_CAT(T,n)>::type
typedef boost::tuples::tuple<
@@ -210,36 +207,50 @@
> tuple_;
#undef MACRO
-#endif
+#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
tuple_ tuple;
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+// TODO remove
+// typedef typename boost::mpl::detail::variadic_vector<
+// Args...
+// >::type
+// vector_args_type;
+#else
+ typedef boost::mpl::vector<
+ BOOST_PP_ENUM_PARAMS(BOOST_ASSIGN_V2_LIMIT_ARITY, T)
+ >
+ vector_args_type;
+#endif
+
public:
typedef std::size_t size_type;
BOOST_STATIC_CONSTANT(size_type, static_row_size = N);
BOOST_STATIC_CONSTANT(size_type,
- static_column_size =
+ static_elem_size =
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
sizeof...(Args)
#else
- boost::mpl::size<vec_>::value
+ boost::mpl::size<vector_args_type>::value
#endif
);
+
container(){}
#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+
explicit container(
const L& l, Args&...args
- ) : link_( l ), tuple( ref::wrap<assign_tag_>(args)... )
-
-// w... = args...
+ ) : link_( l ),
+ tuple(
+ ref::wrap<assign_tag_>( args )...
+ )
{}
#else
-//#define MACRO1(z, n, data)\
-// BOOST_PP_CAT(w, n) ( BOOST_PP_CAT(_, n) )\
-/**/
+
#define MACRO1(z, n, data) ref::wrap<assign_tag_>( BOOST_PP_CAT(data, n) )
#define MACRO(z, n, data) \
explicit container( \
@@ -250,27 +261,52 @@
{}\
/**/
-//#define MACRO2(z, n, data) \
-// explicit container( \
-// const L& l BOOST_PP_COMMA_IF(n) \
-// BOOST_PP_ENUM_BINARY_PARAMS(n, T, & _) \
-// ) : link_( l )\
-// BOOST_PP_ENUM_TRAILING(n, MACRO1, ~)\
-// {}\
-/**/
BOOST_PP_REPEAT(
BOOST_ASSIGN_V2_LIMIT_ARITY,
MACRO,
~
)
#undef MACRO1
-//#undef MACRO2
#undef MACRO
-#endif
+#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
+
// ------ operator() ----- //
- // adds a row //
+ // adds a row //
// ----------------------- //
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+
+ template<typename... NewArgs>
+ struct result : meta_result_::template apply<
+ NewArgs...
+ >{};
+
+ template<typename...NewRArgs>
+ struct cpp0x_traits
+ {
+ typedef result<
+ typename ref::wrapper_param<NewRArgs>::type...
+ > mf_;
+
+ typedef typename mf_::type result_type;
+
+ };
+
+ template<typename...NewRArgs>
+ typename cpp0x_traits<NewRArgs...>::result_type
+ operator()( NewRArgs&&...args )const
+ {
+ typedef typename cpp0x_traits<
+ NewRArgs...
+ >::result_type result_type;
+ return result_type(
+ *this,
+ std::forward<NewRArgs>( args )...
+ );
+ }
+
+#else
+
template<
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
BOOST_PP_INC(BOOST_ASSIGN_V2_LIMIT_ARITY),
@@ -279,7 +315,7 @@
)
>
struct result : boost::mpl::apply<
- meta_result_,
+ meta_result_,
BOOST_PP_ENUM_PARAMS(
BOOST_ASSIGN_V2_LIMIT_ARITY,
U
@@ -292,37 +328,16 @@
return result_( *this );
}
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
-
protected:
- template<typename ... Args>
- struct cpp0x_helper
- {
- typedef typename boost::mpl::detail::variadic_vector<
- Args...
- >::type args_;
-
- typedef typename boost::mpl::transform<
- args_,
- wrapper_param<boost::mpl::_>
- >::type params_;
-
- typedef typename boost::mpl::apply<
- meta_result_,
-
- >::type result_;
-
- };
-
-
-#else
typedef functor_aux::crtp_unary_and_up<
container,
boost::mpl::unpack_args<
meta_result_
>
> super_t;
+
+ public:
using super_t::operator();
#define MACRO1( z, n, data ) \
@@ -333,7 +348,9 @@
template<BOOST_PP_ENUM_PARAMS(N1, typename U)> \
typename result<BOOST_PP_ENUM_PARAMS(N1, U)>::type \
impl( BOOST_PP_ENUM_BINARY_PARAMS(N1, U, &_) )const{ \
- typedef typename result<BOOST_PP_ENUM_PARAMS(N1, U)>::type result_; \
+ typedef typename result<\
+ BOOST_PP_ENUM_PARAMS(N1, U)\
+ >::type result_; \
return result_( *this BOOST_PP_ENUM_TRAILING_PARAMS(N1, _) );\
} \
/**/
@@ -354,22 +371,22 @@
struct is_head : boost::mpl::bool_< I + 1 == N >{};
template<int I>
- struct link_result_static_row
- : L::template result_static_row<I>{};
+ struct link_static_row_result
+ : L::template static_row_result<I>{};
template<int I>
- struct result_static_row : boost::mpl::eval_if<
+ struct static_row_result : boost::mpl::eval_if<
is_head<I>,
boost::mpl::identity<
container const&
>,
- link_result_static_row<I>
+ link_static_row_result<I>
>{};
template<int I>
typename boost::lazy_enable_if<
is_head<I>,
- result_static_row<I>
+ static_row_result<I>
>::type
static_row(boost::mpl::int_<I> index)const
{
@@ -379,25 +396,25 @@
template<int I>
typename boost::lazy_disable_if<
is_head<I>,
- result_static_row<I>
+ static_row_result<I>
>::type
static_row( boost::mpl::int_<I> index )const
{
- return static_cast<link_ const&>(
- *this
- ).link().static_row( index );
+ return this->link().static_row( index );
}
// Column extraction
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
-// TODO
-#else
-
template<int n>
- struct static_column_result
+ struct static_elem_result
{
- typedef typename boost::tuples::element<
+ typedef typename
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ std::tuple_element
+#else
+ boost::tuples::element
+#endif
+ <
n,
tuple_
>::type wrapper_;
@@ -405,33 +422,18 @@
};
template<int n>
- typename static_column_result<n>::type
- static_column( boost::mpl::int_<n> )const
+ typename static_elem_result<n>::type
+ static_elem( boost::mpl::int_<n> )const
{
- return boost::get<n>( this->tuple ).unwrap();
- }
-// TODO remove
-// Prior to 11/2010:
-/*
-#define MACRO(z, n, data)\
- private: \
- typename wrapper<BOOST_PP_CAT(T,n)>::type BOOST_PP_CAT(w,n); \
- public: \
- BOOST_PP_CAT(T,n)& static_column(boost::mpl::int_<n>)const\
- {\
- return this->BOOST_PP_CAT(w,n).unwrap(); \
- }\
-BOOST_PP_REPEAT(
- BOOST_ASSIGN_V2_LIMIT_ARITY,
- MACRO,
- ~
-)
-#undef MACRO
-*/
-/**/
-
-#endif // BOOST_ASSIGN_V2_ENABLE_CPP0X
+ return
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ std::
+#else
+ boost::
+#endif
+ get<n>( this->tuple ).unwrap();
+ }
};
Modified: sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/fwd.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/fwd.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/fwd.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -25,26 +25,19 @@
namespace ref{
namespace fusion_matrix_aux{
-#if BOOST_ASSIGN_V2_ENABLE_CPP0X
-
template<
std::size_t N, typename L,typename Tag1, typename Tag2,
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
typename...Args
- >
- class container;
-
#else
-
- template<
- std::size_t N, typename L,typename Tag1, typename Tag2,
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
BOOST_ASSIGN_V2_LIMIT_ARITY,
typename T,
boost::mpl::na
)
+#endif
>
class container;
-#endif
}// fusion_matrix_aux
}// ref
Modified: sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/nth_result_of.hpp
==============================================================================
--- sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/nth_result_of.hpp (original)
+++ sandbox/statistics/support/boost/assign/v2/ref/fusion_matrix/nth_result_of.hpp 2010-11-21 22:09:06 EST (Sun, 21 Nov 2010)
@@ -9,10 +9,6 @@
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_V2_REF_FUSION_MATRIX_NTH_RESULT_OF_ER_2010_HPP
#define BOOST_ASSIGN_V2_REF_FUSION_MATRIX_NTH_RESULT_OF_ER_2010_HPP
-#include <boost/preprocessor/arithmetic/dec.hpp>
-#include <boost/preprocessor/repetition/enum_trailing.hpp>
-#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
-
#include <boost/mpl/apply.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/aux_/na.hpp>
@@ -28,9 +24,16 @@
#include <boost/assign/v2/ref/fusion_matrix/fwd.hpp>
#include <boost/assign/v2/ref/wrapper/copy.hpp>
+#include <boost/assign/v2/detail/config/enable_cpp0x.hpp>
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+// do nothing
+#else
+#include <boost/preprocessor/arithmetic/dec.hpp>
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
+#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
#include <boost/mpl/aux_/na.hpp>
#include <boost/assign/v2/detail/config/limit_arity.hpp>
-
+#endif
namespace boost{
struct use_default;
@@ -40,13 +43,13 @@
namespace fusion_matrix_aux{
template<
- typename Tag1 = ref::assign_tag::copy,
+ typename Tag1 = ref::assign_tag::copy,
typename Tag2 = boost::use_default
>
struct empty
{
typedef fusion_matrix_aux::container<
- 0,
+ 0,
typename fusion_aux::root_type,
Tag1,
Tag2
@@ -57,56 +60,67 @@
struct nth_result
{
- typedef typename fusion_matrix_aux::empty<Tag1, Tag2>::type state_;
+ typedef typename fusion_matrix_aux::empty<
+ Tag1,
+ Tag2
+ >::type state_;
template<typename NewState>
struct result
{
template<
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ typename...Args
+#else
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
BOOST_ASSIGN_V2_LIMIT_ARITY,
typename T,
boost::mpl::na
- )
+ )
+#endif
>
struct apply : NewState::template result<
+#if BOOST_ASSIGN_V2_ENABLE_CPP0X
+ Args...
+#else
BOOST_PP_ENUM_PARAMS(
BOOST_ASSIGN_V2_LIMIT_ARITY,
T
)
+#endif
>{};
-
- };
+
+ };
struct forward_op{
-
+
template<typename NewState, typename Vec>
struct apply{
typedef result<NewState> meta_;
typedef boost::mpl::unpack_args< meta_ > g_;
typedef typename boost::mpl::apply1<
- g_,
+ g_,
Vec
>::type type;
-
+
};
};
template<typename VecTypes>
struct apply : boost::mpl::fold<
- VecTypes,
+ VecTypes,
state_,
forward_op
>{};
};
-
+
}// fusion_matrix_aux
namespace nth_result_of{
template<
- typename Tag1 = ref::assign_tag::copy,
+ typename Tag1 = ref::assign_tag::copy,
typename Tag2 = boost::use_default
>
struct fusion_matrix
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