diff options
Diffstat (limited to 'boost/fusion')
79 files changed, 1808 insertions, 1951 deletions
diff --git a/boost/fusion/algorithm/iteration/accumulate.hpp b/boost/fusion/algorithm/iteration/accumulate.hpp index fe7112e323..7d524a15c2 100644 --- a/boost/fusion/algorithm/iteration/accumulate.hpp +++ b/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 <boost/fusion/support/config.hpp> #include <boost/fusion/algorithm/iteration/accumulate_fwd.hpp> #include <boost/fusion/algorithm/iteration/fold.hpp> -#include <boost/fusion/support/is_sequence.hpp> -#include <boost/utility/enable_if.hpp> namespace boost { namespace fusion { @@ -27,11 +26,7 @@ namespace boost { namespace fusion template <typename Sequence, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence<Sequence> - , result_of::accumulate<Sequence, State const, F> - >::type + inline typename result_of::accumulate<Sequence, State const, F>::type accumulate(Sequence& seq, State const& state, F f) { return fusion::fold(seq, state, f); @@ -39,11 +34,7 @@ namespace boost { namespace fusion template <typename Sequence, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence<Sequence> - , result_of::accumulate<Sequence const, State const, F> - >::type + inline typename result_of::accumulate<Sequence const, State const, F>::type accumulate(Sequence const& seq, State const& state, F f) { return fusion::fold(seq, state, f); diff --git a/boost/fusion/algorithm/iteration/accumulate_fwd.hpp b/boost/fusion/algorithm/iteration/accumulate_fwd.hpp index 50c4d39d4e..f00e67f966 100644 --- a/boost/fusion/algorithm/iteration/accumulate_fwd.hpp +++ b/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 <boost/fusion/support/config.hpp> -#include <boost/fusion/support/is_sequence.hpp> -#include <boost/utility/enable_if.hpp> namespace boost { namespace fusion { @@ -21,20 +20,12 @@ namespace boost { namespace fusion template <typename Sequence, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence<Sequence> - , result_of::accumulate<Sequence, State const, F> - >::type + inline typename result_of::accumulate<Sequence, State const, F>::type accumulate(Sequence& seq, State const& state, F f); template <typename Sequence, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence<Sequence> - , result_of::accumulate<Sequence const, State const, F> - >::type + inline typename result_of::accumulate<Sequence const, State const, F>::type accumulate(Sequence const& seq, State const& state, F f); }} diff --git a/boost/fusion/algorithm/iteration/detail/fold.hpp b/boost/fusion/algorithm/iteration/detail/fold.hpp index 1813bd247a..4c82b80029 100644 --- a/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -2,12 +2,15 @@ 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) ==============================================================================*/ #include <boost/preprocessor/cat.hpp> +#define FUSION_HASH # + #ifdef BOOST_FUSION_REVERSE_FOLD # ifdef BOOST_FUSION_ITER_FOLD # define BOOST_FUSION_FOLD_NAME reverse_iter_fold @@ -41,378 +44,193 @@ # define BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(IT) fusion::deref(IT) #endif +#if (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +FUSION_HASH define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +FUSION_HASH else +FUSION_HASH define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +FUSION_HASH endif +#else +# if BOOST_WORKAROUND(BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif +#endif + namespace boost { namespace fusion { namespace detail { - template<typename State, typename It, typename F> - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state) - : fusion::detail::result_of_with_decltype< - F( - typename add_reference<typename add_const<State>::type>::type, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It)) - > + template<int SeqSize, typename It, typename State, typename F, typename = void +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + // Dirty hack: those compilers cannot choose exactly one partial specialization. + , bool = SeqSize == 0 +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + > + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME) {}; - template<typename Result,int N> - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template<typename State3, typename It3, typename F> - 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<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,3> - { - template<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,2> - { - template<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,1> - { - template<typename State, typename It0, typename F> - 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<typename Result> - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)<Result,0> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast<Result>(state); - } - }; - - template<typename StateRef, typename It0, typename F, int N> - 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<it1>::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<it2>::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<typename StateRef, typename It0, typename F> - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 3 - > + template<typename It, typename State, typename F> + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F + , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + , true +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + > { - 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; + typedef typename State::type type; }; - template<typename StateRef, typename It0, typename F> - 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 + template<int SeqSize, typename It, typename State, typename F> + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<SeqSize,It,State,F + , typename boost::enable_if_has_type< +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, >= 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + // Following SFINAE enables to avoid MSVC 9's partial specialization + // ambiguous bug but MSVC 8 don't compile, and moreover MSVC 8 style + // workaround won't work with MSVC 9. + typename boost::disable_if_c<SeqSize == 0, State>::type::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +#endif +#else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + >::type +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH if BOOST_WORKAROUND BOOST_PREVENT_MACRO_SUBSTITUTION (BOOST_MSVC, < 1500) +#endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1500) || \ + (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) + , false +#endif +#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) +FUSION_HASH endif +#endif + > + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize-1 + , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) + ) + > , F > {}; - template<typename StateRef, typename It0, typename F> - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 + template<typename It, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + 0 + , It + , State , F - , 1 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + + template<typename It, typename State, typename F, int SeqSize> + 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 > - {}; - - template<typename StateRef, typename It0, typename F> - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 0 - > - { - typedef StateRef type; - }; - - template<typename StateRef, typename It0, typename F, int SeqSize> - 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<int SeqSize, typename StateRef, typename Seq, typename F> - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl) + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f) { - 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<Seq>::type + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::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<typename StateRef, typename Seq, typename F> - 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<StateRef>(state); - } - }; + > + , F + >( + mpl::int_<SeqSize-1>() + , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it) + , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it)) + , f + ); + } + + template<typename Seq, typename State, typename F + , bool = traits::is_sequence<Seq>::value + , bool = traits::is_segmented<Seq>::value> + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + {}; - template<typename Seq, typename State, typename F, bool IsSegmented> - struct BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME) - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)< + template<typename Seq, typename State, typename F> + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F, true, false> + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< result_of::size<Seq>::value - , typename add_reference< - typename add_const<State>::type - >::type - , Seq + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION<Seq>::type + ) + , add_reference<State> , F > {}; + + template<typename Seq, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F>::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<Seq>::type + ) + , add_reference<State> + , F + >( + typename result_of::size<Seq>::type() + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( + fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq) + ) + , state + , f + ); + } } namespace result_of { template<typename Seq, typename State, typename F> struct BOOST_FUSION_FOLD_NAME - : detail::BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME)< - Seq - , State - , F - , traits::is_segmented<Seq>::type::value - > + : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)<Seq, State, F> {}; } @@ -425,10 +243,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME<Seq,State const,F>::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME<Seq, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> @@ -440,47 +255,40 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME<Seq const,State const,F>::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME<Seq const, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq,State,F>::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME<Seq, State, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq const,State,F>::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME<Seq const, State, F>(seq, state, f); } }} #undef BOOST_FUSION_FOLD_NAME +#undef BOOST_FUSION_FOLD_IMPL_ENABLER #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM #undef BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM +#undef FUSION_HASH diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp index bd3b1dbdac..c23ba16c28 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp @@ -8,345 +8,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template<typename State, typename It, typename F> - struct fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference<typename add_const<State>::type>::type, - typename fusion::result_of::deref<It>::type) - > - {}; - template<typename Result,int N> - struct unrolled_fold - { - template<typename State3, typename It3, typename F> - 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<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_fold<Result,3> - { - template<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_fold<Result,2> - { - template<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_fold<Result,1> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template<typename Result> - struct unrolled_fold<Result,0> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast<Result>(state); - } - }; - template<typename StateRef, typename It0, typename F, int N> - 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<it1>::type - it2; - typedef typename - fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next<it2>::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<typename StateRef, typename It0, typename F> - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 3 + template<int SeqSize, typename It, typename State, typename F, typename = void +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + + , bool = SeqSize == 0 +# endif > + struct result_of_it_fold + {}; + template<typename It, typename State, typename F> + struct result_of_it_fold<0,It,State,F + , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - 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; + typedef typename State::type type; }; - template<typename StateRef, typename It0, typename F> - 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<int SeqSize, typename It, typename State, typename F> + struct result_of_it_fold<SeqSize,It,State,F + , typename boost::enable_if_has_type< +# if BOOST_WORKAROUND (BOOST_MSVC, >= 1500) + + + + typename boost::disable_if_c<SeqSize == 0, State>::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_fold< + SeqSize-1 + , typename result_of::next<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + typename fusion::result_of::deref<It const>::type + ) + > , F > {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_fold< - StateRef - , It0 + template<typename It, typename State, typename F> + 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<typename It, typename State, typename F, int SeqSize> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_fold< + SeqSize + , It + , State , F > - {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_fold(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template<typename StateRef, typename It0, typename F, int SeqSize> - 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<int SeqSize, typename StateRef, typename Seq, typename F> - struct fold_impl - { - typedef typename - result_of_first_unrolledfold< - StateRef - , typename result_of::begin<Seq>::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<typename StateRef, typename Seq, typename F> - 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<StateRef>(state); - } - }; - template<typename Seq, typename State, typename F, bool IsSegmented> + return it_fold< + typename result_of::next<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + typename fusion::result_of::deref<It const>::type + ) + > + , F + >( + mpl::int_<SeqSize-1>() + , fusion::next(it) + , f(state, fusion::deref(it)) + , f + ); + } + template<typename Seq, typename State, typename F + , bool = traits::is_sequence<Seq>::value + , bool = traits::is_segmented<Seq>::value> struct result_of_fold - : fold_impl< + {}; + template<typename Seq, typename State, typename F> + struct result_of_fold<Seq, State, F, true, false> + : result_of_it_fold< result_of::size<Seq>::value - , typename add_reference< - typename add_const<State>::type - >::type - , Seq + , typename result_of::begin<Seq>::type + , add_reference<State> , F > {}; + template<typename Seq, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_fold<Seq, State, F>::type + fold(Seq& seq, State& state, F& f) + { + return it_fold< + typename result_of::begin<Seq>::type + , add_reference<State> + , F + >( + typename result_of::size<Seq>::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template<typename Seq, typename State, typename F> struct fold - : detail::result_of_fold< - Seq - , State - , F - , traits::is_segmented<Seq>::type::value - > + : detail::result_of_fold<Seq, State, F> {}; } template<typename Seq, typename State, typename F> @@ -358,10 +151,7 @@ namespace boost { namespace fusion >::type fold(Seq& seq, State const& state, F f) { - return result_of::fold<Seq,State const,F>::call( - state, - seq, - f); + return detail::fold<Seq, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -372,37 +162,28 @@ namespace boost { namespace fusion >::type fold(Seq const& seq, State const& state, F f) { - return result_of::fold<Seq const,State const,F>::call( - state, - seq, - f); + return detail::fold<Seq const, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq,State,F>::call( - state, - seq, - f); + return detail::fold<Seq, State, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq const,State,F>::call( - state, - seq, - f); + return detail::fold<Seq const, State, F>(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp index 1d294a8722..d49a868568 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template<typename State, typename It, typename F> - struct iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference<typename add_const<State>::type>::type, - It&) - > - {}; - template<typename Result,int N> - struct unrolled_iter_fold - { - template<typename State3, typename It3, typename F> - 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<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_iter_fold<Result,3> - { - template<typename State2, typename It2, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_iter_fold<Result,2> - { - template<typename State1, typename It1, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_iter_fold<Result,1> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template<typename Result> - struct unrolled_iter_fold<Result,0> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast<Result>(state); - } - }; - template<typename StateRef, typename It0, typename F, int N> - 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<it1>::type - it2; - typedef typename - iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next<it2>::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<typename StateRef, typename It0, typename F> - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 3 + template<int SeqSize, typename It, typename State, typename F, typename = void +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + + , bool = SeqSize == 0 +# endif > + struct result_of_it_iter_fold + {}; + template<typename It, typename State, typename F> + struct result_of_it_iter_fold<0,It,State,F + , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - 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; + typedef typename State::type type; }; - template<typename StateRef, typename It0, typename F> - 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<int SeqSize, typename It, typename State, typename F> + struct result_of_it_iter_fold<SeqSize,It,State,F + , typename boost::enable_if_has_type< +# if BOOST_WORKAROUND (BOOST_MSVC, >= 1500) + + + + typename boost::disable_if_c<SeqSize == 0, State>::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_iter_fold< + SeqSize-1 + , typename result_of::next<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + It const& + ) + > , F > {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_iter_fold< - StateRef - , It0 + template<typename It, typename State, typename F> + 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<typename It, typename State, typename F, int SeqSize> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_iter_fold< + SeqSize + , It + , State , F > - {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_iter_fold(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template<typename StateRef, typename It0, typename F, int SeqSize> - 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<int SeqSize, typename StateRef, typename Seq, typename F> - struct iter_fold_impl - { - typedef typename - result_of_first_unrollediter_fold< - StateRef - , typename result_of::begin<Seq>::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<typename StateRef, typename Seq, typename F> - 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<StateRef>(state); - } - }; - template<typename Seq, typename State, typename F, bool IsSegmented> + return it_iter_fold< + typename result_of::next<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + It const& + ) + > + , F + >( + mpl::int_<SeqSize-1>() + , fusion::next(it) + , f(state, it) + , f + ); + } + template<typename Seq, typename State, typename F + , bool = traits::is_sequence<Seq>::value + , bool = traits::is_segmented<Seq>::value> struct result_of_iter_fold - : iter_fold_impl< + {}; + template<typename Seq, typename State, typename F> + struct result_of_iter_fold<Seq, State, F, true, false> + : result_of_it_iter_fold< result_of::size<Seq>::value - , typename add_reference< - typename add_const<State>::type - >::type - , Seq + , typename result_of::begin<Seq>::type + , add_reference<State> , F > {}; + template<typename Seq, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_iter_fold<Seq, State, F>::type + iter_fold(Seq& seq, State& state, F& f) + { + return it_iter_fold< + typename result_of::begin<Seq>::type + , add_reference<State> + , F + >( + typename result_of::size<Seq>::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template<typename Seq, typename State, typename F> struct iter_fold - : detail::result_of_iter_fold< - Seq - , State - , F - , traits::is_segmented<Seq>::type::value - > + : detail::result_of_iter_fold<Seq, State, F> {}; } template<typename Seq, typename State, typename F> @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type iter_fold(Seq& seq, State const& state, F f) { - return result_of::iter_fold<Seq,State const,F>::call( - state, - seq, - f); + return detail::iter_fold<Seq, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type iter_fold(Seq const& seq, State const& state, F f) { - return result_of::iter_fold<Seq const,State const,F>::call( - state, - seq, - f); + return detail::iter_fold<Seq const, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq,State,F>::call( - state, - seq, - f); + return detail::iter_fold<Seq, State, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq const,State,F>::call( - state, - seq, - f); + return detail::iter_fold<Seq const, State, F>(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp index 947897821a..4b3b3b1e09 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template<typename State, typename It, typename F> - struct reverse_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference<typename add_const<State>::type>::type, - typename fusion::result_of::deref<It>::type) - > - {}; - template<typename Result,int N> - struct unrolled_reverse_fold - { - template<typename State3, typename It3, typename F> - 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<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_fold<Result,3> - { - template<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_fold<Result,2> - { - template<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_fold<Result,1> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template<typename Result> - struct unrolled_reverse_fold<Result,0> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast<Result>(state); - } - }; - template<typename StateRef, typename It0, typename F, int N> - 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<it1>::type - it2; - typedef typename - reverse_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior<it2>::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<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 3 + template<int SeqSize, typename It, typename State, typename F, typename = void +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + + , bool = SeqSize == 0 +# endif > + struct result_of_it_reverse_fold + {}; + template<typename It, typename State, typename F> + struct result_of_it_reverse_fold<0,It,State,F + , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - 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; + typedef typename State::type type; }; - template<typename StateRef, typename It0, typename F> - 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<int SeqSize, typename It, typename State, typename F> + struct result_of_it_reverse_fold<SeqSize,It,State,F + , typename boost::enable_if_has_type< +# if BOOST_WORKAROUND (BOOST_MSVC, >= 1500) + + + + typename boost::disable_if_c<SeqSize == 0, State>::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_reverse_fold< + SeqSize-1 + , typename result_of::prior<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + typename fusion::result_of::deref<It const>::type + ) + > , F > {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_fold< - StateRef - , It0 + template<typename It, typename State, typename F> + 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<typename It, typename State, typename F, int SeqSize> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_fold< + SeqSize + , It + , State , F > - {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_fold(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template<typename StateRef, typename It0, typename F, int SeqSize> - 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<int SeqSize, typename StateRef, typename Seq, typename F> - struct reverse_fold_impl - { - typedef typename - result_of_first_unrolledreverse_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end<Seq>::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<typename StateRef, typename Seq, typename F> - 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<StateRef>(state); - } - }; - template<typename Seq, typename State, typename F, bool IsSegmented> + return it_reverse_fold< + typename result_of::prior<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + typename fusion::result_of::deref<It const>::type + ) + > + , F + >( + mpl::int_<SeqSize-1>() + , fusion::prior(it) + , f(state, fusion::deref(it)) + , f + ); + } + template<typename Seq, typename State, typename F + , bool = traits::is_sequence<Seq>::value + , bool = traits::is_segmented<Seq>::value> struct result_of_reverse_fold - : reverse_fold_impl< + {}; + template<typename Seq, typename State, typename F> + struct result_of_reverse_fold<Seq, State, F, true, false> + : result_of_it_reverse_fold< result_of::size<Seq>::value - , typename add_reference< - typename add_const<State>::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end<Seq>::type >::type + , add_reference<State> , F > {}; + template<typename Seq, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_fold<Seq, State, F>::type + reverse_fold(Seq& seq, State& state, F& f) + { + return it_reverse_fold< + typename fusion::result_of::prior< typename result_of::end<Seq>::type >::type + , add_reference<State> + , F + >( + typename result_of::size<Seq>::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template<typename Seq, typename State, typename F> struct reverse_fold - : detail::result_of_reverse_fold< - Seq - , State - , F - , traits::is_segmented<Seq>::type::value - > + : detail::result_of_reverse_fold<Seq, State, F> {}; } template<typename Seq, typename State, typename F> @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type reverse_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_fold<Seq,State const,F>::call( - state, - seq, - f); + return detail::reverse_fold<Seq, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type reverse_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_fold<Seq const,State const,F>::call( - state, - seq, - f); + return detail::reverse_fold<Seq const, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq,State,F>::call( - state, - seq, - f); + return detail::reverse_fold<Seq, State, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq const,State,F>::call( - state, - seq, - f); + return detail::reverse_fold<Seq const, State, F>(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp index bf1edca53d..10bd9c7d3b 100644 --- a/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp @@ -7,345 +7,138 @@ This is an auto-generated file. Do not edit! ==============================================================================*/ +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) void +# else +# define BOOST_FUSION_FOLD_IMPL_ENABLER(T) typename T::type +# endif namespace boost { namespace fusion { namespace detail { - template<typename State, typename It, typename F> - struct reverse_iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference<typename add_const<State>::type>::type, - It&) - > - {}; - template<typename Result,int N> - struct unrolled_reverse_iter_fold - { - template<typename State3, typename It3, typename F> - 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<typename State2, typename It2, typename F> - 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<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_iter_fold<Result,3> - { - template<typename State2, typename It2, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template<typename State1, typename It1, typename F> - 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<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_iter_fold<Result,2> - { - template<typename State1, typename It1, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template<typename State, typename It0, typename F> - 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<typename Result> - struct unrolled_reverse_iter_fold<Result,1> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template<typename Result> - struct unrolled_reverse_iter_fold<Result,0> - { - template<typename State, typename It0, typename F> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast<Result>(state); - } - }; - template<typename StateRef, typename It0, typename F, int N> - 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<it1>::type - it2; - typedef typename - reverse_iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior<it2>::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<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 3 + template<int SeqSize, typename It, typename State, typename F, typename = void +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + + , bool = SeqSize == 0 +# endif > + struct result_of_it_reverse_iter_fold + {}; + template<typename It, typename State, typename F> + struct result_of_it_reverse_iter_fold<0,It,State,F + , typename boost::enable_if_has_type<BOOST_FUSION_FOLD_IMPL_ENABLER(State)>::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , true +# endif + > { - 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; + typedef typename State::type type; }; - template<typename StateRef, typename It0, typename F> - 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<int SeqSize, typename It, typename State, typename F> + struct result_of_it_reverse_iter_fold<SeqSize,It,State,F + , typename boost::enable_if_has_type< +# if BOOST_WORKAROUND (BOOST_MSVC, >= 1500) + + + + typename boost::disable_if_c<SeqSize == 0, State>::type::type +# else + BOOST_FUSION_FOLD_IMPL_ENABLER(State) +# endif + >::type +# if BOOST_WORKAROUND (BOOST_MSVC, < 1500) + , false +# endif + > + : result_of_it_reverse_iter_fold< + SeqSize-1 + , typename result_of::prior<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + It const& + ) + > , F > {}; - template<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 + template<typename It, typename State, typename F> + 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<typename It, typename State, typename F, int SeqSize> + 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<typename StateRef, typename It0, typename F> - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_iter_fold(mpl::int_<SeqSize>, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template<typename StateRef, typename It0, typename F, int SeqSize> - 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<int SeqSize, typename StateRef, typename Seq, typename F> - struct reverse_iter_fold_impl - { - typedef typename - result_of_first_unrolledreverse_iter_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end<Seq>::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<typename StateRef, typename Seq, typename F> - 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<StateRef>(state); - } - }; - template<typename Seq, typename State, typename F, bool IsSegmented> + return it_reverse_iter_fold< + typename result_of::prior<It>::type + , boost::result_of< + F( + typename add_reference<typename State::type>::type, + It const& + ) + > + , F + >( + mpl::int_<SeqSize-1>() + , fusion::prior(it) + , f(state, it) + , f + ); + } + template<typename Seq, typename State, typename F + , bool = traits::is_sequence<Seq>::value + , bool = traits::is_segmented<Seq>::value> struct result_of_reverse_iter_fold - : reverse_iter_fold_impl< + {}; + template<typename Seq, typename State, typename F> + struct result_of_reverse_iter_fold<Seq, State, F, true, false> + : result_of_it_reverse_iter_fold< result_of::size<Seq>::value - , typename add_reference< - typename add_const<State>::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end<Seq>::type >::type + , add_reference<State> , F > {}; + template<typename Seq, typename State, typename F> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_iter_fold<Seq, State, F>::type + reverse_iter_fold(Seq& seq, State& state, F& f) + { + return it_reverse_iter_fold< + typename fusion::result_of::prior< typename result_of::end<Seq>::type >::type + , add_reference<State> + , F + >( + typename result_of::size<Seq>::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template<typename Seq, typename State, typename F> struct reverse_iter_fold - : detail::result_of_reverse_iter_fold< - Seq - , State - , F - , traits::is_segmented<Seq>::type::value - > + : detail::result_of_reverse_iter_fold<Seq, State, F> {}; } template<typename Seq, typename State, typename F> @@ -357,10 +150,7 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_iter_fold<Seq,State const,F>::call( - state, - seq, - f); + return detail::reverse_iter_fold<Seq, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +161,28 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_iter_fold<Seq const,State const,F>::call( - state, - seq, - f); + return detail::reverse_iter_fold<Seq const, State const, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq,State,F>::call( - state, - seq, - f); + return detail::reverse_iter_fold<Seq, State, F>(seq, state, f); } template<typename Seq, typename State, typename F> 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<Seq const,State,F>::call( - state, - seq, - f); + return detail::reverse_iter_fold<Seq const, State, F>(seq, state, f); } }} diff --git a/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp b/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp index 4ff679af2e..350bff75b3 100644 --- a/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp +++ b/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp @@ -10,6 +10,7 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/algorithm/iteration/fold_fwd.hpp> #include <boost/fusion/support/segmented_fold_until.hpp> +#include <boost/mpl/bool.hpp> 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 <typename Sequence, typename State, typename Fun, bool IsSegmented> + template <typename Sequence, typename State, typename Fun, bool IsSequence, bool IsSegmented> struct result_of_fold; template <typename Sequence, typename State, typename Fun> - struct result_of_fold<Sequence, State, Fun, true> + struct result_of_fold<Sequence, State, Fun, true, true> { 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>(fun)); } diff --git a/boost/fusion/algorithm/iteration/fold.hpp b/boost/fusion/algorithm/iteration/fold.hpp index a2a0146ab4..039e01c0c7 100644 --- a/boost/fusion/algorithm/iteration/fold.hpp +++ b/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 <boost/fusion/support/config.hpp> -#include <boost/fusion/support/detail/result_of.hpp> #include <boost/fusion/algorithm/iteration/fold_fwd.hpp> #include <boost/config.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> -#include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/sequence/intrinsic/empty.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/support/is_segmented.hpp> -#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/support/is_sequence.hpp> #include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/value_of.hpp> -#include <boost/fusion/iterator/prior.hpp> #include <boost/fusion/iterator/next.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/bool.hpp> #include <boost/utility/result_of.hpp> -#include <boost/type_traits/add_const.hpp> +#include <boost/core/enable_if.hpp> #include <boost/type_traits/add_reference.hpp> #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) diff --git a/boost/fusion/algorithm/iteration/fold_fwd.hpp b/boost/fusion/algorithm/iteration/fold_fwd.hpp index f8328e80f9..0dbac7618b 100644 --- a/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/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/boost/fusion/algorithm/iteration/iter_fold.hpp b/boost/fusion/algorithm/iteration/iter_fold.hpp index b59a6957bc..cff5b4edf9 100644 --- a/boost/fusion/algorithm/iteration/iter_fold.hpp +++ b/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 <boost/fusion/algorithm/iteration/iter_fold_fwd.hpp> #include <boost/config.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> -#include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/sequence/intrinsic/empty.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/support/is_segmented.hpp> -#include <boost/fusion/support/detail/result_of.hpp> -#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/support/is_sequence.hpp> #include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/value_of.hpp> -#include <boost/fusion/iterator/prior.hpp> #include <boost/fusion/iterator/next.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/type_traits/add_const.hpp> +#include <boost/utility/result_of.hpp> +#include <boost/core/enable_if.hpp> #include <boost/type_traits/add_reference.hpp> #define BOOST_FUSION_ITER_FOLD diff --git a/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index 6c595cf198..1d8543ca5f 100644 --- a/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/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/boost/fusion/algorithm/iteration/reverse_fold.hpp b/boost/fusion/algorithm/iteration/reverse_fold.hpp index dffff79e14..252ad30836 100644 --- a/boost/fusion/algorithm/iteration/reverse_fold.hpp +++ b/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 <boost/fusion/support/config.hpp> -#include <boost/fusion/support/detail/result_of.hpp> #include <boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp> #include <boost/config.hpp> -#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/sequence/intrinsic/empty.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/support/is_segmented.hpp> -#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/support/is_sequence.hpp> #include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/value_of.hpp> #include <boost/fusion/iterator/prior.hpp> -#include <boost/fusion/iterator/next.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/bool.hpp> #include <boost/utility/result_of.hpp> -#include <boost/type_traits/add_const.hpp> +#include <boost/core/enable_if.hpp> #include <boost/type_traits/add_reference.hpp> #define BOOST_FUSION_REVERSE_FOLD diff --git a/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index 42c8ac2163..c5e24b34a9 100644 --- a/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/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/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp b/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp index d36861f37b..3276bbde57 100644 --- a/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp +++ b/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 <boost/fusion/support/config.hpp> -#include <boost/fusion/support/detail/result_of.hpp> #include <boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp> #include <boost/config.hpp> -#include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/sequence/intrinsic/empty.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/support/is_segmented.hpp> -#include <boost/fusion/iterator/equal_to.hpp> +#include <boost/fusion/support/is_sequence.hpp> #include <boost/fusion/iterator/deref.hpp> #include <boost/fusion/iterator/value_of.hpp> #include <boost/fusion/iterator/prior.hpp> -#include <boost/fusion/iterator/next.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/bool.hpp> #include <boost/utility/result_of.hpp> -#include <boost/type_traits/add_const.hpp> +#include <boost/core/enable_if.hpp> #include <boost/type_traits/add_reference.hpp> #define BOOST_FUSION_REVERSE_FOLD diff --git a/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 21d99deead..76f0186392 100644 --- a/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/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/boost/fusion/algorithm/transformation/erase.hpp b/boost/fusion/algorithm/transformation/erase.hpp index 0f3b8a1519..8eebc357bb 100644 --- a/boost/fusion/algorithm/transformation/erase.hpp +++ b/boost/fusion/algorithm/transformation/erase.hpp @@ -10,7 +10,6 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/iterator/equal_to.hpp> #include <boost/fusion/iterator/mpl/convert_iterator.hpp> -#include <boost/fusion/container/vector/vector10.hpp> #include <boost/fusion/view/joint_view/joint_view.hpp> #include <boost/fusion/view/iterator_range/iterator_range.hpp> #include <boost/fusion/support/detail/as_fusion_element.hpp> diff --git a/boost/fusion/algorithm/transformation/flatten.hpp b/boost/fusion/algorithm/transformation/flatten.hpp index e3cfa983a5..43ac34dfe6 100644 --- a/boost/fusion/algorithm/transformation/flatten.hpp +++ b/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/boost/fusion/algorithm/transformation/insert.hpp b/boost/fusion/algorithm/transformation/insert.hpp index 44e596537e..c6d5219d69 100644 --- a/boost/fusion/algorithm/transformation/insert.hpp +++ b/boost/fusion/algorithm/transformation/insert.hpp @@ -10,7 +10,6 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/support/detail/as_fusion_element.hpp> #include <boost/fusion/iterator/mpl/convert_iterator.hpp> -#include <boost/fusion/container/vector/vector10.hpp> #include <boost/fusion/view/joint_view/joint_view.hpp> #include <boost/fusion/view/single_view/single_view.hpp> #include <boost/fusion/view/iterator_range/iterator_range.hpp> diff --git a/boost/fusion/algorithm/transformation/insert_range.hpp b/boost/fusion/algorithm/transformation/insert_range.hpp index 40e64e1f5e..57878309a1 100644 --- a/boost/fusion/algorithm/transformation/insert_range.hpp +++ b/boost/fusion/algorithm/transformation/insert_range.hpp @@ -9,7 +9,6 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/iterator/mpl/convert_iterator.hpp> -#include <boost/fusion/container/vector/vector10.hpp> #include <boost/fusion/view/joint_view/joint_view.hpp> #include <boost/fusion/view/iterator_range/iterator_range.hpp> #include <boost/fusion/support/detail/as_fusion_element.hpp> diff --git a/boost/fusion/container/deque/deque.hpp b/boost/fusion/container/deque/deque.hpp index 96919052e7..dee51befcd 100644 --- a/boost/fusion/container/deque/deque.hpp +++ b/boost/fusion/container/deque/deque.hpp @@ -149,7 +149,8 @@ namespace boost { namespace fusion template <typename Sequence> BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit deque(Sequence const& seq - , typename disable_if<is_convertible<Sequence, Head> >::type* /*dummy*/ = 0) + , typename disable_if<is_convertible<Sequence, Head> >::type* /*dummy*/ = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/boost/fusion/container/deque/detail/convert_impl.hpp b/boost/fusion/container/deque/detail/convert_impl.hpp index ba9b847773..ede0cc48fe 100644 --- a/boost/fusion/container/deque/detail/convert_impl.hpp +++ b/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 <boost/fusion/container/deque/convert.hpp> #include <boost/fusion/container/deque/deque.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> -#include <boost/fusion/sequence/intrinsic/size.hpp> +#include <boost/fusion/sequence/intrinsic/end.hpp> 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/boost/fusion/container/deque/detail/cpp03/build_deque.hpp b/boost/fusion/container/deque/detail/cpp03/build_deque.hpp index 99cbe58493..587aa3b06c 100644 --- a/boost/fusion/container/deque/detail/cpp03/build_deque.hpp +++ b/boost/fusion/container/deque/detail/cpp03/build_deque.hpp @@ -22,6 +22,7 @@ namespace boost { namespace fusion { template <typename Sequence> struct as_deque + : detail::as_deque<result_of::size<Sequence>::value> { typedef typename detail::as_deque<result_of::size<Sequence>::value> diff --git a/boost/fusion/container/deque/detail/cpp03/deque.hpp b/boost/fusion/container/deque/detail/cpp03/deque.hpp index db8a967ab0..a65fa4acbd 100644 --- a/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -101,7 +101,9 @@ namespace boost { namespace fusion { template<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* /*dummy*/ = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* /*dummy*/ = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp index ae1828a5f7..95cd8c1cba 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp +++ b/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<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9> diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp index 78224634bb..ad06945135 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp +++ b/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<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19> diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp index 8653217bc0..44a5b2b103 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp +++ b/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<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19 , typename U20 , typename U21 , typename U22 , typename U23 , typename U24 , typename U25 , typename U26 , typename U27 , typename U28 , typename U29> diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp index 3bfd488af2..e642288eb7 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp +++ b/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<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19 , typename U20 , typename U21 , typename U22 , typename U23 , typename U24 , typename U25 , typename U26 , typename U27 , typename U28 , typename U29 , typename U30 , typename U31 , typename U32 , typename U33 , typename U34 , typename U35 , typename U36 , typename U37 , typename U38 , typename U39> diff --git a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp b/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp index 04441da66c..a387708bca 100644 --- a/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp +++ b/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<typename Sequence> BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if<is_convertible<Sequence, T0> >::type* = 0) + deque(Sequence const& seq + , typename disable_if<is_convertible<Sequence, T0> >::type* = 0 + , typename enable_if<traits::is_sequence<Sequence> >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template <typename U0 , typename U1 , typename U2 , typename U3 , typename U4 , typename U5 , typename U6 , typename U7 , typename U8 , typename U9 , typename U10 , typename U11 , typename U12 , typename U13 , typename U14 , typename U15 , typename U16 , typename U17 , typename U18 , typename U19 , typename U20 , typename U21 , typename U22 , typename U23 , typename U24 , typename U25 , typename U26 , typename U27 , typename U28 , typename U29 , typename U30 , typename U31 , typename U32 , typename U33 , typename U34 , typename U35 , typename U36 , typename U37 , typename U38 , typename U39 , typename U40 , typename U41 , typename U42 , typename U43 , typename U44 , typename U45 , typename U46 , typename U47 , typename U48 , typename U49> diff --git a/boost/fusion/container/generation/make_set.hpp b/boost/fusion/container/generation/make_set.hpp index 705ec582a8..cd8519e54d 100644 --- a/boost/fusion/container/generation/make_set.hpp +++ b/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 <boost/fusion/support/config.hpp> #include <boost/fusion/container/set/set.hpp> +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include <boost/fusion/container/generation/detail/pp_make_set.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include <boost/fusion/support/detail/as_fusion_element.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <utility> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename ...T> + struct make_set + { + typedef set< + typename detail::as_fusion_element< + typename remove_const< + typename remove_reference<T>::type + >::type + >::type... + > type; + }; + } + + template <typename ...T> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_set<T...>::type + make_set(T&&... arg) + { + return typename result_of::make_set<T...>::type(std::forward<T>(arg)...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/generation/make_vector.hpp b/boost/fusion/container/generation/make_vector.hpp index 8f0674815e..cd3b992bb5 100644 --- a/boost/fusion/container/generation/make_vector.hpp +++ b/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 <boost/fusion/support/config.hpp> #include <boost/fusion/container/vector/vector.hpp> +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/generation/detail/pp_make_vector.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include <boost/fusion/support/detail/as_fusion_element.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <utility> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename ...T> + struct make_vector + { + // make `make_vector<T..., void_...>' into `make_vector<T...>' + template <typename, typename...> struct trim_void; + + template <typename... U> + struct trim_void<vector<U...> > + { + typedef vector<U...> type; + }; + + template <typename... U, typename... Tail> + struct trim_void<vector<U...>, void_, Tail...> + : trim_void<vector<U...> > { }; + + template <typename... U, typename Head, typename... Tail> + struct trim_void<vector<U...>, Head, Tail...> + : trim_void<vector<U..., Head>, Tail...> { }; + + typedef + typename trim_void< + vector<> + , typename detail::as_fusion_element< + typename remove_const< + typename remove_reference<T>::type + >::type + >::type... + >::type + type; + }; + } + + template <typename ...T> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_vector<T...>::type + make_vector(T&&... arg) + { + return typename result_of::make_vector<T...>::type(std::forward<T>(arg)...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/generation/vector_tie.hpp b/boost/fusion/container/generation/vector_tie.hpp index 5bb4face4d..5d7cb98bc2 100644 --- a/boost/fusion/container/generation/vector_tie.hpp +++ b/boost/fusion/container/generation/vector_tie.hpp @@ -8,8 +8,37 @@ #define FUSION_VECTOR_TIE_11112014_2302 #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/generation/detail/pp_vector_tie.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename ...T> + struct vector_tie + { + typedef vector<T&...> type; + }; + } + + template <typename ...T> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline vector<T&...> + vector_tie(T&... arg) + { + return vector<T&...>(arg...); + } + }} + + +#endif #endif diff --git a/boost/fusion/container/set/detail/as_set.hpp b/boost/fusion/container/set/detail/as_set.hpp index 1eb0d3fe12..9d33325818 100644 --- a/boost/fusion/container/set/detail/as_set.hpp +++ b/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 <boost/fusion/container/set/detail/cpp03/as_set.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/support/detail/index_sequence.hpp> +#include <boost/fusion/container/set/set.hpp> +#include <boost/fusion/iterator/value_of.hpp> +#include <boost/fusion/iterator/deref.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <cstddef> + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template <int size + , typename = typename detail::make_index_sequence<size>::type> + struct as_set; + + template <int size, std::size_t ...Indices> + struct as_set<size, detail::index_sequence<Indices...> > + { + template <typename I> + struct apply + { + typedef set< + typename result_of::value_of< + typename result_of::advance_c<I, Indices>::type + >::type... + > type; + }; + + template <typename Iterator> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply<Iterator>::type + call(Iterator const& i) + { + typedef apply<Iterator> gen; + typedef typename gen::type result; + return result(*advance_c<Indices>(i)...); + } + }; + +BOOST_FUSION_BARRIER_END +}}} + +#endif #endif diff --git a/boost/fusion/container/set/detail/convert_impl.hpp b/boost/fusion/container/set/detail/convert_impl.hpp index d9d5dcfcd3..0b4cb22f32 100644 --- a/boost/fusion/container/set/detail/convert_impl.hpp +++ b/boost/fusion/container/set/detail/convert_impl.hpp @@ -29,7 +29,7 @@ namespace boost { namespace fusion template <typename Sequence> struct apply { - typedef typename detail::as_set<result_of::size<Sequence>::value> gen; + typedef detail::as_set<result_of::size<Sequence>::value> gen; typedef typename gen:: template apply<typename result_of::begin<Sequence>::type>::type type; diff --git a/boost/fusion/container/set/set.hpp b/boost/fusion/container/set/set.hpp index 59f4eafc02..12fd8115d6 100644 --- a/boost/fusion/container/set/set.hpp +++ b/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 <boost/fusion/container/set/detail/cpp03/set.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/support/detail/access.hpp> +#include <boost/fusion/support/sequence_base.hpp> +#include <boost/fusion/support/category_of.hpp> +#include <boost/fusion/support/is_sequence.hpp> +#include <boost/fusion/support/detail/is_same_size.hpp> +#include <boost/fusion/container/vector/vector.hpp> +#include <boost/fusion/container/set/detail/begin_impl.hpp> +#include <boost/fusion/container/set/detail/end_impl.hpp> +#include <boost/fusion/container/set/detail/value_of_impl.hpp> +#include <boost/fusion/container/set/detail/deref_data_impl.hpp> +#include <boost/fusion/container/set/detail/deref_impl.hpp> +#include <boost/fusion/container/set/detail/key_of_impl.hpp> +#include <boost/fusion/container/set/detail/value_of_data_impl.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/core/enable_if.hpp> + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; + + template <> + struct set<> : sequence_base<set<> > + { + 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 <typename Sequence> + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs, + typename enable_if<traits::is_sequence<Sequence> >::type* = 0, + typename enable_if<detail::is_same_size<Sequence, storage_type> >::type* = 0) + : data(rhs) {} + + template <typename T> + 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 <typename ...T> + struct set : sequence_base<set<T...> > + { + 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<T...> storage_type; + + typedef typename storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template <typename Sequence> + BOOST_FUSION_GPU_ENABLED + set(Sequence&& rhs, + typename enable_if<traits::is_sequence<Sequence> >::type* = 0, + typename enable_if<detail::is_same_size<Sequence, storage_type> >::type* = 0) + : data(std::forward<Sequence>(rhs)) {} + + template <typename ...U> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(U&& ...args) + : data(std::forward<U>(args)...) {} + + template <typename U> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U&& rhs) + { + data = std::forward<U>(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/boost/fusion/container/set/set_fwd.hpp b/boost/fusion/container/set/set_fwd.hpp index 50d8d1c8bd..7b5d6830a5 100644 --- a/boost/fusion/container/set/set_fwd.hpp +++ b/boost/fusion/container/set/set_fwd.hpp @@ -9,11 +9,38 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> + +#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 <boost/fusion/container/set/detail/cpp03/set_fwd.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct set_tag; + struct set_iterator_tag; + + template <typename ...T> + struct set; +}} + +#endif #endif diff --git a/boost/fusion/container/vector.hpp b/boost/fusion/container/vector.hpp index a999c8b023..41c980331e 100644 --- a/boost/fusion/container/vector.hpp +++ b/boost/fusion/container/vector.hpp @@ -8,25 +8,8 @@ #define FUSION_SEQUENCE_CLASS_VECTOR_10022005_0602 #include <boost/fusion/support/config.hpp> -#include <boost/fusion/container/vector/detail/cpp03/limits.hpp> - -#include <boost/fusion/container/vector/vector10.hpp> -#if (FUSION_MAX_VECTOR_SIZE > 10) -#include <boost/fusion/container/vector/vector20.hpp> -#endif -#if (FUSION_MAX_VECTOR_SIZE > 20) -#include <boost/fusion/container/vector/vector30.hpp> -#endif -#if (FUSION_MAX_VECTOR_SIZE > 30) -#include <boost/fusion/container/vector/vector40.hpp> -#endif -#if (FUSION_MAX_VECTOR_SIZE > 40) -#include <boost/fusion/container/vector/vector50.hpp> -#endif - -#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/vector_fwd.hpp> -#include <boost/fusion/container/vector/vector_iterator.hpp> +#include <boost/fusion/container/vector/vector.hpp> #include <boost/fusion/container/vector/convert.hpp> #endif diff --git a/boost/fusion/container/vector/detail/as_vector.hpp b/boost/fusion/container/vector/detail/as_vector.hpp index eaaac89638..e2f45b6a04 100644 --- a/boost/fusion/container/vector/detail/as_vector.hpp +++ b/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 <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/as_vector.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/support/detail/index_sequence.hpp> +#include <boost/fusion/container/vector/vector.hpp> +#include <boost/fusion/iterator/value_of.hpp> +#include <boost/fusion/iterator/deref.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <cstddef> + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template <typename Indices> + struct as_vector_impl; + + template <std::size_t ...Indices> + struct as_vector_impl<index_sequence<Indices...> > + { + template <typename Iterator> + struct apply + { + typedef vector< + typename result_of::value_of< + typename result_of::advance_c<Iterator, Indices>::type + >::type... + > type; + }; + + template <typename Iterator> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply<Iterator>::type + call(Iterator i) + { + typedef typename apply<Iterator>::type result; + return result(*advance_c<Indices>(i)...); + } + }; + + template <int size> + struct as_vector + : as_vector_impl<typename make_index_sequence<size>::type> {}; + +BOOST_FUSION_BARRIER_END +}}} + +#endif #endif diff --git a/boost/fusion/container/vector/detail/at_impl.hpp b/boost/fusion/container/vector/detail/at_impl.hpp index cb98dd4a25..a2900d7943 100644 --- a/boost/fusion/container/vector/detail/at_impl.hpp +++ b/boost/fusion/container/vector/detail/at_impl.hpp @@ -9,9 +9,8 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/support/detail/access.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/int.hpp> +#include <boost/fusion/container/vector/detail/value_at_impl.hpp> +#include <boost/static_assert.hpp> namespace boost { namespace fusion { @@ -28,7 +27,7 @@ namespace boost { namespace fusion template <typename Sequence, typename N> struct apply { - typedef typename mpl::at<typename Sequence::types, N>::type element; + typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element; typedef typename detail::ref_result<element>::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -43,7 +42,7 @@ namespace boost { namespace fusion template <typename Sequence, typename N> struct apply <Sequence const, N> { - typedef typename mpl::at<typename Sequence::types, N>::type element; + typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element; typedef typename detail::cref_result<element>::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/boost/fusion/container/vector/detail/config.hpp b/boost/fusion/container/vector/detail/config.hpp new file mode 100644 index 0000000000..84f4605d2e --- /dev/null +++ b/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 <boost/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/fusion/support/config.hpp> + +#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/boost/fusion/container/vector/detail/cpp03/limits.hpp b/boost/fusion/container/vector/detail/cpp03/limits.hpp index 6e106144bb..74a05102d2 100644 --- a/boost/fusion/container/vector/detail/cpp03/limits.hpp +++ b/boost/fusion/container/vector/detail/cpp03/limits.hpp @@ -9,6 +9,7 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/support/detail/pp_round.hpp> +#include <boost/preprocessor/stringize.hpp> #if !defined(FUSION_MAX_VECTOR_SIZE) # define FUSION_MAX_VECTOR_SIZE 10 diff --git a/boost/fusion/container/vector/detail/deref_impl.hpp b/boost/fusion/container/vector/detail/deref_impl.hpp index 5186aa1047..c85bb82b3b 100644 --- a/boost/fusion/container/vector/detail/deref_impl.hpp +++ b/boost/fusion/container/vector/detail/deref_impl.hpp @@ -8,8 +8,8 @@ #define FUSION_DEREF_IMPL_05042005_1037 #include <boost/fusion/support/config.hpp> -#include <boost/mpl/at.hpp> #include <boost/fusion/support/detail/access.hpp> +#include <boost/fusion/container/vector/detail/value_at_impl.hpp> #include <boost/type_traits/is_const.hpp> #include <boost/mpl/if.hpp> @@ -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<vector_tag>::template apply<vector, index>::type element; typedef typename mpl::if_< diff --git a/boost/fusion/container/vector/detail/value_at_impl.hpp b/boost/fusion/container/vector/detail/value_at_impl.hpp index f71ca8486d..6c8c41fb27 100644 --- a/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -9,11 +9,50 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/value_at_impl.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/type_traits/declval.hpp> +#include <boost/type_traits/remove_cv.hpp> + +namespace boost { namespace fusion +{ + struct vector_tag; + + namespace vector_detail + { + template <typename I, typename ...T> + struct vector_data; + } + + namespace extension + { + template <typename Tag> + struct value_at_impl; + + template <> + struct value_at_impl<vector_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename boost::remove_cv<Sequence>::type seq; + typedef typename mpl::identity<decltype(seq::template value_at_impl<N::value>(boost::declval<seq*>()))>::type::type type; + }; + }; + } +}} + +#endif #endif diff --git a/boost/fusion/container/vector/detail/value_of_impl.hpp b/boost/fusion/container/vector/detail/value_of_impl.hpp index 2a8acf912d..d67ab3fcc2 100644 --- a/boost/fusion/container/vector/detail/value_of_impl.hpp +++ b/boost/fusion/container/vector/detail/value_of_impl.hpp @@ -8,7 +8,7 @@ #define FUSION_VALUE_OF_IMPL_05052005_1128 #include <boost/fusion/support/config.hpp> -#include <boost/mpl/at.hpp> +#include <boost/fusion/container/vector/detail/value_at_impl.hpp> 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<vector_tag>::template apply<vector, index>::type type; }; }; } diff --git a/boost/fusion/container/vector/vector.hpp b/boost/fusion/container/vector/vector.hpp index 2b9f0ce5ca..845a019e6b 100644 --- a/boost/fusion/container/vector/vector.hpp +++ b/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,332 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> #include <boost/fusion/container/vector/vector_fwd.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/support/sequence_base.hpp> +#include <boost/fusion/support/is_sequence.hpp> +#include <boost/fusion/support/detail/index_sequence.hpp> +#include <boost/fusion/container/vector/detail/at_impl.hpp> +#include <boost/fusion/container/vector/detail/value_at_impl.hpp> +#include <boost/fusion/container/vector/detail/begin_impl.hpp> +#include <boost/fusion/container/vector/detail/end_impl.hpp> +#include <boost/fusion/sequence/intrinsic/size.hpp> +#include <boost/fusion/sequence/intrinsic/begin.hpp> +#include <boost/fusion/iterator/advance.hpp> +#include <boost/fusion/iterator/deref.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <cstddef> +#include <utility> + +namespace boost { namespace fusion +{ + struct vector_tag; + struct random_access_traversal_tag; + + namespace vector_detail + { + struct each_elem {}; + struct copy_or_move {}; + template <typename I> struct from_sequence {}; + + template <typename Sequence> + struct make_indices_from_seq + : detail::make_index_sequence< + fusion::result_of::size<typename remove_reference<Sequence>::type>::value + > + {}; + + template <typename T> + struct pure : remove_cv<typename remove_reference<T>::type> {}; + + template <typename Sequence, typename This, int = result_of::size<This>::value> + struct is_convertible_to_first + : boost::is_convertible<Sequence, typename result_of::value_at_c<This, 0>::type> + {}; + + template <typename Sequence, typename This> + struct is_convertible_to_first<Sequence, This, 0> + : mpl::false_ + {}; + + template <typename This, typename ...T> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline each_elem + dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); } + + template <typename This> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline copy_or_move + dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); } + + template <typename This, typename Sequence> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline from_sequence< + typename lazy_enable_if_c< + (traits::is_sequence<typename remove_reference<Sequence>::type>::value && + !is_same<This, typename pure<Sequence>::type>::value && + !is_convertible_to_first<Sequence, This>::value) + , make_indices_from_seq<Sequence> + >::type + > + dispatch(Sequence&&) BOOST_NOEXCEPT + { return from_sequence<typename make_indices_from_seq<Sequence>::type>(); } + + + // forward_at_c allows to access Nth element even if ForwardSequence + // since fusion::at_c requires RandomAccessSequence. + namespace result_of + { + template <typename Sequence, int N> + struct forward_at_c + : fusion::result_of::deref< + typename fusion::result_of::advance_c< + typename fusion::result_of::begin< + typename remove_reference<Sequence>::type + >::type + , N + >::type + > + {}; + } + + template <int N, typename Sequence> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::forward_at_c<Sequence, N>::type + forward_at_c(Sequence&& seq) + { + typedef typename + result_of::forward_at_c<Sequence, N>::type + result; + return std::forward<result>(*advance_c<N>(begin(seq))); + } + + // Object proxy since preserve object order + template <std::size_t, typename T> + 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<T&&>(rhs.get())) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store&& rhs) + { + elem = static_cast<T&&>(rhs.get()); + return *this; + } + + template <typename U> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(U&& rhs + , typename disable_if<is_same<typename pure<U>::type, store> >::type* = 0) + : elem(std::forward<U>(rhs)) + {} + + template <typename U> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename disable_if<is_same<typename pure<U>::type, store>, store&>::type + operator=(U&& rhs) + { + elem = std::forward<U>(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 <typename I, typename ...T> + struct vector_data; + + template <std::size_t ...I, typename ...T> + struct vector_data<detail::index_sequence<I...>, T...> + : store<I, T>... + , sequence_base<vector_data<detail::index_sequence<I...>, 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_<sizeof...(T)> size; + typedef vector<T...> 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<I, T>(static_cast<store<I, T> const&>(rhs))... + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data&& rhs) + : store<I, T>(std::forward<store<I, T> >(rhs))... + {} + + template <typename Sequence> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(from_sequence<detail::index_sequence<I...> >, Sequence&& rhs) + : store<I, T>(forward_at_c<I>(rhs))... + {} + + template <typename ...U> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(each_elem, U&&... var) + : store<I, T>(std::forward<U>(var))... + {} + + template <typename Sequence> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&&, detail::index_sequence<>) {} + + template <typename Sequence, std::size_t N, std::size_t ...M> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&& seq, detail::index_sequence<N, M...>) + { + at_impl(mpl::int_<N>()) = vector_detail::forward_at_c<N>(seq); + assign(std::forward<Sequence>(seq), detail::index_sequence<M...>()); + } + + template <std::size_t N, typename U> + static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store<N, U>* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template <std::size_t N, typename U> + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store<N, U> const* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template <typename J> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) -> decltype(at_detail<J::value>(this)) + { + return at_detail<J::value>(this); + } + + template <typename J> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_impl(J) const -> decltype(at_detail<J::value>(this)) + { + return at_detail<J::value>(this); + } + + template <std::size_t N, typename U> + static BOOST_FUSION_GPU_ENABLED + mpl::identity<U> value_at_impl(store<N, U>*); + }; + + template <typename V, typename... T> + struct trim_void_; + + template <typename... T> + struct trim_void_<vector<T...> > + { + typedef vector_data< + typename detail::make_index_sequence<sizeof...(T)>::type + , T... + > type; + }; + + template <typename... T, typename... Tail> + struct trim_void_<vector<T...>, void_, Tail...> + : trim_void_<vector<T...> > {}; + + template <typename... T, typename Head, typename... Tail> + struct trim_void_<vector<T...>, Head, Tail...> + : trim_void_<vector<T..., Head>, Tail...> {}; + + template <typename... T> + struct trim_void : trim_void_<vector<>, T...> {}; + } // namespace boost::fusion::vector_detail + + // This class provides backward compatibility: vector<T, ..., void_, void_, ...>. + template <typename... T> + struct vector + : vector_detail::trim_void<T...>::type + { + typedef typename vector_detail::trim_void<T...>::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 <typename... U> + // 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<vector>(std::forward<U>(u)...), std::forward<U>(u)...) + {} + + template <typename Sequence> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector& + operator=(Sequence&& rhs) + { + typedef typename + vector_detail::make_indices_from_seq<Sequence>::type + indices; + base::assign(std::forward<Sequence>(rhs), indices()); + return *this; + } + }; +}} + +#endif #endif diff --git a/boost/fusion/container/vector/vector10.hpp b/boost/fusion/container/vector/vector10.hpp index f152bfe161..65722fe64a 100644 --- a/boost/fusion/container/vector/vector10.hpp +++ b/boost/fusion/container/vector/vector10.hpp @@ -9,11 +9,21 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector10.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/fusion/container/vector/vector.hpp> + +#endif #endif diff --git a/boost/fusion/container/vector/vector20.hpp b/boost/fusion/container/vector/vector20.hpp index c5be355df6..c36e50c7d2 100644 --- a/boost/fusion/container/vector/vector20.hpp +++ b/boost/fusion/container/vector/vector20.hpp @@ -9,11 +9,21 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector20.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/fusion/container/vector/vector.hpp> + +#endif #endif diff --git a/boost/fusion/container/vector/vector30.hpp b/boost/fusion/container/vector/vector30.hpp index 1a528cb578..e9f891f28b 100644 --- a/boost/fusion/container/vector/vector30.hpp +++ b/boost/fusion/container/vector/vector30.hpp @@ -9,11 +9,21 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector30.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/fusion/container/vector/vector.hpp> + +#endif #endif diff --git a/boost/fusion/container/vector/vector40.hpp b/boost/fusion/container/vector/vector40.hpp index 5faa7d595b..4b753a084e 100644 --- a/boost/fusion/container/vector/vector40.hpp +++ b/boost/fusion/container/vector/vector40.hpp @@ -9,11 +9,21 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector40.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/fusion/container/vector/vector.hpp> + +#endif #endif diff --git a/boost/fusion/container/vector/vector50.hpp b/boost/fusion/container/vector/vector50.hpp index 7b7e7a8a18..5d8d356313 100644 --- a/boost/fusion/container/vector/vector50.hpp +++ b/boost/fusion/container/vector/vector50.hpp @@ -9,11 +9,21 @@ #include <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector50.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector_fwd.hpp> +#include <boost/fusion/container/vector/vector.hpp> + +#endif #endif diff --git a/boost/fusion/container/vector/vector_fwd.hpp b/boost/fusion/container/vector/vector_fwd.hpp index b63099ce9d..dcb0a0fc0c 100644 --- a/boost/fusion/container/vector/vector_fwd.hpp +++ b/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 <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/container/vector/detail/cpp03/vector_fwd.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> + +namespace boost { namespace fusion +{ + template <typename ...T> + struct vector; + +#define FUSION_VECTOR_N_ALIASES(z, N, d) \ + template <typename ...T> \ + using BOOST_PP_CAT(vector, N) = vector<T...>; + + BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~) + +#undef FUSION_VECTOR_N_ALIASES +}} + +#endif #endif diff --git a/boost/fusion/functional/adapter/limits.hpp b/boost/fusion/functional/adapter/limits.hpp index cdcdf8210e..9fb5a2a2cc 100644 --- a/boost/fusion/functional/adapter/limits.hpp +++ b/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 <boost/fusion/container/vector/detail/cpp03/limits.hpp> +# include <boost/fusion/container/vector/detail/config.hpp> +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# include <boost/fusion/container/vector/detail/cpp03/limits.hpp> +# 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/boost/fusion/functional/invocation/invoke.hpp b/boost/fusion/functional/invocation/invoke.hpp index b79ff5b439..09f3ead87f 100644 --- a/boost/fusion/functional/invocation/invoke.hpp +++ b/boost/fusion/functional/invocation/invoke.hpp @@ -39,9 +39,9 @@ #include <boost/function_types/parameter_types.hpp> #include <boost/utility/result_of.hpp> +#include <boost/core/enable_if.hpp> #include <boost/fusion/support/category_of.hpp> -#include <boost/fusion/support/detail/enabler.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/front.hpp> @@ -148,7 +148,7 @@ namespace boost { namespace fusion template <typename Function, class Sequence> struct invoke<Function, Sequence, - typename detail::enabler< + typename enable_if_has_type< typename detail::invoke_impl< typename boost::remove_reference<Function>::type, Sequence >::result_type @@ -195,7 +195,7 @@ namespace boost { namespace fusion template <typename Function, class Sequence> struct invoke_impl<Function,Sequence,N,false,true, - typename enabler< + typename enable_if_has_type< typename boost::result_of<Function(BOOST_PP_ENUM(N,M,~)) >::type >::type> { @@ -289,7 +289,7 @@ namespace boost { namespace fusion template <typename Function, class Sequence> struct invoke_impl<Function,Sequence,N,false,false, - typename enabler< + typename enable_if_has_type< #define L(z,j,data) typename invoke_param_types<Sequence,N>::BOOST_PP_CAT(T, j) typename boost::result_of<Function(BOOST_PP_ENUM(N,L,~))>::type >::type> diff --git a/boost/fusion/functional/invocation/invoke_function_object.hpp b/boost/fusion/functional/invocation/invoke_function_object.hpp index 3ed508dd3d..2a88eaec19 100644 --- a/boost/fusion/functional/invocation/invoke_function_object.hpp +++ b/boost/fusion/functional/invocation/invoke_function_object.hpp @@ -18,14 +18,12 @@ #include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/utility/result_of.hpp> +#include <boost/core/enable_if.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/remove_const.hpp> -#include <boost/utility/result_of.hpp> - #include <boost/fusion/support/category_of.hpp> -#include <boost/fusion/support/detail/enabler.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> @@ -62,7 +60,7 @@ namespace boost { namespace fusion template <class Function, class Sequence> struct invoke_function_object<Function, Sequence, - typename detail::enabler< + typename enable_if_has_type< typename detail::invoke_function_object_impl< typename boost::remove_reference<Function>::type, Sequence >::result_type @@ -110,7 +108,7 @@ namespace boost { namespace fusion template <class Function, class Sequence> struct invoke_function_object_impl<Function,Sequence,N,true, - typename enabler< + typename enable_if_has_type< typename boost::result_of<Function (BOOST_PP_ENUM(N,M,~)) >::type >::type> { @@ -151,7 +149,7 @@ namespace boost { namespace fusion template <class Function, class Sequence> struct invoke_function_object_impl<Function,Sequence,N,false, - typename enabler< + typename enable_if_has_type< typename boost::result_of<Function (BOOST_PP_ENUM(N,M,~)) >::type >::type> #undef M diff --git a/boost/fusion/functional/invocation/invoke_procedure.hpp b/boost/fusion/functional/invocation/invoke_procedure.hpp index a0fe73a6f3..971ddbfdea 100644 --- a/boost/fusion/functional/invocation/invoke_procedure.hpp +++ b/boost/fusion/functional/invocation/invoke_procedure.hpp @@ -20,6 +20,7 @@ #include <boost/preprocessor/repetition/enum_shifted_params.hpp> #include <boost/type_traits/remove_reference.hpp> +#include <boost/core/enable_if.hpp> #include <boost/mpl/front.hpp> @@ -28,7 +29,6 @@ #include <boost/function_types/parameter_types.hpp> #include <boost/fusion/support/category_of.hpp> -#include <boost/fusion/support/detail/enabler.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp> #include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> @@ -66,7 +66,7 @@ namespace boost { namespace fusion template <typename Function, class Sequence> struct invoke_procedure<Function, Sequence, - typename detail::enabler< + typename enable_if_has_type< typename detail::invoke_procedure_impl< typename boost::remove_reference<Function>::type,Sequence >::result_type diff --git a/boost/fusion/sequence/io/detail/manip.hpp b/boost/fusion/sequence/io/detail/manip.hpp index ec8ce304f6..68f7ab4f91 100644 --- a/boost/fusion/sequence/io/detail/manip.hpp +++ b/boost/fusion/sequence/io/detail/manip.hpp @@ -110,8 +110,7 @@ namespace boost { namespace fusion { // read a delimiter string_type const* p = stream_data_t::get(stream); - using namespace std; - ws(stream); + std::ws(stream); if (p) { diff --git a/boost/fusion/support/detail/enabler.hpp b/boost/fusion/support/detail/enabler.hpp deleted file mode 100644 index 48b69f3227..0000000000 --- a/boost/fusion/support/detail/enabler.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/*============================================================================= - 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). -==============================================================================*/ -#ifndef FUSION_DETAIL_ENABLER_02082015_163810 -#define FUSION_DETAIL_ENABLER_02082015_163810 - -namespace boost { namespace fusion { namespace detail -{ - template <typename, typename T = void> - struct enabler { typedef T type; }; -}}} - -#endif - diff --git a/boost/fusion/support/detail/is_same_size.hpp b/boost/fusion/support/detail/is_same_size.hpp new file mode 100644 index 0000000000..b1bf7cde41 --- /dev/null +++ b/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 <boost/fusion/support/is_sequence.hpp> +#include <boost/fusion/sequence/intrinsic/size.hpp> +#include <boost/core/enable_if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/equal_to.hpp> + +namespace boost { namespace fusion { namespace detail +{ + template <typename Sequence1, typename Sequence2, typename = void, typename = void> + struct is_same_size : mpl::false_ {}; + + template <typename Sequence1, typename Sequence2> + struct is_same_size<Sequence1, Sequence2, + typename enable_if<traits::is_sequence<Sequence1> >::type, + typename enable_if<traits::is_sequence<Sequence2> >::type> + : mpl::equal_to<result_of::size<Sequence1>, result_of::size<Sequence2> > + {}; +}}} + +#endif diff --git a/boost/fusion/support/detail/result_of.hpp b/boost/fusion/support/detail/result_of.hpp deleted file mode 100644 index e53ea9e354..0000000000 --- a/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 <boost/config.hpp> -#include <boost/utility/result_of.hpp> - -#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 <boost/mpl/if.hpp> -#include <boost/mpl/or.hpp> -#include <boost/mpl/has_xxx.hpp> -#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 <typename Sig> - struct result_of_with_decltype : boost::tr1_result_of<Sig> {}; - -#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 <typename Sig> - struct result_of_with_decltype; - - template <typename F, typename... Args> - struct result_of_with_decltype<F(Args...)> - : mpl::if_<mpl::or_<has_result_type<F>, detail::has_result<F> >, - boost::tr1_result_of<F(Args...)>, - boost::detail::cpp0x_result_of<F(Args...)> >::type {}; - -#endif // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - -}}} - -#endif diff --git a/boost/fusion/support/segmented_fold_until.hpp b/boost/fusion/support/segmented_fold_until.hpp index 9e6f4a50f6..8fb09ee38d 100644 --- a/boost/fusion/support/segmented_fold_until.hpp +++ b/boost/fusion/support/segmented_fold_until.hpp @@ -11,11 +11,6 @@ #include <boost/type_traits/is_const.hpp> #include <boost/utility/enable_if.hpp> #include <boost/fusion/support/detail/segmented_fold_until_impl.hpp> -#include <boost/fusion/view/iterator_range.hpp> -#include <boost/fusion/sequence/intrinsic/begin.hpp> -#include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/sequence/intrinsic/empty.hpp> -#include <boost/fusion/container/list/cons.hpp> namespace boost { namespace fusion { diff --git a/boost/fusion/tuple/make_tuple.hpp b/boost/fusion/tuple/make_tuple.hpp index 0d1277366a..e5cbb3b2ac 100644 --- a/boost/fusion/tuple/make_tuple.hpp +++ b/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 <boost/fusion/tuple/detail/make_tuple.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/support/detail/as_fusion_element.hpp> +#include <boost/fusion/tuple/tuple.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion +{ + template <typename ...T> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline tuple<typename detail::as_fusion_element< + typename remove_const< + typename remove_reference<T>::type + >::type + >::type...> + make_tuple(T&&... arg) + { + typedef tuple<typename detail::as_fusion_element< + typename remove_const< + typename remove_reference<T>::type + >::type + >::type...> result_type; + return result_type(std::forward<T>(arg)...); + } +}} + +#endif #endif diff --git a/boost/fusion/tuple/tuple.hpp b/boost/fusion/tuple/tuple.hpp index 674c369132..6ee21f56a0 100644 --- a/boost/fusion/tuple/tuple.hpp +++ b/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 <boost/fusion/tuple/detail/tuple.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector/vector.hpp> +#include <boost/fusion/sequence/intrinsic/size.hpp> +#include <boost/fusion/sequence/intrinsic/value_at.hpp> +#include <boost/fusion/sequence/intrinsic/at.hpp> +#include <boost/fusion/sequence/comparison.hpp> +#include <boost/fusion/sequence/io.hpp> +#include <utility> + +namespace boost { namespace fusion +{ + template <typename ...T> + struct tuple : vector<T...> + { + typedef vector<T...> base_type; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple() + : base_type() {} + + template <typename ...U> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple<U...> const& other) + : base_type(other) {} + + template <typename ...U> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple<U...>&& other) + : base_type(std::move(other)) {} + + template <typename ...U> + /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED + explicit + tuple(U&&... args) + : base_type(std::forward<U>(args)...) {} + + template <typename U> + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple& operator=(U&& rhs) + { + base_type::operator=(std::forward<U>(rhs)); + return *this; + } + }; + + template <typename Tuple> + struct tuple_size : result_of::size<Tuple> {}; + + template <int N, typename Tuple> + struct tuple_element : result_of::value_at_c<Tuple, N> {}; + + template <int N, typename Tuple> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c<Tuple, N>::type + get(Tuple& tup) + { + return at_c<N>(tup); + } + + template <int N, typename Tuple> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c<Tuple const, N>::type + get(Tuple const& tup) + { + return at_c<N>(tup); + } +}} + +#endif #endif diff --git a/boost/fusion/tuple/tuple_fwd.hpp b/boost/fusion/tuple/tuple_fwd.hpp index 0742023403..b763acd52f 100644 --- a/boost/fusion/tuple/tuple_fwd.hpp +++ b/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 <boost/config.hpp> #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> + +#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 <boost/fusion/tuple/detail/tuple_fwd.hpp> +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template <typename ...T> + struct tuple; +}} #endif +#endif diff --git a/boost/fusion/tuple/tuple_tie.hpp b/boost/fusion/tuple/tuple_tie.hpp index 9202807048..a07dc0a43e 100644 --- a/boost/fusion/tuple/tuple_tie.hpp +++ b/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 <boost/fusion/tuple/detail/tuple_tie.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/tuple/tuple.hpp> + +namespace boost { namespace fusion +{ + template <typename ...T> + BOOST_FUSION_GPU_ENABLED + inline tuple<T&...> + tie(T&... arg) + { + return tuple<T&...>(arg...); + } +}} + +#endif #endif diff --git a/boost/fusion/view/detail/strictest_traversal.hpp b/boost/fusion/view/detail/strictest_traversal.hpp index 9ad1f7aa85..4092ea4da6 100644 --- a/boost/fusion/view/detail/strictest_traversal.hpp +++ b/boost/fusion/view/detail/strictest_traversal.hpp @@ -59,7 +59,7 @@ namespace boost { namespace fusion // never called, but needed for decltype-based result_of (C++0x) #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template<typename StrictestSoFar, typename Next> - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + BOOST_FUSION_GPU_ENABLED typename result<strictest_traversal_impl(StrictestSoFar, Next)>::type operator()(StrictestSoFar&&, Next&&) const; #endif diff --git a/boost/fusion/view/flatten_view.hpp b/boost/fusion/view/flatten_view.hpp index dcef08dec7..25428544d6 100644 --- a/boost/fusion/view/flatten_view.hpp +++ b/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/boost/fusion/view/flatten_view/flatten_view.hpp b/boost/fusion/view/flatten_view/flatten_view.hpp index 8e40158d1c..401f65dc86 100644 --- a/boost/fusion/view/flatten_view/flatten_view.hpp +++ b/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/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index 1ecf692822..be115d910b 100644 --- a/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/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/boost/fusion/view/nview/detail/advance_impl.hpp b/boost/fusion/view/nview/detail/advance_impl.hpp index 7c74a386bb..c46414337f 100644 --- a/boost/fusion/view/nview/detail/advance_impl.hpp +++ b/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 <boost/fusion/support/config.hpp> -#include <boost/mpl/advance.hpp> #include <boost/fusion/iterator/advance.hpp> namespace boost { namespace fusion @@ -30,11 +29,11 @@ namespace boost { namespace fusion template<typename Iterator, typename Dist> 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<sequence_type, - typename mpl::advance<iterator_type, Dist>::type> type; + typedef nview_iterator<sequence_type, + typename result_of::advance<iterator_type, Dist>::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/detail/at_impl.hpp b/boost/fusion/view/nview/detail/at_impl.hpp index b9f41defcd..9f8c163708 100644 --- a/boost/fusion/view/nview/detail/at_impl.hpp +++ b/boost/fusion/view/nview/detail/at_impl.hpp @@ -10,6 +10,7 @@ #include <boost/fusion/support/config.hpp> #include <boost/fusion/sequence/intrinsic/at.hpp> +#include <boost/fusion/sequence/intrinsic/value_at.hpp> 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<index_type, N>::type index; + typedef typename result_of::value_at<index_type, N>::type index; typedef typename result_of::at<sequence_type, index>::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/boost/fusion/view/nview/detail/begin_impl.hpp b/boost/fusion/view/nview/detail/begin_impl.hpp index bab5e221c9..99e6319ea8 100644 --- a/boost/fusion/view/nview/detail/begin_impl.hpp +++ b/boost/fusion/view/nview/detail/begin_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM #include <boost/fusion/support/config.hpp> -#include <boost/mpl/begin.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> namespace boost { namespace fusion @@ -32,8 +31,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator<Sequence, - typename mpl::begin<index_type>::type> type; + typedef nview_iterator<Sequence, + typename result_of::begin<index_type>::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp b/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp index 08c6c9d738..0bcea9bb91 100644 --- a/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp +++ b/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp @@ -17,10 +17,13 @@ #include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_binary_params.hpp> #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/fusion/adapted/mpl.hpp> +#include <boost/fusion/adapted/mpl/mpl_iterator.hpp> #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/boost/fusion/view/nview/detail/deref_impl.hpp b/boost/fusion/view/nview/detail/deref_impl.hpp index 85991021b6..57654aa057 100644 --- a/boost/fusion/view/nview/detail/deref_impl.hpp +++ b/boost/fusion/view/nview/detail/deref_impl.hpp @@ -9,8 +9,8 @@ #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM #include <boost/fusion/support/config.hpp> -#include <boost/fusion/iterator/deref.hpp> -#include <boost/fusion/container/vector.hpp> +#include <boost/fusion/iterator/value_of.hpp> +#include <boost/fusion/sequence/intrinsic/at.hpp> 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<first_type>::type index; + typedef typename result_of::value_of<first_type>::type index; typedef typename result_of::at< typename sequence_type::sequence_type, index>::type type; diff --git a/boost/fusion/view/nview/detail/end_impl.hpp b/boost/fusion/view/nview/detail/end_impl.hpp index 0a6efe560d..810aea917a 100644 --- a/boost/fusion/view/nview/detail/end_impl.hpp +++ b/boost/fusion/view/nview/detail/end_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM #include <boost/fusion/support/config.hpp> -#include <boost/mpl/end.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> namespace boost { namespace fusion @@ -33,8 +32,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator<Sequence, - typename mpl::end<index_type>::type> type; + typedef nview_iterator<Sequence, + typename result_of::end<index_type>::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/boost/fusion/view/nview/detail/next_impl.hpp b/boost/fusion/view/nview/detail/next_impl.hpp index 3c30409647..821d9c3768 100644 --- a/boost/fusion/view/nview/detail/next_impl.hpp +++ b/boost/fusion/view/nview/detail/next_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM #include <boost/fusion/support/config.hpp> -#include <boost/mpl/next.hpp> +#include <boost/fusion/iterator/next.hpp> namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct next_impl<nview_iterator_tag> { template <typename Iterator> - 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<sequence_type, - typename mpl::next<first_type>::type> type; + typename result_of::next<first_type>::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/detail/nview_impl.hpp b/boost/fusion/view/nview/detail/nview_impl.hpp index 40674e3551..0c75a66afa 100644 --- a/boost/fusion/view/nview/detail/nview_impl.hpp +++ b/boost/fusion/view/nview/detail/nview_impl.hpp @@ -8,11 +8,43 @@ #define BOOST_FUSION_NVIEW_IMPL_17122014_1948 #include <boost/fusion/support/config.hpp> +#include <boost/fusion/container/vector/detail/config.hpp> /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include <boost/fusion/view/nview/detail/cpp03/nview_impl.hpp> +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include <boost/fusion/container/vector.hpp> +#include <boost/mpl/int.hpp> + +namespace boost { namespace fusion +{ + namespace result_of + { + template <typename Sequence, int ...I> + struct as_nview + { + typedef vector<mpl::int_<I>...> index_type; + typedef nview<Sequence, index_type> type; + }; + } + + template <int ...I, typename Sequence> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline nview<Sequence, vector<mpl::int_<I>...> > + as_nview(Sequence& s) + { + typedef vector<mpl::int_<I>...> index_type; + return nview<Sequence, index_type>(s); + } +}} + +#endif #endif diff --git a/boost/fusion/view/nview/detail/prior_impl.hpp b/boost/fusion/view/nview/detail/prior_impl.hpp index 470c5bd323..29b63f5692 100644 --- a/boost/fusion/view/nview/detail/prior_impl.hpp +++ b/boost/fusion/view/nview/detail/prior_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM #include <boost/fusion/support/config.hpp> -#include <boost/mpl/prior.hpp> +#include <boost/fusion/iterator/prior.hpp> namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct prior_impl<nview_iterator_tag> { template <typename Iterator> - 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<sequence_type, - typename mpl::prior<first_type>::type> type; + typename result_of::prior<first_type>::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/boost/fusion/view/nview/nview.hpp b/boost/fusion/view/nview/nview.hpp index 2e257c81de..e5a4be8ab7 100644 --- a/boost/fusion/view/nview/nview.hpp +++ b/boost/fusion/view/nview/nview.hpp @@ -9,19 +9,15 @@ #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM #include <boost/fusion/support/config.hpp> -#include <boost/mpl/size.hpp> #include <boost/mpl/if.hpp> -#include <boost/mpl/vector_c.hpp> -#include <boost/utility/result_of.hpp> -#include <boost/type_traits/remove_reference.hpp> #include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_const.hpp> #include <boost/fusion/support/is_view.hpp> -#include <boost/fusion/support/category_of.hpp> #include <boost/fusion/support/sequence_base.hpp> #include <boost/fusion/container/vector.hpp> +#include <boost/fusion/sequence/intrinsic/size.hpp> #include <boost/fusion/view/transform_view.hpp> #include <boost/config.hpp> @@ -99,7 +95,7 @@ namespace boost { namespace fusion typedef mpl::true_ is_view; typedef Indicies index_type; - typedef typename mpl::size<Indicies>::type size; + typedef typename result_of::size<Indicies>::type size; typedef typename mpl::if_< is_const<Sequence>, detail::addconstref, detail::addref diff --git a/boost/fusion/view/nview/nview_iterator.hpp b/boost/fusion/view/nview/nview_iterator.hpp index aeaf4620b8..42e634e521 100644 --- a/boost/fusion/view/nview/nview_iterator.hpp +++ b/boost/fusion/view/nview/nview_iterator.hpp @@ -12,7 +12,6 @@ #include <boost/fusion/support/category_of.hpp> #include <boost/fusion/sequence/intrinsic/begin.hpp> #include <boost/fusion/sequence/intrinsic/end.hpp> -#include <boost/fusion/adapted/mpl/mpl_iterator.hpp> #include <boost/fusion/view/nview/detail/size_impl.hpp> #include <boost/fusion/view/nview/detail/begin_impl.hpp> @@ -40,7 +39,7 @@ namespace boost { namespace fusion typedef random_access_traversal_tag category; typedef Sequence sequence_type; - typedef mpl_iterator<Pos> first_type; + typedef Pos first_type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit nview_iterator(Sequence& in_seq) |