From a046e4399068ab28267848f63e04c01f289829e0 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Fri, 10 Oct 2008 14:49:19 +0000 Subject: [PATCH] Merge from Trunk [SVN r49251] --- .../fusion/container/list/detail/at_impl.hpp | 85 +++++++++++++++---- .../fusion/functional/invocation/invoke.hpp | 28 +++--- .../invocation/invoke_function_object.hpp | 24 +++--- .../invocation/invoke_procedure.hpp | 12 +-- include/boost/fusion/include/at_c.hpp | 12 +++ include/boost/fusion/include/end.hpp | 4 +- .../boost/fusion/sequence/intrinsic/at_c.hpp | 13 +++ ...uple_forward_ctor.hpp => tuple_expand.hpp} | 19 ++++- include/boost/fusion/tuple/tuple.hpp | 38 ++++++--- 9 files changed, 170 insertions(+), 65 deletions(-) create mode 100644 include/boost/fusion/include/at_c.hpp create mode 100644 include/boost/fusion/sequence/intrinsic/at_c.hpp rename include/boost/fusion/tuple/detail/{tuple_forward_ctor.hpp => tuple_expand.hpp} (70%) diff --git a/include/boost/fusion/container/list/detail/at_impl.hpp b/include/boost/fusion/container/list/detail/at_impl.hpp index 54ba6bb8..4dee15dc 100644 --- a/include/boost/fusion/container/list/detail/at_impl.hpp +++ b/include/boost/fusion/container/list/detail/at_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under 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) ==============================================================================*/ #if !defined(FUSION_AT_IMPL_07172005_0726) @@ -15,6 +15,71 @@ namespace boost { namespace fusion { + namespace detail + { + template + struct cons_deref + { + typedef typename Cons::car_type type; + }; + + template + struct cons_advance + { + typedef typename + cons_advance::type::cdr_type + type; + }; + + template + struct cons_advance + { + typedef Cons type; + }; + + template + struct cons_advance + { + typedef typename Cons::cdr_type type; + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type type; +#endif + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type _b; + typedef typename _b::cdr_type type; +#endif + }; + + template + struct cons_advance + { +#if BOOST_WORKAROUND(BOOST_MSVC, > 1400) // VC8 and above + typedef typename Cons::cdr_type::cdr_type::cdr_type::cdr_type type; +#else + typedef typename Cons::cdr_type _a; + typedef typename _a::cdr_type _b; + typedef typename _b::cdr_type _c; + typedef typename _c::cdr_type type; +#endif + }; + } + struct cons_tag; namespace extension @@ -26,22 +91,10 @@ namespace boost { namespace fusion struct at_impl { template - struct apply + struct apply { - typedef typename - mpl::eval_if< - is_const - , add_const - , mpl::identity - >::type - cdr_type; - - typedef typename - mpl::eval_if< - mpl::bool_ - , mpl::identity - , apply > - > + typedef detail::cons_deref< + typename detail::cons_advance::type> element; typedef typename diff --git a/include/boost/fusion/functional/invocation/invoke.hpp b/include/boost/fusion/functional/invocation/invoke.hpp index bac695cc..f021d923 100644 --- a/include/boost/fusion/functional/invocation/invoke.hpp +++ b/include/boost/fusion/functional/invocation/invoke.hpp @@ -1,8 +1,8 @@ /*============================================================================= - Copyright (c) 2005-2006 João Abecasis + Copyright (c) 2005-2006 Joao Abecasis Copyright (c) 2006-2007 Tobias Schwinger - - Use modification and distribution are subject to the Boost Software + + 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). ==============================================================================*/ @@ -71,21 +71,21 @@ namespace boost { namespace fusion { namespace ft = function_types; - template< - typename Function, class Sequence, + template< + typename Function, class Sequence, int N = result_of::size::value, bool CBI = ft::is_callable_builtin::value, bool RandomAccess = traits::is_random_access::value > struct invoke_impl; - template + template struct invoke_param_types; template struct invoke_data_member; - template + template struct invoke_mem_fn; #define BOOST_PP_FILENAME_1 @@ -116,7 +116,7 @@ namespace boost { namespace fusion invoke_mem_fn, invoke_data_member >, mpl::identity< invoke_nonmember_builtin< - Function,Sequence,1,RandomAccess> > + Function,Sequence,1,RandomAccess> > >::type { }; @@ -139,7 +139,7 @@ namespace boost { namespace fusion public: - typedef typename boost::add_reference::type + typedef typename boost::add_reference::type result_type; static inline result_type call(T C::* f, Sequence & s) @@ -154,10 +154,10 @@ namespace boost { namespace fusion { template struct invoke { - typedef typename detail::invoke_impl< + typedef typename detail::invoke_impl< typename boost::remove_reference::type, Sequence >::result_type type; - }; + }; } template @@ -242,7 +242,7 @@ namespace boost { namespace fusion public: typedef typename boost::result_of< - Function(BOOST_PP_ENUM_PARAMS(N,typename seq::T)) + Function(BOOST_PP_ENUM_PARAMS(N,typename seq::T)) >::type result_type; template @@ -274,7 +274,7 @@ namespace boost { namespace fusion typename seq::I0 i0 = fusion::begin(s); BOOST_PP_REPEAT_FROM_TO(1,N,M,~) - return (that_ptr< typename mpl::front< + return (that_ptr< typename mpl::front< ft::parameter_types >::type >::get(*i0)->*f)(BOOST_PP_ENUM_SHIFTED_PARAMS(N,*i)); } @@ -302,5 +302,5 @@ namespace boost { namespace fusion #undef N #endif // defined(BOOST_PP_IS_ITERATING) -#endif +#endif diff --git a/include/boost/fusion/functional/invocation/invoke_function_object.hpp b/include/boost/fusion/functional/invocation/invoke_function_object.hpp index f0f6e4eb..24c02c2b 100644 --- a/include/boost/fusion/functional/invocation/invoke_function_object.hpp +++ b/include/boost/fusion/functional/invocation/invoke_function_object.hpp @@ -1,8 +1,8 @@ /*============================================================================= - Copyright (c) 2005-2006 João Abecasis + Copyright (c) 2005-2006 Joao Abecasis Copyright (c) 2006-2007 Tobias Schwinger - - Use modification and distribution are subject to the Boost Software + + 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). ==============================================================================*/ @@ -51,14 +51,14 @@ namespace boost { namespace fusion namespace detail { - template< - class Function, class Sequence, + template< + class Function, class Sequence, int N = result_of::size::value, - bool RandomAccess = traits::is_random_access::value + bool RandomAccess = traits::is_random_access::value > struct invoke_function_object_impl; - template + template struct invoke_function_object_param_types; #define BOOST_PP_FILENAME_1 \ @@ -72,10 +72,10 @@ namespace boost { namespace fusion { template struct invoke_function_object { - typedef typename detail::invoke_function_object_impl< + typedef typename detail::invoke_function_object_impl< typename boost::remove_reference::type, Sequence >::result_type type; - }; + }; } template @@ -114,7 +114,7 @@ namespace boost { namespace fusion typedef typename boost::result_of< #define M(z,j,data) \ - typename result_of::at_c::type + typename result_of::at_c::type Function (BOOST_PP_ENUM(N,M,~)) >::type result_type; #undef M @@ -154,7 +154,7 @@ namespace boost { namespace fusion } }; - template + template struct invoke_function_object_param_types { #if N > 0 @@ -173,5 +173,5 @@ namespace boost { namespace fusion #undef N #endif // defined(BOOST_PP_IS_ITERATING) -#endif +#endif diff --git a/include/boost/fusion/functional/invocation/invoke_procedure.hpp b/include/boost/fusion/functional/invocation/invoke_procedure.hpp index 31822ade..502b38aa 100644 --- a/include/boost/fusion/functional/invocation/invoke_procedure.hpp +++ b/include/boost/fusion/functional/invocation/invoke_procedure.hpp @@ -1,8 +1,8 @@ /*============================================================================= - Copyright (c) 2005-2006 João Abecasis + Copyright (c) 2005-2006 Joao Abecasis Copyright (c) 2006-2007 Tobias Schwinger - - Use modification and distribution are subject to the Boost Software + + 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). ==============================================================================*/ @@ -58,8 +58,8 @@ namespace boost { namespace fusion { namespace ft = function_types; - template< - typename Function, class Sequence, + template< + typename Function, class Sequence, int N = result_of::size::value, bool MFP = ft::is_member_function_pointer::value, bool RandomAccess = traits::is_random_access::value @@ -167,5 +167,5 @@ namespace boost { namespace fusion #undef N #endif // defined(BOOST_PP_IS_ITERATING) -#endif +#endif diff --git a/include/boost/fusion/include/at_c.hpp b/include/boost/fusion/include/at_c.hpp new file mode 100644 index 00000000..a2403d16 --- /dev/null +++ b/include/boost/fusion/include/at_c.hpp @@ -0,0 +1,12 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + Distributed under 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) +==============================================================================*/ +#if !defined(FUSION_INCLUDE_AT_C) +#define FUSION_INCLUDE_AT_C + +#include + +#endif diff --git a/include/boost/fusion/include/end.hpp b/include/boost/fusion/include/end.hpp index 60be1a98..61d65de0 100644 --- a/include/boost/fusion/include/end.hpp +++ b/include/boost/fusion/include/end.hpp @@ -4,8 +4,8 @@ Distributed under 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) ==============================================================================*/ -#if !defined(FUSION_INCLUDE_BEGIN) -#define FUSION_INCLUDE_BEGIN +#if !defined(FUSION_INCLUDE_END) +#define FUSION_INCLUDE_END #include diff --git a/include/boost/fusion/sequence/intrinsic/at_c.hpp b/include/boost/fusion/sequence/intrinsic/at_c.hpp new file mode 100644 index 00000000..4dc53ae0 --- /dev/null +++ b/include/boost/fusion/sequence/intrinsic/at_c.hpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2001-2006 Joel de Guzman + + Distributed under 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) +==============================================================================*/ +#if !defined(FUSION_AT_C_08252008_0308) +#define FUSION_AT_C_08252008_0308 + +#include + +#endif + diff --git a/include/boost/fusion/tuple/detail/tuple_forward_ctor.hpp b/include/boost/fusion/tuple/detail/tuple_expand.hpp similarity index 70% rename from include/boost/fusion/tuple/detail/tuple_forward_ctor.hpp rename to include/boost/fusion/tuple/detail/tuple_expand.hpp index 2ff20a2a..806515f9 100644 --- a/include/boost/fusion/tuple/detail/tuple_forward_ctor.hpp +++ b/include/boost/fusion/tuple/detail/tuple_expand.hpp @@ -1,19 +1,19 @@ /*============================================================================= Copyright (c) 2001-2006 Joel de Guzman - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under 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_PP_IS_ITERATING -#if !defined(FUSION_TUPLE_FORWARD_CTOR_10032005_0815) -#define FUSION_TUPLE_FORWARD_CTOR_10032005_0815 +#if !defined(FUSION_TUPLE_EXPAND_10032005_0815) +#define FUSION_TUPLE_EXPAND_10032005_0815 #include #include #include #define BOOST_PP_FILENAME_1 \ - + #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE) #include BOOST_PP_ITERATE() @@ -34,6 +34,17 @@ N, typename detail::call_param::type _)) : base_type(BOOST_PP_ENUM_PARAMS(N, _)) {} + template + tuple(tuple const& rhs) + : base_type(rhs) {} + + template + tuple& operator=(tuple const& rhs) + { + base_type::operator=(rhs); + return *this; + } + #undef N #endif // defined(BOOST_PP_IS_ITERATING) diff --git a/include/boost/fusion/tuple/tuple.hpp b/include/boost/fusion/tuple/tuple.hpp index d9860323..a97cadeb 100644 --- a/include/boost/fusion/tuple/tuple.hpp +++ b/include/boost/fusion/tuple/tuple.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2005 Joel de Guzman - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under 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) ==============================================================================*/ #if !defined(FUSION_TUPLE_10032005_0810) @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace fusion { @@ -23,35 +24,50 @@ namespace boost { namespace fusion struct tuple : vector { typedef vector< - BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> + BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)> base_type; tuple() : base_type() {} - - template - tuple(Sequence const& rhs) + + tuple(tuple const& rhs) : base_type(rhs) {} - #include + template + tuple(std::pair const& rhs) + : base_type(rhs) {} + + #include template - tuple& - operator=(T const& rhs) + tuple& operator=(T const& rhs) + { + base_type::operator=(rhs); + return *this; + } + + tuple& operator=(tuple const& rhs) + { + base_type::operator=(rhs); + return *this; + } + + template + tuple& operator=(std::pair const& rhs) { base_type::operator=(rhs); return *this; } }; - template + template struct tuple_size : result_of::size {}; - template + template struct tuple_element : result_of::value_at_c {}; template - inline typename + inline typename lazy_disable_if< is_const , result_of::at_c