diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index f47fce5c..3bda204d 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -258,6 +258,22 @@ the first call) and [arg_desc] of `seq`. typename result_of_name_macro::type name_macro( Sequence const& seq, State const& initial_state, F f); + template< + typename Sequence, + typename State, + typename F + > + typename result_of_name_macro::type name_macro( + Sequence& seq, State& initial_state, F f); + + template< + typename Sequence, + typename State, + typename F + > + typename result_of_name_macro::type name_macro( + Sequence const& seq, State& initial_state, F f); + [def seq_concept_macro [seq_concept]] [def arg_type_id_macro [arg_type_id]] [def arg_id_macro [arg_id]] @@ -1722,7 +1738,7 @@ Takes 2 sequences and returns a sequence containing the elements of the first fo template< typename LhSequence, typename RhSequence> - typename __result_of_join__::type join(LhSequence const& lhs, RhSequence const& rhs); + typename __result_of_join__::type join(LhSequence const& lhs, RhSequence const& rhs); [table Parameters [[Parameter][Requirement][Description]] @@ -1767,7 +1783,7 @@ Zips sequences together to form a single sequence, whose members are tuples of t ... typename SequenceN > - typename __result_of_zip__::type + typename __result_of_zip__::type zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN); [table Parameters @@ -1886,7 +1902,7 @@ Returns a new sequence with an element added at the end. typename Sequence, typename T > - typename __result_of_push_back__::type push_back( + typename __result_of_push_back__::type push_back( Sequence const& seq, T const& t); [table Parameters @@ -1927,7 +1943,7 @@ Returns a new sequence with an element added at the beginning. typename Sequence, typename T > - typename __result_of_push_front__::type push_front( + typename __result_of_push_front__::type push_front( Sequence const& seq, T const& t); [table Parameters diff --git a/doc/container.qbk b/doc/container.qbk index 8a29e29b..fccd2102 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -66,6 +66,11 @@ cases the most efficient. template struct vectorN; +[important Numbered forms will be deprecated in C++11 and it will be provided + via aliasing templates. It means that your partial specialization + might be compile error. You can detect whether it is aliasing + templates or not, using `BOOST_FUSION_HAS_VARIADIC_VECTOR`.] + [*Variadic form] template < @@ -81,9 +86,11 @@ The numbered form accepts the exact number of elements. Example: vector3 -The variadic form accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where -`FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the The variadic form accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. Example: vector @@ -232,9 +239,11 @@ each element is peculiarly constant (see __recursive_inline__). > struct list; -The variadic class interface accepts `0` to `FUSION_MAX_LIST_SIZE` -elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined -maximum that defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: list @@ -532,9 +541,11 @@ complexity (see __overloaded_functions__). > struct set; -The variadic class interface accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: set @@ -614,9 +625,11 @@ __overloaded_functions__). > struct map; -The variadic class interface accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: map<__pair__, __pair__, __pair__ > @@ -697,10 +710,13 @@ Create a __list__ from one or more values. typename __result_of_make_list__::type make_list(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -794,11 +810,13 @@ Create a __vector__ from one or more values. typename __result_of_make_vector__::type make_vector(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. You may define +the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any +Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -896,11 +914,13 @@ Create a __set__ from one or more values. typename __result_of_make_set__::type make_set(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_SET_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_SET_SIZE 20 @@ -1049,10 +1069,13 @@ Constructs a tie using a __list__ sequence. __list__ list_tie(T0& x0, T1& x1... TN& xN); -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1096,11 +1119,13 @@ Constructs a tie using a __vector__ sequence. __vector__ vector_tie(T0& x0, T1& x1... TN& xN); -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. You may define +the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any +Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1144,11 +1169,14 @@ Constructs a tie using a __map__ sequence. __map__<__pair__, __pair__,... __pair__ > map_tie(D0& d0, D1& d1... DN& dN); -The variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`, and a corresponding number of key types. -You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before -including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user +definable predefined maximum that defaults to `10`, and a corresponding +number of key types. You may define the preprocessor constant +`FUSION_MAX_MAP_SIZE` before including any Fusion header to change the +default. Example: #define FUSION_MAX_MAP_SIZE 20 @@ -1249,10 +1277,13 @@ Returns the result type of __make_list__. template struct make_list; -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1333,11 +1364,13 @@ Returns the result type of __make_vector__. template struct make_vector; -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1427,11 +1460,13 @@ Returns the result type of __make_set__. template struct make_set; -The variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_SET_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable +predefined maximum that defaults to `10`. You may define the preprocessor +constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change +the default. Example: #define FUSION_MAX_SET_SIZE 20 @@ -1559,10 +1594,13 @@ Returns the result type of __list_tie__. template struct list_tie; -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1603,11 +1641,13 @@ Returns the result type of __vector_tie__. template struct vector_tie; -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1695,11 +1735,13 @@ Returns the result type of __map_tie__. template struct map_tie; -The variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_MAP_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable +predefined maximum that defaults to `10`. You may define the preprocessor +constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change +the default. Example: #define FUSION_MAX_MAP_SIZE 20 diff --git a/include/boost/fusion/algorithm/iteration/accumulate.hpp b/include/boost/fusion/algorithm/iteration/accumulate.hpp index fe7112e3..7d524a15 100644 --- a/include/boost/fusion/algorithm/iteration/accumulate.hpp +++ b/include/boost/fusion/algorithm/iteration/accumulate.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi 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) @@ -10,8 +11,6 @@ #include #include #include -#include -#include namespace boost { namespace fusion { @@ -27,11 +26,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f) { return fusion::fold(seq, state, f); @@ -39,11 +34,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f) { return fusion::fold(seq, state, f); diff --git a/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp b/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp index 50c4d39d..f00e67f9 100644 --- a/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2011 Eric Niebler + Copyright (c) 2015 Kohei Takahashi 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) @@ -8,8 +9,6 @@ #define BOOST_FUSION_ACCUMULATE_FWD_HPP_INCLUDED #include -#include -#include namespace boost { namespace fusion { @@ -21,20 +20,12 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f); template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f); }} diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 1813bd24..ddc4d0af 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2006 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi 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) @@ -45,374 +46,124 @@ namespace boost { namespace fusion { namespace detail { - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state) - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It)) - > + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME) {}; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - Result - , N-4 - >::call( - f(state3,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it3)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } + typedef typename State::type type; }; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it2; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it3; - - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest3 - , it3 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it3 - >::type - , F - , N-4 - >::type - type; - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it1 const - >::type const - , F - >::type - type; - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 2 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type const - , F - > - {}; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 1 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - > - {}; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 0 - > - { - typedef StateRef type; - }; - - template - struct BOOST_PP_CAT(result_of_first_unrolled,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM( - It0 const) - ) - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl) - { - typedef typename - BOOST_PP_CAT( - result_of_first_unrolled,BOOST_FUSION_FOLD_NAME)< - StateRef - , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( - typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)::type::type + >::type> + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize-1 + , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename add_reference::type, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) - , F - , SeqSize - >::type - type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - type - , SeqSize - > - unrolled_impl; - - return unrolled_impl::call( - state, - BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( - fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq)), - f); - } - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)<0,StateRef,Seq,F> - { - typedef StateRef type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - - template - struct BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME) - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)< - result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + > , F > {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + 0 + , It + , State + , F + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize + , It + , State + , F + > + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_, It const& it, typename State::type state, F& f) + { + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename add_reference::type, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) + ) + > + , F + >( + mpl::int_() + , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it) + , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it)) + , f + ); + } + + template::value + , bool = traits::is_segmented::value> + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + {}; + + template + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + result_of::size::value + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference + , F + > + {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)::type + BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F& f) + { + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference + , F + >( + typename result_of::size::type() + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( + fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq) + ) + , state + , f + ); + } } namespace result_of { template struct BOOST_FUSION_FOLD_NAME - : detail::BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME)< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) {}; } @@ -425,10 +176,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template @@ -440,40 +188,31 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq - , State const + , State , F >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::BOOST_FUSION_FOLD_NAME< Seq const - , State const + , State , F >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp index bd3b1dbd..eb5bc9ab 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp @@ -12,341 +12,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > + template + struct result_of_it_fold {}; - template - struct unrolled_fold + template + struct result_of_it_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_fold - { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_fold< - typename fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - typename fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 2 - > - : fold_lvalue_state< - typename fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_fold::type::type + >::type> + : result_of_it_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_fold< + 0 + , It + , State , F - , 1 - > - : fold_lvalue_state< - StateRef - , It0 const + >::type + it_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledfold - { - typedef typename - result_of_unrolled_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct fold_impl - { - typedef typename - result_of_first_unrolledfold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_fold - : fold_impl< + {}; + template + struct result_of_fold + : result_of_it_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_fold::type + fold(Seq& seq, State& state, F& f) + { + return it_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct fold - : detail::result_of_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_fold {}; } template @@ -358,10 +127,7 @@ namespace boost { namespace fusion >::type fold(Seq& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -372,37 +138,28 @@ namespace boost { namespace fusion >::type fold(Seq const& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp index 1d294a87..3895526c 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > + template + struct result_of_it_iter_fold {}; - template - struct unrolled_iter_fold + template + struct result_of_it_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_iter_fold - { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_iter_fold< - typename iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 2 - > - : iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_iter_fold::type::type + >::type> + : result_of_it_iter_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_iter_fold< + 0 + , It + , State , F - , 1 - > - : iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrollediter_fold - { - typedef typename - result_of_unrolled_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct iter_fold_impl - { - typedef typename - result_of_first_unrollediter_fold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_iter_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_iter_fold - : iter_fold_impl< + {}; + template + struct result_of_iter_fold + : result_of_it_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_iter_fold::type + iter_fold(Seq& seq, State& state, F& f) + { + return it_iter_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct iter_fold - : detail::result_of_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_iter_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type iter_fold(Seq& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type iter_fold(Seq const& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp index 94789782..a6705b08 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct reverse_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > + template + struct result_of_it_reverse_fold {}; - template - struct unrolled_reverse_fold + template + struct result_of_it_reverse_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_fold - { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_fold< - typename reverse_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_fold::type::type + >::type> + : result_of_it_reverse_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_fold< + 0 + , It + , State , F - , 1 - > - : reverse_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_fold - { - typedef typename - result_of_unrolled_reverse_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_fold_impl - { - typedef typename - result_of_first_unrolledreverse_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_fold - : reverse_fold_impl< + {}; + template + struct result_of_reverse_fold + : result_of_it_reverse_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_fold::type + reverse_fold(Seq& seq, State& state, F& f) + { + return it_reverse_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_fold - : detail::result_of_reverse_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type reverse_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type reverse_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp index bf1edca5..b6101cb1 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct reverse_iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > + template + struct result_of_it_reverse_iter_fold {}; - template - struct unrolled_reverse_iter_fold + template + struct result_of_it_reverse_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_iter_fold - { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_iter_fold< - typename reverse_iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_iter_fold::type::type + >::type> + : result_of_it_reverse_iter_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_iter_fold< + 0 + , It + , State , F - , 1 - > - : reverse_iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_iter_fold - { - typedef typename - result_of_unrolled_reverse_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_iter_fold_impl - { - typedef typename - result_of_first_unrolledreverse_iter_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_iter_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_iter_fold - : reverse_iter_fold_impl< + {}; + template + struct result_of_reverse_iter_fold + : result_of_it_reverse_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_iter_fold::type + reverse_iter_fold(Seq& seq, State& state, F& f) + { + return it_reverse_iter_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_iter_fold - : detail::result_of_reverse_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_iter_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp index 4ff679af..350bff75 100644 --- a/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -38,11 +39,11 @@ namespace boost { namespace fusion { namespace detail }; // The default implementation of this lives in detail/fold.hpp - template + template struct result_of_fold; template - struct result_of_fold + struct result_of_fold { typedef typename result_of::segmented_fold_until< @@ -53,7 +54,7 @@ namespace boost { namespace fusion { namespace detail type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type call(State& state, Sequence& seq, Fun fun) + static type call(Sequence& seq, State& state, Fun& fun) { return fusion::segmented_fold_until(seq, state, segmented_fold_fun(fun)); } diff --git a/include/boost/fusion/algorithm/iteration/fold.hpp b/include/boost/fusion/algorithm/iteration/fold.hpp index a2a0146a..039e01c0 100644 --- a/include/boost/fusion/algorithm/iteration/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/fold.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2007 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi 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) @@ -10,24 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_FOLD_HPP #include -#include #include #include #include -#include -#include #include #include -#include +#include #include #include -#include #include -#include -#include -#include #include -#include +#include #include #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) diff --git a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp index f8328e80..0dbac761 100644 --- a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/iter_fold.hpp index b59a6957..cff5b4ed 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi 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) @@ -13,20 +14,14 @@ #include #include #include -#include -#include #include #include -#include -#include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include #include #define BOOST_FUSION_ITER_FOLD diff --git a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index 6c595cf1..1d8543ca 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp index dffff79e..252ad308 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi 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) @@ -10,24 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include -#include +#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index 42c8ac21..c5e24b34 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp index d36861f3..3276bbde 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi 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) @@ -9,24 +10,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_ITER_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include -#include +#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 21d99dee..76f01863 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/transformation/erase.hpp b/include/boost/fusion/algorithm/transformation/erase.hpp index 0f3b8a15..8eebc357 100644 --- a/include/boost/fusion/algorithm/transformation/erase.hpp +++ b/include/boost/fusion/algorithm/transformation/erase.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/fusion/algorithm/transformation/flatten.hpp b/include/boost/fusion/algorithm/transformation/flatten.hpp index e3cfa983..43ac34df 100644 --- a/include/boost/fusion/algorithm/transformation/flatten.hpp +++ b/include/boost/fusion/algorithm/transformation/flatten.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED #define BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED diff --git a/include/boost/fusion/algorithm/transformation/insert.hpp b/include/boost/fusion/algorithm/transformation/insert.hpp index 44e59653..c6d5219d 100644 --- a/include/boost/fusion/algorithm/transformation/insert.hpp +++ b/include/boost/fusion/algorithm/transformation/insert.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/fusion/algorithm/transformation/insert_range.hpp b/include/boost/fusion/algorithm/transformation/insert_range.hpp index 40e64e1f..57878309 100644 --- a/include/boost/fusion/algorithm/transformation/insert_range.hpp +++ b/include/boost/fusion/algorithm/transformation/insert_range.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/fusion/container/deque/deque.hpp b/include/boost/fusion/container/deque/deque.hpp index 96919052..dee51bef 100644 --- a/include/boost/fusion/container/deque/deque.hpp +++ b/include/boost/fusion/container/deque/deque.hpp @@ -149,7 +149,8 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit deque(Sequence const& seq - , typename disable_if >::type* /*dummy*/ = 0) + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/include/boost/fusion/container/deque/detail/convert_impl.hpp b/include/boost/fusion/container/deque/detail/convert_impl.hpp index ba9b8477..ede0cc48 100644 --- a/include/boost/fusion/container/deque/detail/convert_impl.hpp +++ b/include/boost/fusion/container/deque/detail/convert_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2015 Kohei Takahashi 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) @@ -12,7 +13,7 @@ #include #include #include -#include +#include namespace boost { namespace fusion { @@ -41,7 +42,11 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& seq) { - return gen::call(seq); + return gen::call(fusion::begin(seq) +#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) + , fusion::end(seq) +#endif + ); } }; }; diff --git a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp index 99cbe584..587aa3b0 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp @@ -22,6 +22,7 @@ namespace boost { namespace fusion { template struct as_deque + : detail::as_deque::value> { typedef typename detail::as_deque::value> diff --git a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp index db8a967a..a65fa4ac 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -101,7 +101,9 @@ namespace boost { namespace fusion { template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* /*dummy*/ = 0) + deque(Sequence const& seq + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp index ae1828a5..95cd8c1c 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp @@ -201,7 +201,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp index 78224634..ad069451 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp @@ -381,7 +381,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp index 8653217b..44a5b2b1 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp @@ -561,7 +561,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp index 3bfd488a..e642288e 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp @@ -741,7 +741,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp index 04441da6..a387708b 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp @@ -921,7 +921,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/generation/make_set.hpp b/include/boost/fusion/container/generation/make_set.hpp index 705ec582..cd8519e5 100644 --- a/include/boost/fusion/container/generation/make_set.hpp +++ b/include/boost/fusion/container/generation/make_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -10,7 +10,46 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_set + { + typedef set< + typename detail::as_fusion_element< + typename remove_const< + typename remove_reference::type + >::type + >::type... + > type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_set::type + make_set(T&&... arg) + { + return typename result_of::make_set::type(std::forward(arg)...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index 8f067481..cd3b992b 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -10,7 +10,66 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_vector + { + // make `make_vector' into `make_vector' + template struct trim_void; + + template + struct trim_void > + { + typedef vector type; + }; + + template + struct trim_void, void_, Tail...> + : trim_void > { }; + + template + struct trim_void, Head, Tail...> + : trim_void, Tail...> { }; + + typedef + typename trim_void< + vector<> + , typename detail::as_fusion_element< + typename remove_const< + typename remove_reference::type + >::type + >::type... + >::type + type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_vector::type + make_vector(T&&... arg) + { + return typename result_of::make_vector::type(std::forward(arg)...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/generation/vector_tie.hpp b/include/boost/fusion/container/generation/vector_tie.hpp index 5bb4face..5d7cb98b 100644 --- a/include/boost/fusion/container/generation/vector_tie.hpp +++ b/include/boost/fusion/container/generation/vector_tie.hpp @@ -8,8 +8,37 @@ #define FUSION_VECTOR_TIE_11112014_2302 #include +#include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct vector_tie + { + typedef vector type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline vector + vector_tie(T&... arg) + { + return vector(arg...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/set/detail/as_set.hpp b/include/boost/fusion/container/set/detail/as_set.hpp index 1eb0d3fe..9d333258 100644 --- a/include/boost/fusion/container/set/detail/as_set.hpp +++ b/include/boost/fusion/container/set/detail/as_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -13,7 +13,55 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template ::type> + struct as_set; + + template + struct as_set > + { + template + struct apply + { + typedef set< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator const& i) + { + typedef apply gen; + typedef typename gen::type result; + return result(*advance_c(i)...); + } + }; + +BOOST_FUSION_BARRIER_END +}}} #endif +#endif diff --git a/include/boost/fusion/container/set/detail/convert_impl.hpp b/include/boost/fusion/container/set/detail/convert_impl.hpp index d9d5dcfc..0b4cb22f 100644 --- a/include/boost/fusion/container/set/detail/convert_impl.hpp +++ b/include/boost/fusion/container/set/detail/convert_impl.hpp @@ -29,7 +29,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename detail::as_set::value> gen; + typedef detail::as_set::value> gen; typedef typename gen:: template apply::type>::type type; diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 59f4eafc..12fd8115 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -13,8 +13,126 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; + + template <> + struct set<> : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector<> storage_type; + + typedef storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) + : data(rhs) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(T const& rhs) + { + data = rhs; + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type& get_data() { return data; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type const& get_data() const { return data; } + + private: + storage_type data; + }; + + template + struct set : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector storage_type; + + typedef typename storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence&& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) + : data(std::forward(rhs)) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(U&& ...args) + : data(std::forward(args)...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U&& rhs) + { + data = std::forward(rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type& get_data() { return data; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type const& get_data() const { return data; } + + private: + storage_type data; + }; + +}} + +#endif #endif diff --git a/include/boost/fusion/container/set/set_fwd.hpp b/include/boost/fusion/container/set/set_fwd.hpp index 50d8d1c8..7b5d6830 100644 --- a/include/boost/fusion/container/set/set_fwd.hpp +++ b/include/boost/fusion/container/set/set_fwd.hpp @@ -9,11 +9,38 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_SET) +# undef BOOST_FUSION_HAS_VARIADIC_SET +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_SET) +# define BOOST_FUSION_HAS_VARIADIC_SET +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct set_tag; + struct set_iterator_tag; + + template + struct set; +}} #endif +#endif diff --git a/include/boost/fusion/container/vector.hpp b/include/boost/fusion/container/vector.hpp index a999c8b0..41c98033 100644 --- a/include/boost/fusion/container/vector.hpp +++ b/include/boost/fusion/container/vector.hpp @@ -8,25 +8,8 @@ #define FUSION_SEQUENCE_CLASS_VECTOR_10022005_0602 #include -#include - -#include -#if (FUSION_MAX_VECTOR_SIZE > 10) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 20) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 30) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 40) -#include -#endif - -#include #include -#include +#include #include #endif diff --git a/include/boost/fusion/container/vector/detail/as_vector.hpp b/include/boost/fusion/container/vector/detail/as_vector.hpp index eaaac896..e2f45b6a 100644 --- a/include/boost/fusion/container/vector/detail/as_vector.hpp +++ b/include/boost/fusion/container/vector/detail/as_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -8,12 +8,63 @@ #define FUSION_AS_VECTOR_11052014_1801 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template + struct as_vector_impl; + + template + struct as_vector_impl > + { + template + struct apply + { + typedef vector< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator i) + { + typedef typename apply::type result; + return result(*advance_c(i)...); + } + }; + + template + struct as_vector + : as_vector_impl::type> {}; + +BOOST_FUSION_BARRIER_END +}}} + +#endif #endif diff --git a/include/boost/fusion/container/vector/detail/at_impl.hpp b/include/boost/fusion/container/vector/detail/at_impl.hpp index cb98dd4a..a2900d79 100644 --- a/include/boost/fusion/container/vector/detail/at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/at_impl.hpp @@ -9,9 +9,8 @@ #include #include -#include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -28,7 +27,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::ref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -43,7 +42,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::cref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/include/boost/fusion/container/vector/detail/config.hpp b/include/boost/fusion/container/vector/detail/config.hpp new file mode 100644 index 00000000..84f4605d --- /dev/null +++ b/include/boost/fusion/container/vector/detail/config.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2014-2015 Kohei Takahashi + + 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 FUSION_VECTOR_CONFIG_11052014_1720 +#define FUSION_VECTOR_CONFIG_11052014_1720 + +#include +#include +#include + +#if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ + || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ + || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) \ + || defined(BOOST_NO_CXX11_DECLTYPE)) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# undef BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# define BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#endif + +// Sometimes, MSVC 12 shows compile error with std::size_t of template parameter. +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1800)) +# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# undef BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#endif + +#endif + diff --git a/include/boost/fusion/container/vector/detail/cpp03/limits.hpp b/include/boost/fusion/container/vector/detail/cpp03/limits.hpp index 6e106144..74a05102 100644 --- a/include/boost/fusion/container/vector/detail/cpp03/limits.hpp +++ b/include/boost/fusion/container/vector/detail/cpp03/limits.hpp @@ -9,6 +9,7 @@ #include #include +#include #if !defined(FUSION_MAX_VECTOR_SIZE) # define FUSION_MAX_VECTOR_SIZE 10 diff --git a/include/boost/fusion/container/vector/detail/deref_impl.hpp b/include/boost/fusion/container/vector/detail/deref_impl.hpp index 5186aa10..c85bb82b 100644 --- a/include/boost/fusion/container/vector/detail/deref_impl.hpp +++ b/include/boost/fusion/container/vector/detail/deref_impl.hpp @@ -8,8 +8,8 @@ #define FUSION_DEREF_IMPL_05042005_1037 #include -#include #include +#include #include #include @@ -30,9 +30,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - element; + typedef typename value_at_impl::template apply::type element; typedef typename mpl::if_< diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index f71ca848..3d748afd 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -9,11 +9,50 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + + namespace vector_detail + { + template + struct vector_data; + } + + namespace extension + { + template + struct value_at_impl; + + template <> + struct value_at_impl + { + template + struct apply + { + typedef typename boost::remove_cv::type seq; + typedef decltype(seq::template value_at_impl(boost::declval())) type; + }; + }; + } +}} #endif +#endif diff --git a/include/boost/fusion/container/vector/detail/value_of_impl.hpp b/include/boost/fusion/container/vector/detail/value_of_impl.hpp index 2a8acf91..d67ab3fc 100644 --- a/include/boost/fusion/container/vector/detail/value_of_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_of_impl.hpp @@ -8,7 +8,7 @@ #define FUSION_VALUE_OF_IMPL_05052005_1128 #include -#include +#include namespace boost { namespace fusion { @@ -27,9 +27,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - type; + typedef typename value_at_impl::template apply::type type; }; }; } diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 2b9f0ce5..df306714 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -9,12 +9,333 @@ #include #include +#include #include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + struct random_access_traversal_tag; + + namespace vector_detail + { + struct each_elem {}; + struct copy_or_move {}; + template struct from_sequence {}; + + template + struct make_indices_from_seq + : detail::make_index_sequence< + fusion::result_of::size::type>::value + > + {}; + + template + struct pure : remove_cv::type> {}; + + template ::value> + struct is_convertible_to_first + : boost::is_convertible::type> + {}; + + template + struct is_convertible_to_first + : mpl::false_ + {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline each_elem + dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline copy_or_move + dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline from_sequence< + typename lazy_enable_if_c< + (traits::is_sequence::type>::value && + !is_same::type>::value && + !is_convertible_to_first::value) + , make_indices_from_seq + >::type + > + dispatch(Sequence&&) BOOST_NOEXCEPT + { return from_sequence::type>(); } + + + // forward_at_c allows to access Nth element even if ForwardSequence + // since fusion::at_c requires RandomAccessSequence. + namespace result_of + { + template + struct forward_at_c + : fusion::result_of::deref< + typename fusion::result_of::advance_c< + typename fusion::result_of::begin< + typename remove_reference::type + >::type + , N + >::type + > + {}; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::forward_at_c::type + forward_at_c(Sequence&& seq) + { + typedef typename + result_of::forward_at_c::type + result; + return std::forward(*advance_c(begin(seq))); + } + + // Object proxy since preserve object order + template + struct store + { + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store() + : elem() // value-initialized explicitly + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store const& rhs) + : elem(rhs.get()) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store const& rhs) + { + elem = rhs.get(); + return *this; + } + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store&& rhs) + : elem(static_cast(rhs.get())) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store&& rhs) + { + elem = static_cast(rhs.get()); + return *this; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(U&& rhs + , typename disable_if::type, store> >::type* = 0) + : elem(std::forward(rhs)) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename disable_if::type, store>, store&>::type + operator=(U&& rhs) + { + elem = std::forward(rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T & get() { return elem; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T const& get() const { return elem; } + + T elem; + }; + + template + struct vector_data; + + template + struct vector_data, T...> + : store... + , sequence_base, T...> > + { + typedef vector_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + typedef random_access_traversal_tag category; + typedef mpl::int_ size; + typedef vector type_sequence; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data() + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data const& rhs) + : store(static_cast const&>(rhs))... + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data&& rhs) + : store(std::forward >(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(from_sequence >, Sequence&& rhs) + : store(forward_at_c(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(each_elem, U&&... var) + : store(std::forward(var))... + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&&, detail::index_sequence<>) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&& seq, detail::index_sequence) + { + at_impl(mpl::int_()) = vector_detail::forward_at_c(seq); + assign(std::forward(seq), detail::index_sequence()); + } + + template + static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store const* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) -> decltype(at_detail(this)) + { + return at_detail(this); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) const -> decltype(at_detail(this)) + { + return at_detail(this); + } + + template + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + U value_at_impl(store*) { return boost::declval(); } + }; + + template + struct trim_void_; + + template + struct trim_void_ > + { + typedef vector_data< + typename detail::make_index_sequence::type + , T... + > type; + }; + + template + struct trim_void_, void_, Tail...> + : trim_void_ > {}; + + template + struct trim_void_, Head, Tail...> + : trim_void_, Tail...> {}; + + template + struct trim_void : trim_void_, T...> {}; + } // namespace boost::fusion::vector_detail + + // This class provides backward compatibility: vector. + template + struct vector + : vector_detail::trim_void::type + { + typedef typename vector_detail::trim_void::type base; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector() + {} + + // rvalue-references is required here in order to forward any arguments to + // base: vector(T const&...) doesn't work with trailing void_ and + // vector(U const&...) cannot forward any arguments to base. + template + // XXX: constexpr become error due to pull-request #79, booooo!! + // In the (near) future release, should be fixed. + /* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED + vector(U&&... u) + : base(vector_detail::dispatch(std::forward(u)...), std::forward(u)...) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector& + operator=(Sequence&& rhs) + { + typedef typename + vector_detail::make_indices_from_seq::type + indices; + base::assign(std::forward(rhs), indices()); + return *this; + } + }; +}} #endif +#endif diff --git a/include/boost/fusion/container/vector/vector10.hpp b/include/boost/fusion/container/vector/vector10.hpp index f152bfe1..65722fe6 100644 --- a/include/boost/fusion/container/vector/vector10.hpp +++ b/include/boost/fusion/container/vector/vector10.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include #endif +#endif diff --git a/include/boost/fusion/container/vector/vector20.hpp b/include/boost/fusion/container/vector/vector20.hpp index c5be355d..c36e50c7 100644 --- a/include/boost/fusion/container/vector/vector20.hpp +++ b/include/boost/fusion/container/vector/vector20.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include #endif +#endif diff --git a/include/boost/fusion/container/vector/vector30.hpp b/include/boost/fusion/container/vector/vector30.hpp index 1a528cb5..e9f891f2 100644 --- a/include/boost/fusion/container/vector/vector30.hpp +++ b/include/boost/fusion/container/vector/vector30.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include #endif +#endif diff --git a/include/boost/fusion/container/vector/vector40.hpp b/include/boost/fusion/container/vector/vector40.hpp index 5faa7d59..4b753a08 100644 --- a/include/boost/fusion/container/vector/vector40.hpp +++ b/include/boost/fusion/container/vector/vector40.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include #endif +#endif diff --git a/include/boost/fusion/container/vector/vector50.hpp b/include/boost/fusion/container/vector/vector50.hpp index 7b7e7a8a..5d8d3563 100644 --- a/include/boost/fusion/container/vector/vector50.hpp +++ b/include/boost/fusion/container/vector/vector50.hpp @@ -9,11 +9,21 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include #endif +#endif diff --git a/include/boost/fusion/container/vector/vector_fwd.hpp b/include/boost/fusion/container/vector/vector_fwd.hpp index b63099ce..dcb0a0fc 100644 --- a/include/boost/fusion/container/vector/vector_fwd.hpp +++ b/include/boost/fusion/container/vector/vector_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -9,11 +9,35 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + template + struct vector; + +#define FUSION_VECTOR_N_ALIASES(z, N, d) \ + template \ + using BOOST_PP_CAT(vector, N) = vector; + + BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~) + +#undef FUSION_VECTOR_N_ALIASES +}} #endif +#endif diff --git a/include/boost/fusion/functional/adapter/limits.hpp b/include/boost/fusion/functional/adapter/limits.hpp index cdcdf821..9fb5a2a2 100644 --- a/include/boost/fusion/functional/adapter/limits.hpp +++ b/include/boost/fusion/functional/adapter/limits.hpp @@ -9,16 +9,21 @@ #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED) # define BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED -# include +# include +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# include +# endif # if !defined(BOOST_FUSION_UNFUSED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif # if !defined(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif diff --git a/include/boost/fusion/support/detail/is_same_size.hpp b/include/boost/fusion/support/detail/is_same_size.hpp new file mode 100644 index 00000000..b1bf7cde --- /dev/null +++ b/include/boost/fusion/support/detail/is_same_size.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2014-2015 Kohei Takahashi + + 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 FUSION_IS_SAME_SIZE_10082015_1156 +#define FUSION_IS_SAME_SIZE_10082015_1156 + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct is_same_size : mpl::false_ {}; + + template + struct is_same_size >::type, + typename enable_if >::type> + : mpl::equal_to, result_of::size > + {}; +}}} + +#endif diff --git a/include/boost/fusion/support/detail/result_of.hpp b/include/boost/fusion/support/detail/result_of.hpp deleted file mode 100644 index e53ea9e3..00000000 --- a/include/boost/fusion/support/detail/result_of.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2014 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_RESULT_OF_10272014_0654) -#define FUSION_RESULT_OF_10272014_0654 - -#include -#include - -#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#define BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF -#endif - -#if !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) -#include -#include -#include -#endif - -namespace boost { namespace fusion { namespace detail -{ - // This is a temporary workaround for result_of before we make fusion fully - // sfinae result_of friendy, which will require some heavy lifting for some - // low level code. So far this is used only in the fold algorithm. This will - // be removed once we overhaul fold. - -#if defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - template - struct result_of_with_decltype : boost::tr1_result_of {}; - -#else // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) - BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result) - - template - struct result_of_with_decltype; - - template - struct result_of_with_decltype - : mpl::if_, detail::has_result >, - boost::tr1_result_of, - boost::detail::cpp0x_result_of >::type {}; - -#endif // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - -}}} - -#endif diff --git a/include/boost/fusion/support/segmented_fold_until.hpp b/include/boost/fusion/support/segmented_fold_until.hpp index 9e6f4a50..8fb09ee3 100644 --- a/include/boost/fusion/support/segmented_fold_until.hpp +++ b/include/boost/fusion/support/segmented_fold_until.hpp @@ -11,11 +11,6 @@ #include #include #include -#include -#include -#include -#include -#include namespace boost { namespace fusion { diff --git a/include/boost/fusion/tuple/make_tuple.hpp b/include/boost/fusion/tuple/make_tuple.hpp index 0d127736..e5cbb3b2 100644 --- a/include/boost/fusion/tuple/make_tuple.hpp +++ b/include/boost/fusion/tuple/make_tuple.hpp @@ -13,7 +13,38 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline tuple::type + >::type + >::type...> + make_tuple(T&&... arg) + { + typedef tuple::type + >::type + >::type...> result_type; + return result_type(std::forward(arg)...); + } +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple.hpp b/include/boost/fusion/tuple/tuple.hpp index 674c3691..6ee21f56 100644 --- a/include/boost/fusion/tuple/tuple.hpp +++ b/include/boost/fusion/tuple/tuple.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -13,7 +13,80 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + struct tuple : vector + { + typedef vector base_type; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple() + : base_type() {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple const& other) + : base_type(other) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple&& other) + : base_type(std::move(other)) {} + + template + /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED + explicit + tuple(U&&... args) + : base_type(std::forward(args)...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple& operator=(U&& rhs) + { + base_type::operator=(std::forward(rhs)); + return *this; + } + }; + + template + struct tuple_size : result_of::size {}; + + template + struct tuple_element : result_of::value_at_c {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple& tup) + { + return at_c(tup); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple const& tup) + { + return at_c(tup); + } +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple_fwd.hpp b/include/boost/fusion/tuple/tuple_fwd.hpp index 07420234..b763acd5 100644 --- a/include/boost/fusion/tuple/tuple_fwd.hpp +++ b/include/boost/fusion/tuple/tuple_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi 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) @@ -9,11 +9,35 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# undef BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# define BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template + struct tuple; +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple_tie.hpp b/include/boost/fusion/tuple/tuple_tie.hpp index 92028070..a07dc0a4 100644 --- a/include/boost/fusion/tuple/tuple_tie.hpp +++ b/include/boost/fusion/tuple/tuple_tie.hpp @@ -13,7 +13,26 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { namespace fusion +{ + template + BOOST_FUSION_GPU_ENABLED + inline tuple + tie(T&... arg) + { + return tuple(arg...); + } +}} #endif +#endif diff --git a/include/boost/fusion/view/detail/strictest_traversal.hpp b/include/boost/fusion/view/detail/strictest_traversal.hpp index 9ad1f7aa..d1aa7883 100644 --- a/include/boost/fusion/view/detail/strictest_traversal.hpp +++ b/include/boost/fusion/view/detail/strictest_traversal.hpp @@ -17,6 +17,9 @@ #include #include #include +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include +#endif namespace boost { namespace fusion { @@ -61,7 +64,10 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED typename result::type - operator()(StrictestSoFar&&, Next&&) const; + operator()(StrictestSoFar&&, Next&&) const + { + return boost::declval::type>(); + } #endif }; diff --git a/include/boost/fusion/view/flatten_view.hpp b/include/boost/fusion/view/flatten_view.hpp index dcef08de..25428544 100644 --- a/include/boost/fusion/view/flatten_view.hpp +++ b/include/boost/fusion/view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED diff --git a/include/boost/fusion/view/flatten_view/flatten_view.hpp b/include/boost/fusion/view/flatten_view/flatten_view.hpp index 8e40158d..401f65dc 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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_FUSION_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED diff --git a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index 1ecf6928..be115d91 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED diff --git a/include/boost/fusion/view/nview/detail/advance_impl.hpp b/include/boost/fusion/view/nview/detail/advance_impl.hpp index 7c74a386..c4641433 100644 --- a/include/boost/fusion/view/nview/detail/advance_impl.hpp +++ b/include/boost/fusion/view/nview/detail/advance_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2009 Hartmut Kaiser - 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) ==============================================================================*/ @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_ADVANCE_IMPL_SEP_24_2009_0212PM #include -#include #include namespace boost { namespace fusion @@ -30,11 +29,11 @@ namespace boost { namespace fusion template struct apply { - typedef typename Iterator::first_type::iterator_type iterator_type; + typedef typename Iterator::first_type iterator_type; typedef typename Iterator::sequence_type sequence_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/detail/at_impl.hpp b/include/boost/fusion/view/nview/detail/at_impl.hpp index b9f41def..9f8c1637 100644 --- a/include/boost/fusion/view/nview/detail/at_impl.hpp +++ b/include/boost/fusion/view/nview/detail/at_impl.hpp @@ -10,6 +10,7 @@ #include #include +#include namespace boost { namespace fusion { @@ -29,7 +30,7 @@ namespace boost { namespace fusion typedef typename Sequence::sequence_type sequence_type; typedef typename Sequence::index_type index_type; - typedef typename result_of::at::type index; + typedef typename result_of::value_at::type index; typedef typename result_of::at::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/include/boost/fusion/view/nview/detail/begin_impl.hpp b/include/boost/fusion/view/nview/detail/begin_impl.hpp index bab5e221..99e6319e 100644 --- a/include/boost/fusion/view/nview/detail/begin_impl.hpp +++ b/include/boost/fusion/view/nview/detail/begin_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM #include -#include #include namespace boost { namespace fusion @@ -32,8 +31,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp b/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp index 08c6c9d7..0bcea9bb 100644 --- a/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp +++ b/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp @@ -17,10 +17,13 @@ #include #include #include +#include +#include +#include #define BOOST_PP_ITERATION_PARAMS_1 \ (3, (1, FUSION_MAX_VECTOR_SIZE, \ - "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ + "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ /**/ /////////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/fusion/view/nview/detail/deref_impl.hpp b/include/boost/fusion/view/nview/detail/deref_impl.hpp index 85991021..57654aa0 100644 --- a/include/boost/fusion/view/nview/detail/deref_impl.hpp +++ b/include/boost/fusion/view/nview/detail/deref_impl.hpp @@ -9,8 +9,8 @@ #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM #include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -30,7 +30,7 @@ namespace boost { namespace fusion typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; - typedef typename result_of::deref::type index; + typedef typename result_of::value_of::type index; typedef typename result_of::at< typename sequence_type::sequence_type, index>::type type; diff --git a/include/boost/fusion/view/nview/detail/end_impl.hpp b/include/boost/fusion/view/nview/detail/end_impl.hpp index 0a6efe56..810aea91 100644 --- a/include/boost/fusion/view/nview/detail/end_impl.hpp +++ b/include/boost/fusion/view/nview/detail/end_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM #include -#include #include namespace boost { namespace fusion @@ -33,8 +32,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/include/boost/fusion/view/nview/detail/next_impl.hpp b/include/boost/fusion/view/nview/detail/next_impl.hpp index 3c304096..821d9c37 100644 --- a/include/boost/fusion/view/nview/detail/next_impl.hpp +++ b/include/boost/fusion/view/nview/detail/next_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct next_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::next::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/detail/nview_impl.hpp b/include/boost/fusion/view/nview/detail/nview_impl.hpp index 40674e35..0c75a66a 100644 --- a/include/boost/fusion/view/nview/detail/nview_impl.hpp +++ b/include/boost/fusion/view/nview/detail/nview_impl.hpp @@ -8,11 +8,43 @@ #define BOOST_FUSION_NVIEW_IMPL_17122014_1948 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct as_nview + { + typedef vector...> index_type; + typedef nview type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline nview...> > + as_nview(Sequence& s) + { + typedef vector...> index_type; + return nview(s); + } +}} #endif +#endif diff --git a/include/boost/fusion/view/nview/detail/prior_impl.hpp b/include/boost/fusion/view/nview/detail/prior_impl.hpp index 470c5bd3..29b63f56 100644 --- a/include/boost/fusion/view/nview/detail/prior_impl.hpp +++ b/include/boost/fusion/view/nview/detail/prior_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct prior_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::prior::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/nview.hpp b/include/boost/fusion/view/nview/nview.hpp index 2e257c81..e5a4be8a 100644 --- a/include/boost/fusion/view/nview/nview.hpp +++ b/include/boost/fusion/view/nview/nview.hpp @@ -9,19 +9,15 @@ #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM #include -#include #include -#include -#include -#include #include #include #include -#include #include #include +#include #include #include @@ -99,7 +95,7 @@ namespace boost { namespace fusion typedef mpl::true_ is_view; typedef Indicies index_type; - typedef typename mpl::size::type size; + typedef typename result_of::size::type size; typedef typename mpl::if_< is_const, detail::addconstref, detail::addref diff --git a/include/boost/fusion/view/nview/nview_iterator.hpp b/include/boost/fusion/view/nview/nview_iterator.hpp index aeaf4620..42e634e5 100644 --- a/include/boost/fusion/view/nview/nview_iterator.hpp +++ b/include/boost/fusion/view/nview/nview_iterator.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -40,7 +39,7 @@ namespace boost { namespace fusion typedef random_access_traversal_tag category; typedef Sequence sequence_type; - typedef mpl_iterator first_type; + typedef Pos first_type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit nview_iterator(Sequence& in_seq) diff --git a/test/Jamfile b/test/Jamfile index f9c71c71..8f290165 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -65,6 +65,12 @@ project [ run sequence/boost_tuple.cpp : : : : ] [ run sequence/boost_tuple_iterator.cpp : : : : ] [ run sequence/cons.cpp : : : : ] + [ run sequence/convert_boost_tuple.cpp : : : : ] + [ run sequence/convert_deque.cpp : : : : ] + [ run sequence/convert_list.cpp : : : : ] + [ run sequence/convert_std_pair.cpp : : : : ] + [ run sequence/convert_std_tuple.cpp : : : : ] + [ run sequence/convert_vector.cpp : : : : ] [ run sequence/filter_view.cpp : : : : ] [ run sequence/hash.cpp : : : : ] [ run sequence/io.cpp : : : : ] @@ -86,6 +92,7 @@ project [ run sequence/deque_copy.cpp : : : : ] [ run sequence/deque_iterator.cpp : : : : ] [ run sequence/deque_hash.cpp : : : : ] + [ compile sequence/deque_is_constructible.cpp : : : : ] [ run sequence/deque_make.cpp : : : : ] [ run sequence/deque_misc.cpp : : : : ] [ run sequence/deque_move.cpp : : : : ] diff --git a/test/algorithm/flatten.cpp b/test/algorithm/flatten.cpp index 28d6359f..ddc71006 100644 --- a/test/algorithm/flatten.cpp +++ b/test/algorithm/flatten.cpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #include #include #include diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp index 249f1bb3..c441ceaf 100644 --- a/test/algorithm/fold.cpp +++ b/test/algorithm/fold.cpp @@ -238,7 +238,7 @@ main() } { -#if !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) +#if defined(BOOST_RESULT_OF_USE_DECLTYPE) { boost::fusion::vector container{1, 2, 3}; functor f; diff --git a/test/algorithm/fold.hpp b/test/algorithm/fold.hpp index 87a81a7c..997623ea 100644 --- a/test/algorithm/fold.hpp +++ b/test/algorithm/fold.hpp @@ -189,7 +189,7 @@ struct fold_test_n >::type , typename mpl::if_c< !n - , mpl::vector, mpl::int_<0> > const& + , mpl::vector, mpl::int_<0> >& , mpl::vector, mpl::int_ > >::type > diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp index 5e45e779..fcb5b75c 100644 --- a/test/algorithm/pop_back.cpp +++ b/test/algorithm/pop_back.cpp @@ -88,6 +88,7 @@ main() auto i1 = find(popv); auto i2 = find(pop); + (void)push; BOOST_TEST(i1 != end(pop)); BOOST_TEST(i2 != end(pop)); BOOST_TEST(i1 != i2); diff --git a/test/compile_time/sfinae_friendly.hpp b/test/compile_time/sfinae_friendly.hpp index 77b148b8..1111cd8c 100644 --- a/test/compile_time/sfinae_friendly.hpp +++ b/test/compile_time/sfinae_friendly.hpp @@ -12,9 +12,9 @@ #include #include #include -#include +#include -#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) +#if !defined(BOOST_NO_SFINAE) && defined(BOOST_RESULT_OF_USE_DECLTYPE) #include diff --git a/test/sequence/convert.hpp b/test/sequence/convert.hpp new file mode 100644 index 00000000..233fabfb --- /dev/null +++ b/test/sequence/convert.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif + +template +void test(FUSION_SEQUENCE const& seq) +{ + typedef typename + boost::fusion::result_of::convert< + Tag + , FUSION_SEQUENCE + >::type + type; + + type v = boost::fusion::convert(seq); + BOOST_TEST((boost::fusion::at_c<0>(v) == 123)); + BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!")); +} + +int main() +{ + FUSION_SEQUENCE seq(123, "Hola!!!"); + test(seq); + test(seq); + test(seq); + test(seq); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + test(seq); +#endif + + return boost::report_errors(); +} + diff --git a/test/sequence/convert_boost_tuple.cpp b/test/sequence/convert_boost_tuple.cpp new file mode 100644 index 00000000..588ee4d7 --- /dev/null +++ b/test/sequence/convert_boost_tuple.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include +#include + +#define FUSION_SEQUENCE boost::tuples::tuple +#include "convert.hpp" + diff --git a/test/sequence/convert_deque.cpp b/test/sequence/convert_deque.cpp new file mode 100644 index 00000000..5be34d3f --- /dev/null +++ b/test/sequence/convert_deque.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::deque +#include "convert.hpp" + diff --git a/test/sequence/convert_list.cpp b/test/sequence/convert_list.cpp new file mode 100644 index 00000000..57ad0507 --- /dev/null +++ b/test/sequence/convert_list.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::list +#include "convert.hpp" + diff --git a/test/sequence/convert_std_pair.cpp b/test/sequence/convert_std_pair.cpp new file mode 100644 index 00000000..aa350025 --- /dev/null +++ b/test/sequence/convert_std_pair.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include +#include + +#define FUSION_SEQUENCE std::pair +#include "convert.hpp" + diff --git a/test/sequence/convert_std_tuple.cpp b/test/sequence/convert_std_tuple.cpp new file mode 100644 index 00000000..3e28276c --- /dev/null +++ b/test/sequence/convert_std_tuple.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#include +#include + +#define FUSION_SEQUENCE std::tuple +#include "convert.hpp" + +#else + +int main() +{ +} + +#endif diff --git a/test/sequence/convert_vector.cpp b/test/sequence/convert_vector.cpp new file mode 100644 index 00000000..b39014df --- /dev/null +++ b/test/sequence/convert_vector.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + 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). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::vector +#include "convert.hpp" + diff --git a/test/sequence/deque_is_constructible.cpp b/test/sequence/deque_is_constructible.cpp new file mode 100644 index 00000000..e08b4787 --- /dev/null +++ b/test/sequence/deque_is_constructible.cpp @@ -0,0 +1,21 @@ +/*============================================================================= + Copyright (c) 2015 Louis Dionne + + 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) +==============================================================================*/ + +#include + +#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS +#include +#include + + +struct Dummy { }; + +// Make sure deque's constructor is SFINAE-friendly. +static_assert(!std::is_constructible, Dummy const&>::value, ""); + +#endif + diff --git a/test/sequence/flatten_view.cpp b/test/sequence/flatten_view.cpp index f24c1d95..da8e6527 100644 --- a/test/sequence/flatten_view.cpp +++ b/test/sequence/flatten_view.cpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree 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) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #include #include #include