From d9370039621553844ded593b7f35514028b8d6c6 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 9 Nov 2014 15:27:54 +0900 Subject: [PATCH 01/34] Prepare implementing c++11 variadic based fusion::vector. --- .../fusion/algorithm/transformation/erase.hpp | 1 - .../algorithm/transformation/insert.hpp | 1 - .../algorithm/transformation/insert_range.hpp | 1 - include/boost/fusion/container/vector.hpp | 19 +------------ .../container/vector/detail/as_vector.hpp | 8 ++++++ .../fusion/container/vector/detail/config.hpp | 28 +++++++++++++++++++ .../container/vector/detail/cpp03/limits.hpp | 1 + .../boost/fusion/container/vector/vector.hpp | 9 +++++- .../fusion/container/vector/vector10.hpp | 8 ++++++ .../fusion/container/vector/vector20.hpp | 8 ++++++ .../fusion/container/vector/vector30.hpp | 8 ++++++ .../fusion/container/vector/vector40.hpp | 8 ++++++ .../fusion/container/vector/vector50.hpp | 8 ++++++ .../fusion/container/vector/vector_fwd.hpp | 13 +++++++++ .../fusion/functional/adapter/limits.hpp | 11 ++++++-- 15 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 include/boost/fusion/container/vector/detail/config.hpp diff --git a/include/boost/fusion/algorithm/transformation/erase.hpp b/include/boost/fusion/algorithm/transformation/erase.hpp index 0f3b8a15..8eebc357 100644 --- a/include/boost/fusion/algorithm/transformation/erase.hpp +++ b/include/boost/fusion/algorithm/transformation/erase.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/fusion/algorithm/transformation/insert.hpp b/include/boost/fusion/algorithm/transformation/insert.hpp index 44e59653..c6d5219d 100644 --- a/include/boost/fusion/algorithm/transformation/insert.hpp +++ b/include/boost/fusion/algorithm/transformation/insert.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/include/boost/fusion/algorithm/transformation/insert_range.hpp b/include/boost/fusion/algorithm/transformation/insert_range.hpp index 40e64e1f..57878309 100644 --- a/include/boost/fusion/algorithm/transformation/insert_range.hpp +++ b/include/boost/fusion/algorithm/transformation/insert_range.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/fusion/container/vector.hpp b/include/boost/fusion/container/vector.hpp index a999c8b0..41c98033 100644 --- a/include/boost/fusion/container/vector.hpp +++ b/include/boost/fusion/container/vector.hpp @@ -8,25 +8,8 @@ #define FUSION_SEQUENCE_CLASS_VECTOR_10022005_0602 #include -#include - -#include -#if (FUSION_MAX_VECTOR_SIZE > 10) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 20) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 30) -#include -#endif -#if (FUSION_MAX_VECTOR_SIZE > 40) -#include -#endif - -#include #include -#include +#include #include #endif diff --git a/include/boost/fusion/container/vector/detail/as_vector.hpp b/include/boost/fusion/container/vector/detail/as_vector.hpp index eaaac896..9fc38156 100644 --- a/include/boost/fusion/container/vector/detail/as_vector.hpp +++ b/include/boost/fusion/container/vector/detail/as_vector.hpp @@ -8,12 +8,20 @@ #define FUSION_AS_VECTOR_11052014_1801 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// + +#endif #endif diff --git a/include/boost/fusion/container/vector/detail/config.hpp b/include/boost/fusion/container/vector/detail/config.hpp new file mode 100644 index 00000000..380183b4 --- /dev/null +++ b/include/boost/fusion/container/vector/detail/config.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2014 Kohei Takahashi + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef FUSION_VECTOR_CONFIG_11052014_1720 +#define FUSION_VECTOR_CONFIG_11052014_1720 + +#include +#include + +/* +#if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ + || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)) \ + || (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 +*/ + +#endif + diff --git a/include/boost/fusion/container/vector/detail/cpp03/limits.hpp b/include/boost/fusion/container/vector/detail/cpp03/limits.hpp index 6e106144..74a05102 100644 --- a/include/boost/fusion/container/vector/detail/cpp03/limits.hpp +++ b/include/boost/fusion/container/vector/detail/cpp03/limits.hpp @@ -9,6 +9,7 @@ #include #include +#include #if !defined(FUSION_MAX_VECTOR_SIZE) # define FUSION_MAX_VECTOR_SIZE 10 diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 2b9f0ce5..db3a046e 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -7,14 +7,21 @@ #ifndef FUSION_VECTOR_11052014_1625 #define FUSION_VECTOR_11052014_1625 -#include #include +#include #include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector10.hpp b/include/boost/fusion/container/vector/vector10.hpp index f152bfe1..86c58cc6 100644 --- a/include/boost/fusion/container/vector/vector10.hpp +++ b/include/boost/fusion/container/vector/vector10.hpp @@ -9,11 +9,19 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector20.hpp b/include/boost/fusion/container/vector/vector20.hpp index c5be355d..f0b4c47a 100644 --- a/include/boost/fusion/container/vector/vector20.hpp +++ b/include/boost/fusion/container/vector/vector20.hpp @@ -9,11 +9,19 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector30.hpp b/include/boost/fusion/container/vector/vector30.hpp index 1a528cb5..5ef2b90e 100644 --- a/include/boost/fusion/container/vector/vector30.hpp +++ b/include/boost/fusion/container/vector/vector30.hpp @@ -9,11 +9,19 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector40.hpp b/include/boost/fusion/container/vector/vector40.hpp index 5faa7d59..3625879b 100644 --- a/include/boost/fusion/container/vector/vector40.hpp +++ b/include/boost/fusion/container/vector/vector40.hpp @@ -9,11 +9,19 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector50.hpp b/include/boost/fusion/container/vector/vector50.hpp index 7b7e7a8a..95d5d275 100644 --- a/include/boost/fusion/container/vector/vector50.hpp +++ b/include/boost/fusion/container/vector/vector50.hpp @@ -9,11 +9,19 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// #endif +#endif diff --git a/include/boost/fusion/container/vector/vector_fwd.hpp b/include/boost/fusion/container/vector/vector_fwd.hpp index b63099ce..5b4fc749 100644 --- a/include/boost/fusion/container/vector/vector_fwd.hpp +++ b/include/boost/fusion/container/vector/vector_fwd.hpp @@ -9,11 +9,24 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template + struct vector; +}} #endif +#endif diff --git a/include/boost/fusion/functional/adapter/limits.hpp b/include/boost/fusion/functional/adapter/limits.hpp index cdcdf821..9fb5a2a2 100644 --- a/include/boost/fusion/functional/adapter/limits.hpp +++ b/include/boost/fusion/functional/adapter/limits.hpp @@ -9,16 +9,21 @@ #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED) # define BOOST_FUSION_FUNCTIONAL_ADAPTER_LIMITS_HPP_INCLUDED -# include +# include +# if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# include +# endif # if !defined(BOOST_FUSION_UNFUSED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_GENERIC_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif # if !defined(BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY) # define BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY 6 -# elif BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE +# elif !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) && \ + (BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE) # error "BOOST_FUSION_UNFUSED_TYPED_MAX_ARITY > FUSION_MAX_VECTOR_SIZE" # endif From c77f84749f58550d70291546f5fb418ac459bb74 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 11 Nov 2014 11:16:30 +0900 Subject: [PATCH 02/34] Implement variadic generators for fusion::vector. --- .../container/generation/make_vector.hpp | 30 +++++++++++++++++++ .../container/generation/vector_tie.hpp | 29 ++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index 8f067481..14ef323c 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -10,7 +10,37 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_vector + { + typedef vector::type...> type; + }; + } + + template + BOOST_FUSION_GPU_ENABLED + inline vector::type...> + make_vector(T const&... arg) + { + return vector::type...>(arg...); + } + }} + #endif +#endif diff --git a/include/boost/fusion/container/generation/vector_tie.hpp b/include/boost/fusion/container/generation/vector_tie.hpp index 5bb4face..dc820043 100644 --- a/include/boost/fusion/container/generation/vector_tie.hpp +++ b/include/boost/fusion/container/generation/vector_tie.hpp @@ -8,8 +8,37 @@ #define FUSION_VECTOR_TIE_11112014_2302 #include +#include +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct vector_tie + { + typedef vector type; + }; + } + + template + BOOST_FUSION_GPU_ENABLED + inline vector + vector_tie(T&... arg) + { + return vector(arg...); + } + }} + #endif +#endif From 969b475462847e6affe79e9257355804f924c88d Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 28 Jun 2015 01:13:32 +0900 Subject: [PATCH 03/34] Implement variadic templates based fusion::vector. Thanks to Lee Clagett. --- .../container/generation/make_vector.hpp | 30 +- .../container/generation/vector_tie.hpp | 2 +- .../container/vector/detail/as_vector.hpp | 44 +++ .../container/vector/detail/at_impl.hpp | 9 +- .../fusion/container/vector/detail/config.hpp | 13 +- .../container/vector/detail/deref_impl.hpp | 6 +- .../container/vector/detail/value_at_impl.hpp | 49 +++ .../container/vector/detail/value_of_impl.hpp | 6 +- .../boost/fusion/container/vector/vector.hpp | 331 +++++++++++++++++- .../fusion/container/vector/vector10.hpp | 2 + .../fusion/container/vector/vector20.hpp | 2 + .../fusion/container/vector/vector30.hpp | 2 + .../fusion/container/vector/vector40.hpp | 2 + .../fusion/container/vector/vector50.hpp | 2 + .../fusion/container/vector/vector_fwd.hpp | 15 + 15 files changed, 493 insertions(+), 22 deletions(-) diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index 14ef323c..df63ded6 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -27,16 +27,38 @@ namespace boost { namespace fusion template struct make_vector { - typedef vector::type...> type; + // make `make_vector' into `make_vector' + template struct trim_void; + + template + struct trim_void > + { + typedef vector, U...> type; + }; + + template + struct trim_void, void_, Tail...> + : trim_void > { }; + + template + struct trim_void, Head, Tail...> + : trim_void, Tail...> { }; + + typedef + typename trim_void< + vector<> + , typename detail::as_fusion_element::type... + >::type + type; }; } template - BOOST_FUSION_GPU_ENABLED - inline vector::type...> + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::make_vector::type make_vector(T const&... arg) { - return vector::type...>(arg...); + return typename result_of::make_vector::type(arg...); } }} diff --git a/include/boost/fusion/container/generation/vector_tie.hpp b/include/boost/fusion/container/generation/vector_tie.hpp index dc820043..5d7cb98b 100644 --- a/include/boost/fusion/container/generation/vector_tie.hpp +++ b/include/boost/fusion/container/generation/vector_tie.hpp @@ -30,7 +30,7 @@ namespace boost { namespace fusion } template - BOOST_FUSION_GPU_ENABLED + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline vector vector_tie(T&... arg) { diff --git a/include/boost/fusion/container/vector/detail/as_vector.hpp b/include/boost/fusion/container/vector/detail/as_vector.hpp index 9fc38156..322f3dd6 100644 --- a/include/boost/fusion/container/vector/detail/as_vector.hpp +++ b/include/boost/fusion/container/vector/detail/as_vector.hpp @@ -20,6 +20,50 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template + struct as_vector_impl; + + template + struct as_vector_impl > + { + template + struct apply + { + typedef vector< + numbered_vector_tag + , typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator i) + { + typedef typename apply::type result; + return result(*advance_c(i)...); + } + }; + + template + struct as_vector + : as_vector_impl::type> {}; + +BOOST_FUSION_BARRIER_END +}}} #endif #endif diff --git a/include/boost/fusion/container/vector/detail/at_impl.hpp b/include/boost/fusion/container/vector/detail/at_impl.hpp index cb98dd4a..a2900d79 100644 --- a/include/boost/fusion/container/vector/detail/at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/at_impl.hpp @@ -9,9 +9,8 @@ #include #include -#include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -28,7 +27,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::ref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -43,7 +42,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename mpl::at::type element; + typedef typename value_at_impl::template apply::type element; typedef typename detail::cref_result::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/include/boost/fusion/container/vector/detail/config.hpp b/include/boost/fusion/container/vector/detail/config.hpp index 380183b4..475fe641 100644 --- a/include/boost/fusion/container/vector/detail/config.hpp +++ b/include/boost/fusion/container/vector/detail/config.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,10 +8,11 @@ #define FUSION_VECTOR_CONFIG_11052014_1720 #include +#include #include -/* #if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ + || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)) \ || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) # if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) @@ -22,7 +23,13 @@ # define BOOST_FUSION_HAS_VARIADIC_VECTOR # endif #endif -*/ + +// Sometimes, MSVC 12 shows compile error with std::size_t of template parameter. +#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1800)) +# if defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) +# undef BOOST_FUSION_HAS_VARIADIC_VECTOR +# endif +#endif #endif diff --git a/include/boost/fusion/container/vector/detail/deref_impl.hpp b/include/boost/fusion/container/vector/detail/deref_impl.hpp index 5186aa10..c85bb82b 100644 --- a/include/boost/fusion/container/vector/detail/deref_impl.hpp +++ b/include/boost/fusion/container/vector/detail/deref_impl.hpp @@ -8,8 +8,8 @@ #define FUSION_DEREF_IMPL_05042005_1037 #include -#include #include +#include #include #include @@ -30,9 +30,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - element; + typedef typename value_at_impl::template apply::type element; typedef typename mpl::if_< diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index f71ca848..220807c7 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -9,11 +9,60 @@ #include #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + + namespace vector_detail + { + template + struct vector_data; + } + + namespace extension + { + template + struct value_at_impl; + + template <> + struct value_at_impl + { + template + struct apply_impl; + + template + struct apply_impl, 0> + { + typedef H type; + }; + + template + struct apply_impl, N> + : apply_impl, N - 1> + {}; + + template + struct apply : apply_impl + {}; + }; + } +}} #endif +#endif diff --git a/include/boost/fusion/container/vector/detail/value_of_impl.hpp b/include/boost/fusion/container/vector/detail/value_of_impl.hpp index 2a8acf91..d67ab3fc 100644 --- a/include/boost/fusion/container/vector/detail/value_of_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_of_impl.hpp @@ -8,7 +8,7 @@ #define FUSION_VALUE_OF_IMPL_05052005_1128 #include -#include +#include namespace boost { namespace fusion { @@ -27,9 +27,7 @@ namespace boost { namespace fusion { typedef typename Iterator::vector vector; typedef typename Iterator::index index; - typedef typename mpl::at< - typename vector::types, index>::type - type; + typedef typename value_at_impl::template apply::type type; }; }; } diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index db3a046e..3f9d52ec 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,6 +7,7 @@ #ifndef FUSION_VECTOR_11052014_1625 #define FUSION_VECTOR_11052014_1625 +#include #include #include #include @@ -21,6 +22,334 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct vector_tag; + struct random_access_traversal_tag; + + namespace vector_detail + { + struct each_elem {}; + struct copy_or_move {}; + template struct from_sequence {}; + + template + struct make_indices_from_seq + : detail::make_index_sequence< + fusion::result_of::size::type>::value + > + {}; + + template + struct pure : remove_cv::type> {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline each_elem + dispatch( T const&... ) BOOST_NOEXCEPT { return each_elem(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline copy_or_move + dispatch( This const& ) BOOST_NOEXCEPT { return copy_or_move(); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline from_sequence< + typename lazy_enable_if_c< + (traits::is_sequence::value && + !is_same::value) + , make_indices_from_seq + >::type + > + dispatch( Sequence const& ) BOOST_NOEXCEPT + { return from_sequence::type>(); } + + + // forward_at_c allows to access Nth element even if ForwardSequence + // since fusion::at_c requires RandomAccessSequence. + namespace result_of + { + template + struct forward_at_c + : fusion::result_of::deref< + typename fusion::result_of::advance_c< + typename fusion::result_of::begin< + typename remove_reference::type + >::type + , N + >::type + > + {}; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::forward_at_c::type + forward_at_c(Sequence&& seq) + { + typedef typename + result_of::forward_at_c::type + result; + return std::forward(*advance_c(begin(seq))); + } + + // Object proxy since preserve object order + template + struct store + { + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store() + : elem() // value-initialized explicitly + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store const& rhs) + : elem(rhs.get()) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store const& rhs) + { + elem = rhs.get(); + return *this; + } + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(store&& rhs) + : elem(static_cast(rhs.get())) + {} + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store& + operator=(store&& rhs) + { + elem = static_cast(rhs.get()); + return *this; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + store(U&& rhs + , typename disable_if::type, store> >::type* = 0) + : elem(std::forward(rhs)) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename disable_if::type, store>, store&>::type + operator=(U&& rhs) + { + elem = std::forward(rhs); + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T & get() { return elem; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + T const& get() const { return elem; } + + T elem; + }; + + template + struct vector_data; + + template + struct vector_data, T...> + : store... + , sequence_base, T...> > + { + typedef vector_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + typedef random_access_traversal_tag category; + typedef mpl::int_ size; + typedef vector type_sequence; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data() + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data const& rhs) + : store(static_cast const&>(rhs))... + {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(copy_or_move, vector_data&& rhs) + : store(std::forward >(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(from_sequence >, Sequence&& rhs) + : store(forward_at_c(rhs))... + {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + vector_data(each_elem, U&&... var) + : store(std::forward(var))... + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&&, detail::index_sequence<>) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + void + assign(Sequence&& seq, detail::index_sequence) + { + at_impl(mpl::int_()) = vector_detail::forward_at_c(seq); + assign(std::forward(seq), detail::index_sequence()); + } + + typedef extension::value_at_impl value_at_impl; + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename value_at_impl::template apply::type& + at_impl(J) + { + typedef typename value_at_impl::template apply::type U; + typedef store S; + return static_cast(this)->get(); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + typename value_at_impl::template apply::type const& + at_impl(J) const + { + typedef typename value_at_impl::template apply::type U; + typedef store S; + return static_cast(this)->get(); + } + }; + + // Internal use only specialization for implementing vectorN. + // Simple aliasing (like a using vectorN = vector) will cause specialization confliction + // like following. + // + // template struct SomeClass; + // template struct SomeClass> { ... }; + // template + // struct SomeClass> // Error, since vector and vector1 are exact same type. + // { ... }; + // + // Introducing `numbered_vector_tag` will resolve such specialization error. + // + // template + // struct SomeClass> { ... }; + // template + // struct SomeClass> // OK + // { ... }; + // + // // Same meaning as above specialization. + // template + // struct SomeClass, T>> + // { ... }; + template + struct vector_data, numbered_vector_tag, T...> + : vector_data::type, T...> + { + typedef vector_data::type, T...> base; + + BOOST_STATIC_ASSERT((base::size::value == N)); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector_data(U&&... var) + : base(std::forward(var)...) + {} + }; + + template + struct construct_vector_; + + template + struct construct_vector_ > + { + typedef vector_data< + typename detail::make_index_sequence::type + , T... + > type; + }; + + template + struct construct_vector_, void_, Tail...> + : construct_vector_ > {}; + + template + struct construct_vector_, Head, Tail...> + : construct_vector_, Tail...> {}; + + template + struct construct_vector : construct_vector_, T...> {}; + } // namespace boost::fusion::vector_detail + + // This class provides backward compatibility: vector. + template + struct vector + : vector_detail::construct_vector::type + { + typedef typename vector_detail::construct_vector::type base; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector() + {} + + // rvalue-references is required here in order to forward any arguments to + // base: vector(T const&...) doesn't work with trailing void_ and + // vector(U const&...) cannot forward any arguments to base. + template + // XXX: constexpr become error due to pull-request #79, booooo!! + // In the (near) future release, should be fixed. + /* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED + vector(U&&... u) + : base(vector_detail::dispatch(u...), std::forward(u)...) + {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + vector& + operator=(Sequence&& rhs) + { + typedef typename + vector_detail::make_indices_from_seq::type + indices; + base::assign(std::forward(rhs), indices()); + return *this; + } + }; +}} #endif #endif diff --git a/include/boost/fusion/container/vector/vector10.hpp b/include/boost/fusion/container/vector/vector10.hpp index 86c58cc6..65722fe6 100644 --- a/include/boost/fusion/container/vector/vector10.hpp +++ b/include/boost/fusion/container/vector/vector10.hpp @@ -21,6 +21,8 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include #endif #endif diff --git a/include/boost/fusion/container/vector/vector20.hpp b/include/boost/fusion/container/vector/vector20.hpp index f0b4c47a..c36e50c7 100644 --- a/include/boost/fusion/container/vector/vector20.hpp +++ b/include/boost/fusion/container/vector/vector20.hpp @@ -21,6 +21,8 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include #endif #endif diff --git a/include/boost/fusion/container/vector/vector30.hpp b/include/boost/fusion/container/vector/vector30.hpp index 5ef2b90e..e9f891f2 100644 --- a/include/boost/fusion/container/vector/vector30.hpp +++ b/include/boost/fusion/container/vector/vector30.hpp @@ -21,6 +21,8 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include #endif #endif diff --git a/include/boost/fusion/container/vector/vector40.hpp b/include/boost/fusion/container/vector/vector40.hpp index 3625879b..4b753a08 100644 --- a/include/boost/fusion/container/vector/vector40.hpp +++ b/include/boost/fusion/container/vector/vector40.hpp @@ -21,6 +21,8 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include #endif #endif diff --git a/include/boost/fusion/container/vector/vector50.hpp b/include/boost/fusion/container/vector/vector50.hpp index 95d5d275..5d8d3563 100644 --- a/include/boost/fusion/container/vector/vector50.hpp +++ b/include/boost/fusion/container/vector/vector50.hpp @@ -21,6 +21,8 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include #endif #endif diff --git a/include/boost/fusion/container/vector/vector_fwd.hpp b/include/boost/fusion/container/vector/vector_fwd.hpp index 5b4fc749..641b19ef 100644 --- a/include/boost/fusion/container/vector/vector_fwd.hpp +++ b/include/boost/fusion/container/vector/vector_fwd.hpp @@ -21,10 +21,25 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// +#include +#include +#include + namespace boost { namespace fusion { template struct vector; + + template + struct numbered_vector_tag; + +#define FUSION_VECTOR_N_ALIASES(z, N, d) \ + template \ + using BOOST_PP_CAT(vector, N) = vector, T...>; + + BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~) + +#undef FUSION_VECTOR_N_ALIASES }} #endif From 1f8ccd7bc316d817cdee01a6185c993dd2267c20 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 28 Jun 2015 13:46:56 +0900 Subject: [PATCH 04/34] Support move for make_vector. --- .../boost/fusion/container/generation/make_vector.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index df63ded6..1c8a86c8 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -19,6 +19,8 @@ /////////////////////////////////////////////////////////////////////////////// #include +#include +#include namespace boost { namespace fusion { @@ -47,7 +49,9 @@ namespace boost { namespace fusion typedef typename trim_void< vector<> - , typename detail::as_fusion_element::type... + , typename detail::as_fusion_element< + typename remove_reference::type + >::type... >::type type; }; @@ -56,9 +60,9 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::make_vector::type - make_vector(T const&... arg) + make_vector(T&&... arg) { - return typename result_of::make_vector::type(arg...); + return typename result_of::make_vector::type(std::forward(arg)...); } }} From f9fda7ce067617c473055006cfc3cbed0db32eff Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 28 Jun 2015 19:42:08 +0900 Subject: [PATCH 05/34] Remove intermediate specialization. --- .../boost/fusion/container/vector/vector.hpp | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 3f9d52ec..b330b3a2 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -276,21 +276,6 @@ namespace boost { namespace fusion // template // struct SomeClass, T>> // { ... }; - template - struct vector_data, numbered_vector_tag, T...> - : vector_data::type, T...> - { - typedef vector_data::type, T...> base; - - BOOST_STATIC_ASSERT((base::size::value == N)); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - vector_data(U&&... var) - : base(std::forward(var)...) - {} - }; - template struct construct_vector_; @@ -303,6 +288,17 @@ namespace boost { namespace fusion > type; }; + template + struct construct_vector_, T...> > + { + typedef vector_data< + typename detail::make_index_sequence::type + , T... + > type; + + BOOST_STATIC_ASSERT((type::size::value == N)); + }; + template struct construct_vector_, void_, Tail...> : construct_vector_ > {}; From 7739e4026d8b0c69488c6bb9a6d796181e4d6114 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 17 Dec 2014 21:09:42 +0900 Subject: [PATCH 06/34] Adjust fusion::nview for variadic templates based fusion::vector since FUSION_MAX_VECTOR_SIZE won't define in c++11. --- .../fusion/view/nview/detail/advance_impl.hpp | 9 +++--- .../fusion/view/nview/detail/at_impl.hpp | 3 +- .../fusion/view/nview/detail/begin_impl.hpp | 5 ++- .../view/nview/detail/cpp03/nview_impl.hpp | 5 ++- .../fusion/view/nview/detail/deref_impl.hpp | 6 ++-- .../fusion/view/nview/detail/end_impl.hpp | 5 ++- .../fusion/view/nview/detail/next_impl.hpp | 8 ++--- .../fusion/view/nview/detail/nview_impl.hpp | 32 +++++++++++++++++++ .../fusion/view/nview/detail/prior_impl.hpp | 8 ++--- include/boost/fusion/view/nview/nview.hpp | 8 ++--- .../fusion/view/nview/nview_iterator.hpp | 3 +- 11 files changed, 60 insertions(+), 32 deletions(-) diff --git a/include/boost/fusion/view/nview/detail/advance_impl.hpp b/include/boost/fusion/view/nview/detail/advance_impl.hpp index 7c74a386..c4641433 100644 --- a/include/boost/fusion/view/nview/detail/advance_impl.hpp +++ b/include/boost/fusion/view/nview/detail/advance_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2009 Hartmut Kaiser - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_ADVANCE_IMPL_SEP_24_2009_0212PM #include -#include #include namespace boost { namespace fusion @@ -30,11 +29,11 @@ namespace boost { namespace fusion template struct apply { - typedef typename Iterator::first_type::iterator_type iterator_type; + typedef typename Iterator::first_type iterator_type; typedef typename Iterator::sequence_type sequence_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/detail/at_impl.hpp b/include/boost/fusion/view/nview/detail/at_impl.hpp index b9f41def..9f8c1637 100644 --- a/include/boost/fusion/view/nview/detail/at_impl.hpp +++ b/include/boost/fusion/view/nview/detail/at_impl.hpp @@ -10,6 +10,7 @@ #include #include +#include namespace boost { namespace fusion { @@ -29,7 +30,7 @@ namespace boost { namespace fusion typedef typename Sequence::sequence_type sequence_type; typedef typename Sequence::index_type index_type; - typedef typename result_of::at::type index; + typedef typename result_of::value_at::type index; typedef typename result_of::at::type type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED diff --git a/include/boost/fusion/view/nview/detail/begin_impl.hpp b/include/boost/fusion/view/nview/detail/begin_impl.hpp index bab5e221..99e6319e 100644 --- a/include/boost/fusion/view/nview/detail/begin_impl.hpp +++ b/include/boost/fusion/view/nview/detail/begin_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_BEGIN_IMPL_SEP_23_2009_1036PM #include -#include #include namespace boost { namespace fusion @@ -32,8 +31,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp b/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp index 08c6c9d7..0bcea9bb 100644 --- a/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp +++ b/include/boost/fusion/view/nview/detail/cpp03/nview_impl.hpp @@ -17,10 +17,13 @@ #include #include #include +#include +#include +#include #define BOOST_PP_ITERATION_PARAMS_1 \ (3, (1, FUSION_MAX_VECTOR_SIZE, \ - "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ + "boost/fusion/view/nview/detail/cpp03/nview_impl.hpp")) \ /**/ /////////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/fusion/view/nview/detail/deref_impl.hpp b/include/boost/fusion/view/nview/detail/deref_impl.hpp index 85991021..57654aa0 100644 --- a/include/boost/fusion/view/nview/detail/deref_impl.hpp +++ b/include/boost/fusion/view/nview/detail/deref_impl.hpp @@ -9,8 +9,8 @@ #define BOOST_FUSION_NVIEW_DEREF_IMPL_SEP_24_2009_0818AM #include -#include -#include +#include +#include namespace boost { namespace fusion { @@ -30,7 +30,7 @@ namespace boost { namespace fusion typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; - typedef typename result_of::deref::type index; + typedef typename result_of::value_of::type index; typedef typename result_of::at< typename sequence_type::sequence_type, index>::type type; diff --git a/include/boost/fusion/view/nview/detail/end_impl.hpp b/include/boost/fusion/view/nview/detail/end_impl.hpp index 0a6efe56..810aea91 100644 --- a/include/boost/fusion/view/nview/detail/end_impl.hpp +++ b/include/boost/fusion/view/nview/detail/end_impl.hpp @@ -9,7 +9,6 @@ #define BOOST_FUSION_NVIEW_END_IMPL_SEP_24_2009_0140PM #include -#include #include namespace boost { namespace fusion @@ -33,8 +32,8 @@ namespace boost { namespace fusion { typedef typename Sequence::index_type index_type; - typedef nview_iterator::type> type; + typedef nview_iterator::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& s) diff --git a/include/boost/fusion/view/nview/detail/next_impl.hpp b/include/boost/fusion/view/nview/detail/next_impl.hpp index 3c304096..821d9c37 100644 --- a/include/boost/fusion/view/nview/detail/next_impl.hpp +++ b/include/boost/fusion/view/nview/detail/next_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_NEXT_IMPL_SEP_24_2009_0116PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct next_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::next::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/detail/nview_impl.hpp b/include/boost/fusion/view/nview/detail/nview_impl.hpp index 40674e35..0c75a66a 100644 --- a/include/boost/fusion/view/nview/detail/nview_impl.hpp +++ b/include/boost/fusion/view/nview/detail/nview_impl.hpp @@ -8,11 +8,43 @@ #define BOOST_FUSION_NVIEW_IMPL_17122014_1948 #include +#include /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct as_nview + { + typedef vector...> index_type; + typedef nview type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline nview...> > + as_nview(Sequence& s) + { + typedef vector...> index_type; + return nview(s); + } +}} #endif +#endif diff --git a/include/boost/fusion/view/nview/detail/prior_impl.hpp b/include/boost/fusion/view/nview/detail/prior_impl.hpp index 470c5bd3..29b63f56 100644 --- a/include/boost/fusion/view/nview/detail/prior_impl.hpp +++ b/include/boost/fusion/view/nview/detail/prior_impl.hpp @@ -9,7 +9,7 @@ #define BOOST_FUSION_NVIEW_PRIOR_IMPL_SEP_24_2009_0142PM #include -#include +#include namespace boost { namespace fusion { @@ -27,13 +27,13 @@ namespace boost { namespace fusion struct prior_impl { template - struct apply + struct apply { - typedef typename Iterator::first_type::iterator_type first_type; + typedef typename Iterator::first_type first_type; typedef typename Iterator::sequence_type sequence_type; typedef nview_iterator::type> type; + typename result_of::prior::type> type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type diff --git a/include/boost/fusion/view/nview/nview.hpp b/include/boost/fusion/view/nview/nview.hpp index 2e257c81..e5a4be8a 100644 --- a/include/boost/fusion/view/nview/nview.hpp +++ b/include/boost/fusion/view/nview/nview.hpp @@ -9,19 +9,15 @@ #define BOOST_FUSION_NVIEW_SEP_23_2009_0948PM #include -#include #include -#include -#include -#include #include #include #include -#include #include #include +#include #include #include @@ -99,7 +95,7 @@ namespace boost { namespace fusion typedef mpl::true_ is_view; typedef Indicies index_type; - typedef typename mpl::size::type size; + typedef typename result_of::size::type size; typedef typename mpl::if_< is_const, detail::addconstref, detail::addref diff --git a/include/boost/fusion/view/nview/nview_iterator.hpp b/include/boost/fusion/view/nview/nview_iterator.hpp index aeaf4620..42e634e5 100644 --- a/include/boost/fusion/view/nview/nview_iterator.hpp +++ b/include/boost/fusion/view/nview/nview_iterator.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -40,7 +39,7 @@ namespace boost { namespace fusion typedef random_access_traversal_tag category; typedef Sequence sequence_type; - typedef mpl_iterator first_type; + typedef Pos first_type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit nview_iterator(Sequence& in_seq) From b4133761e8dcd81e461f0b4c2e5d8029100d7b62 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 29 Nov 2014 23:04:29 +0900 Subject: [PATCH 07/34] Implement C++11 variadic templates based fusion::set --- .../fusion/container/set/detail/as_set.hpp | 50 +++++++- .../container/set/detail/convert_impl.hpp | 2 +- include/boost/fusion/container/set/set.hpp | 111 ++++++++++++++++++ .../boost/fusion/container/set/set_fwd.hpp | 27 +++++ 4 files changed, 188 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/container/set/detail/as_set.hpp b/include/boost/fusion/container/set/detail/as_set.hpp index 1eb0d3fe..9d333258 100644 --- a/include/boost/fusion/container/set/detail/as_set.hpp +++ b/include/boost/fusion/container/set/detail/as_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,55 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ +BOOST_FUSION_BARRIER_BEGIN + + template ::type> + struct as_set; + + template + struct as_set > + { + template + struct apply + { + typedef set< + typename result_of::value_of< + typename result_of::advance_c::type + >::type... + > type; + }; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + static typename apply::type + call(Iterator const& i) + { + typedef apply gen; + typedef typename gen::type result; + return result(*advance_c(i)...); + } + }; + +BOOST_FUSION_BARRIER_END +}}} #endif +#endif diff --git a/include/boost/fusion/container/set/detail/convert_impl.hpp b/include/boost/fusion/container/set/detail/convert_impl.hpp index d9d5dcfc..0b4cb22f 100644 --- a/include/boost/fusion/container/set/detail/convert_impl.hpp +++ b/include/boost/fusion/container/set/detail/convert_impl.hpp @@ -29,7 +29,7 @@ namespace boost { namespace fusion template struct apply { - typedef typename detail::as_set::value> gen; + typedef detail::as_set::value> gen; typedef typename gen:: template apply::type>::type type; diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 59f4eafc..9e383619 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -13,8 +13,119 @@ /////////////////////////////////////////////////////////////////////////////// // Without variadics, we will use the PP version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + struct fusion_sequence_tag; + + template <> + struct set<> : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector<> storage_type; + + typedef storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs) + : data(rhs) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(T const& rhs) + { + data = rhs; + return *this; + } + + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type& get_data() { return data; } + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + storage_type const& get_data() const { return data; } + + private: + storage_type data; + }; + + template + struct set : sequence_base > + { + struct category : forward_traversal_tag, associative_tag {}; + + typedef set_tag fusion_tag; + typedef fusion_sequence_tag tag; // this gets picked up by MPL + typedef mpl::false_ is_view; + + typedef vector storage_type; + + typedef typename storage_type::size size; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set() + : data() {} + + template + BOOST_FUSION_GPU_ENABLED + set(Sequence const& rhs) + : data(rhs) {} + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(typename detail::call_param::type ...args) + : data(args...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U 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; + }; + +}} + +#endif #endif diff --git a/include/boost/fusion/container/set/set_fwd.hpp b/include/boost/fusion/container/set/set_fwd.hpp index 50d8d1c8..7b5d6830 100644 --- a/include/boost/fusion/container/set/set_fwd.hpp +++ b/include/boost/fusion/container/set/set_fwd.hpp @@ -9,11 +9,38 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_SET) +# undef BOOST_FUSION_HAS_VARIADIC_SET +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_SET) +# define BOOST_FUSION_HAS_VARIADIC_SET +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + struct set_tag; + struct set_iterator_tag; + + template + struct set; +}} #endif +#endif From 62d9833bbf09f4d355e94697106e4d7e21827add Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 29 Jun 2015 21:55:51 +0900 Subject: [PATCH 08/34] Add missing remove_const. --- include/boost/fusion/container/generation/make_vector.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index 1c8a86c8..4a237011 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -20,6 +20,7 @@ #include #include +#include #include namespace boost { namespace fusion @@ -50,7 +51,9 @@ namespace boost { namespace fusion typename trim_void< vector<> , typename detail::as_fusion_element< - typename remove_reference::type + typename remove_const< + typename remove_reference::type + >::type >::type... >::type type; From 298eeef9c9942436e6c32210407815aac049a6b0 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 30 Jun 2015 01:28:01 +0900 Subject: [PATCH 09/34] Remove evil numbered_vector_tag. --- .../container/generation/make_vector.hpp | 2 +- .../container/vector/detail/as_vector.hpp | 5 +- .../boost/fusion/container/vector/vector.hpp | 56 ++++--------------- .../fusion/container/vector/vector_fwd.hpp | 8 +-- 4 files changed, 16 insertions(+), 55 deletions(-) diff --git a/include/boost/fusion/container/generation/make_vector.hpp b/include/boost/fusion/container/generation/make_vector.hpp index 4a237011..cd3b992b 100644 --- a/include/boost/fusion/container/generation/make_vector.hpp +++ b/include/boost/fusion/container/generation/make_vector.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion template struct trim_void > { - typedef vector, U...> type; + typedef vector type; }; template diff --git a/include/boost/fusion/container/vector/detail/as_vector.hpp b/include/boost/fusion/container/vector/detail/as_vector.hpp index 322f3dd6..e2f45b6a 100644 --- a/include/boost/fusion/container/vector/detail/as_vector.hpp +++ b/include/boost/fusion/container/vector/detail/as_vector.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -41,8 +41,7 @@ BOOST_FUSION_BARRIER_BEGIN struct apply { typedef vector< - numbered_vector_tag - , typename result_of::value_of< + typename result_of::value_of< typename result_of::advance_c::type >::type... > type; diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index b330b3a2..ab1c1f04 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -254,33 +253,11 @@ namespace boost { namespace fusion } }; - // Internal use only specialization for implementing vectorN. - // Simple aliasing (like a using vectorN = vector) will cause specialization confliction - // like following. - // - // template struct SomeClass; - // template struct SomeClass> { ... }; - // template - // struct SomeClass> // Error, since vector and vector1 are exact same type. - // { ... }; - // - // Introducing `numbered_vector_tag` will resolve such specialization error. - // - // template - // struct SomeClass> { ... }; - // template - // struct SomeClass> // OK - // { ... }; - // - // // Same meaning as above specialization. - // template - // struct SomeClass, T>> - // { ... }; template - struct construct_vector_; + struct trim_void_; template - struct construct_vector_ > + struct trim_void_ > { typedef vector_data< typename detail::make_index_sequence::type @@ -288,35 +265,24 @@ namespace boost { namespace fusion > type; }; - template - struct construct_vector_, T...> > - { - typedef vector_data< - typename detail::make_index_sequence::type - , T... - > type; + template + struct trim_void_, void_, Tail...> + : trim_void_ > {}; - BOOST_STATIC_ASSERT((type::size::value == N)); - }; - - template - struct construct_vector_, void_, Tail...> - : construct_vector_ > {}; - - template - struct construct_vector_, Head, Tail...> - : construct_vector_, Tail...> {}; + template + struct trim_void_, Head, Tail...> + : trim_void_, Tail...> {}; template - struct construct_vector : construct_vector_, T...> {}; + struct trim_void : trim_void_, T...> {}; } // namespace boost::fusion::vector_detail // This class provides backward compatibility: vector. template struct vector - : vector_detail::construct_vector::type + : vector_detail::trim_void::type { - typedef typename vector_detail::construct_vector::type base; + typedef typename vector_detail::trim_void::type base; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED vector() diff --git a/include/boost/fusion/container/vector/vector_fwd.hpp b/include/boost/fusion/container/vector/vector_fwd.hpp index 641b19ef..dcb0a0fc 100644 --- a/include/boost/fusion/container/vector/vector_fwd.hpp +++ b/include/boost/fusion/container/vector/vector_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -23,19 +23,15 @@ /////////////////////////////////////////////////////////////////////////////// #include #include -#include namespace boost { namespace fusion { template struct vector; - template - struct numbered_vector_tag; - #define FUSION_VECTOR_N_ALIASES(z, N, d) \ template \ - using BOOST_PP_CAT(vector, N) = vector, T...>; + using BOOST_PP_CAT(vector, N) = vector; BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~) From bc01b7fa245fde856493de24bc035dcaa365c8d4 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 3 Jul 2015 01:36:49 +0900 Subject: [PATCH 10/34] Implement C++11 variadic templates based fusion::tuple. --- .../boost/fusion/tuple/detail/make_tuple.hpp | 2 +- include/boost/fusion/tuple/detail/tuple.hpp | 2 +- .../boost/fusion/tuple/detail/tuple_fwd.hpp | 2 +- .../boost/fusion/tuple/detail/tuple_tie.hpp | 2 +- include/boost/fusion/tuple/make_tuple.hpp | 31 ++++++++ include/boost/fusion/tuple/tuple.hpp | 75 ++++++++++++++++++- include/boost/fusion/tuple/tuple_fwd.hpp | 26 ++++++- include/boost/fusion/tuple/tuple_tie.hpp | 19 +++++ 8 files changed, 153 insertions(+), 6 deletions(-) diff --git a/include/boost/fusion/tuple/detail/make_tuple.hpp b/include/boost/fusion/tuple/detail/make_tuple.hpp index abacb0bf..f87ea5a2 100644 --- a/include/boost/fusion/tuple/detail/make_tuple.hpp +++ b/include/boost/fusion/tuple/detail/make_tuple.hpp @@ -27,7 +27,7 @@ namespace boost { namespace fusion #include #else #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/make_tuple" FUSION_MAX_VECTOR_SIZE_STR ".hpp") +#pragma wave option(preserve: 2, line: 0, output: "preprocessed/make_tuple" FUSION_MAX_VECTOR_SIZE_STR ".hpp") #endif /*============================================================================= diff --git a/include/boost/fusion/tuple/detail/tuple.hpp b/include/boost/fusion/tuple/detail/tuple.hpp index f9270687..971d1a8a 100644 --- a/include/boost/fusion/tuple/detail/tuple.hpp +++ b/include/boost/fusion/tuple/detail/tuple.hpp @@ -23,7 +23,7 @@ #include #else #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/tuple" FUSION_MAX_VECTOR_SIZE_STR ".hpp") +#pragma wave option(preserve: 2, line: 0, output: "preprocessed/tuple" FUSION_MAX_VECTOR_SIZE_STR ".hpp") #endif /*============================================================================= diff --git a/include/boost/fusion/tuple/detail/tuple_fwd.hpp b/include/boost/fusion/tuple/detail/tuple_fwd.hpp index 2b52183a..ef6bdfe8 100644 --- a/include/boost/fusion/tuple/detail/tuple_fwd.hpp +++ b/include/boost/fusion/tuple/detail/tuple_fwd.hpp @@ -15,7 +15,7 @@ #include #else #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/tuple" FUSION_MAX_VECTOR_SIZE_STR "_fwd.hpp") +#pragma wave option(preserve: 2, line: 0, output: "preprocessed/tuple" FUSION_MAX_VECTOR_SIZE_STR "_fwd.hpp") #endif /*============================================================================= diff --git a/include/boost/fusion/tuple/detail/tuple_tie.hpp b/include/boost/fusion/tuple/detail/tuple_tie.hpp index 7ecbfe17..b650d1cc 100644 --- a/include/boost/fusion/tuple/detail/tuple_tie.hpp +++ b/include/boost/fusion/tuple/detail/tuple_tie.hpp @@ -18,7 +18,7 @@ #include #else #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES) -#pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/tuple_tie" FUSION_MAX_VECTOR_SIZE_STR ".hpp") +#pragma wave option(preserve: 2, line: 0, output: "preprocessed/tuple_tie" FUSION_MAX_VECTOR_SIZE_STR ".hpp") #endif /*============================================================================= diff --git a/include/boost/fusion/tuple/make_tuple.hpp b/include/boost/fusion/tuple/make_tuple.hpp index 0d127736..e5cbb3b2 100644 --- a/include/boost/fusion/tuple/make_tuple.hpp +++ b/include/boost/fusion/tuple/make_tuple.hpp @@ -13,7 +13,38 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline tuple::type + >::type + >::type...> + make_tuple(T&&... arg) + { + typedef tuple::type + >::type + >::type...> result_type; + return result_type(std::forward(arg)...); + } +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple.hpp b/include/boost/fusion/tuple/tuple.hpp index 674c3691..6ee21f56 100644 --- a/include/boost/fusion/tuple/tuple.hpp +++ b/include/boost/fusion/tuple/tuple.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,80 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace fusion +{ + template + struct tuple : vector + { + typedef vector base_type; + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple() + : base_type() {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple const& other) + : base_type(other) {} + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple(tuple&& other) + : base_type(std::move(other)) {} + + template + /*BOOST_CONSTEXPR*/ BOOST_FUSION_GPU_ENABLED + explicit + tuple(U&&... args) + : base_type(std::forward(args)...) {} + + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + tuple& operator=(U&& rhs) + { + base_type::operator=(std::forward(rhs)); + return *this; + } + }; + + template + struct tuple_size : result_of::size {}; + + template + struct tuple_element : result_of::value_at_c {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple& tup) + { + return at_c(tup); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::at_c::type + get(Tuple const& tup) + { + return at_c(tup); + } +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple_fwd.hpp b/include/boost/fusion/tuple/tuple_fwd.hpp index 07420234..b763acd5 100644 --- a/include/boost/fusion/tuple/tuple_fwd.hpp +++ b/include/boost/fusion/tuple/tuple_fwd.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,11 +9,35 @@ #include #include +#include + +#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR) \ + || (defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)) +# if defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# undef BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#else +# if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) +# define BOOST_FUSION_HAS_VARIADIC_TUPLE +# endif +#endif /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace fusion +{ + template + struct tuple; +}} #endif +#endif diff --git a/include/boost/fusion/tuple/tuple_tie.hpp b/include/boost/fusion/tuple/tuple_tie.hpp index 92028070..a07dc0a4 100644 --- a/include/boost/fusion/tuple/tuple_tie.hpp +++ b/include/boost/fusion/tuple/tuple_tie.hpp @@ -13,7 +13,26 @@ /////////////////////////////////////////////////////////////////////////////// // With no variadics, we will use the C++03 version /////////////////////////////////////////////////////////////////////////////// +#if !defined(BOOST_FUSION_HAS_VARIADIC_TUPLE) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 interface +/////////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { namespace fusion +{ + template + BOOST_FUSION_GPU_ENABLED + inline tuple + tie(T&... arg) + { + return tuple(arg...); + } +}} #endif +#endif From 7fdb3201faa30a6d21b3e0de530bcf4198d58b2a Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Fri, 24 Jul 2015 22:11:53 +0200 Subject: [PATCH 11/34] [Deque] Make the from-sequence constructor SFINAE friendly --- include/boost/fusion/container/deque/deque.hpp | 3 ++- test/Jamfile | 1 + test/sequence/deque_is_constructible.cpp | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/sequence/deque_is_constructible.cpp diff --git a/include/boost/fusion/container/deque/deque.hpp b/include/boost/fusion/container/deque/deque.hpp index 96919052..dee51bef 100644 --- a/include/boost/fusion/container/deque/deque.hpp +++ b/include/boost/fusion/container/deque/deque.hpp @@ -149,7 +149,8 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit deque(Sequence const& seq - , typename disable_if >::type* /*dummy*/ = 0) + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/test/Jamfile b/test/Jamfile index 87b4bf51..3c782619 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -86,6 +86,7 @@ project [ run sequence/deque_copy.cpp : : : : ] [ run sequence/deque_iterator.cpp : : : : ] [ run sequence/deque_hash.cpp : : : : ] + [ run sequence/deque_is_constructible.cpp : : : : ] [ run sequence/deque_make.cpp : : : : ] [ run sequence/deque_misc.cpp : : : : ] [ run sequence/deque_move.cpp : : : : ] diff --git a/test/sequence/deque_is_constructible.cpp b/test/sequence/deque_is_constructible.cpp new file mode 100644 index 00000000..e7499363 --- /dev/null +++ b/test/sequence/deque_is_constructible.cpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2015 Louis Dionne + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#include +#include + + +struct Dummy { }; + +// Make sure deque's constructor is SFINAE-friendly. +static_assert(!std::is_constructible, Dummy const&>::value, ""); + +int main() { } From 6689de502b3c94888e74921123f338648ea3ba2f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 30 Jul 2015 11:56:09 +0900 Subject: [PATCH 12/34] Implement variadic make_set. --- .../fusion/container/generation/make_set.hpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/boost/fusion/container/generation/make_set.hpp b/include/boost/fusion/container/generation/make_set.hpp index 705ec582..9abcf08e 100644 --- a/include/boost/fusion/container/generation/make_set.hpp +++ b/include/boost/fusion/container/generation/make_set.hpp @@ -10,7 +10,37 @@ #include #include +#if !defined(BOOST_FUSION_HAS_VARIADIC_SET) # include +#else + +/////////////////////////////////////////////////////////////////////////////// +// C++11 variadic interface +/////////////////////////////////////////////////////////////////////////////// + +#include + +namespace boost { namespace fusion +{ + namespace result_of + { + template + struct make_set + { + typedef set type; + }; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline set::type...> + make_set(T const&... arg) + { + return set::type...>(arg...); + } + }} + #endif +#endif From 22994d7e96cad92d5b60540dca662ba1fa229b03 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 4 Aug 2015 16:23:13 +0900 Subject: [PATCH 13/34] Fix a discrepance of element types in make_set. --- include/boost/fusion/container/generation/make_set.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/fusion/container/generation/make_set.hpp b/include/boost/fusion/container/generation/make_set.hpp index 9abcf08e..7f98532b 100644 --- a/include/boost/fusion/container/generation/make_set.hpp +++ b/include/boost/fusion/container/generation/make_set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -27,16 +27,16 @@ namespace boost { namespace fusion template struct make_set { - typedef set type; + typedef set::type...> type; }; } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline set::type...> + inline typename result_of::make_set::type make_set(T const&... arg) { - return set::type...>(arg...); + return typename result_of::make_set::type(arg...); } }} From c5ba3af4c0bf83258c42495b9377e5831bbd3dc2 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 20 Aug 2015 22:30:41 +0900 Subject: [PATCH 14/34] Added move functions for set. --- include/boost/fusion/container/set/set.hpp | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 9e383619..0d93290b 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -1,5 +1,5 @@ /*============================================================================= - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014-2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -100,11 +100,26 @@ namespace boost { namespace fusion set(Sequence const& rhs) : data(rhs) {} +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_FUSION_GPU_ENABLED + set(Sequence&& rhs) + : data(std::forward(rhs)) {} +#endif + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit set(typename detail::call_param::type ...args) : data(args...) {} +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + explicit + set(U&& ...args) + : data(std::forward(args)...) {} +#endif + template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED set& @@ -114,6 +129,17 @@ namespace boost { namespace fusion return *this; } +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + template + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + set& + operator=(U&& rhs) + { + data = std::forward(rhs); + return *this; + } +#endif + BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED storage_type& get_data() { return data; } BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED From 10d9f0ffba1ec80e49e2aedee3d313318bdf4e87 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 25 Aug 2015 23:36:32 +0900 Subject: [PATCH 15/34] Add convert tests for non-assoc containers. --- test/Jamfile | 6 ++++ test/sequence/convert.hpp | 51 +++++++++++++++++++++++++++ test/sequence/convert_boost_tuple.cpp | 14 ++++++++ test/sequence/convert_deque.cpp | 13 +++++++ test/sequence/convert_list.cpp | 13 +++++++ test/sequence/convert_std_pair.cpp | 14 ++++++++ test/sequence/convert_std_tuple.cpp | 25 +++++++++++++ test/sequence/convert_vector.cpp | 13 +++++++ 8 files changed, 149 insertions(+) create mode 100644 test/sequence/convert.hpp create mode 100644 test/sequence/convert_boost_tuple.cpp create mode 100644 test/sequence/convert_deque.cpp create mode 100644 test/sequence/convert_list.cpp create mode 100644 test/sequence/convert_std_pair.cpp create mode 100644 test/sequence/convert_std_tuple.cpp create mode 100644 test/sequence/convert_vector.cpp diff --git a/test/Jamfile b/test/Jamfile index 33701cb6..fbfea3c9 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -65,6 +65,12 @@ project [ run sequence/boost_tuple.cpp : : : : ] [ run sequence/boost_tuple_iterator.cpp : : : : ] [ run sequence/cons.cpp : : : : ] + [ run sequence/convert_boost_tuple.cpp : : : : ] + [ run sequence/convert_deque.cpp : : : : ] + [ run sequence/convert_list.cpp : : : : ] + [ run sequence/convert_std_pair.cpp : : : : ] + [ run sequence/convert_std_tuple.cpp : : : : ] + [ run sequence/convert_vector.cpp : : : : ] [ run sequence/filter_view.cpp : : : : ] [ run sequence/hash.cpp : : : : ] [ run sequence/io.cpp : : : : ] diff --git a/test/sequence/convert.hpp b/test/sequence/convert.hpp new file mode 100644 index 00000000..233fabfb --- /dev/null +++ b/test/sequence/convert.hpp @@ -0,0 +1,51 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) +#include +#endif + +template +void test(FUSION_SEQUENCE const& seq) +{ + typedef typename + boost::fusion::result_of::convert< + Tag + , FUSION_SEQUENCE + >::type + type; + + type v = boost::fusion::convert(seq); + BOOST_TEST((boost::fusion::at_c<0>(v) == 123)); + BOOST_TEST((boost::fusion::at_c<1>(v) == "Hola!!!")); +} + +int main() +{ + FUSION_SEQUENCE seq(123, "Hola!!!"); + test(seq); + test(seq); + test(seq); + test(seq); +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + test(seq); +#endif + + return boost::report_errors(); +} + diff --git a/test/sequence/convert_boost_tuple.cpp b/test/sequence/convert_boost_tuple.cpp new file mode 100644 index 00000000..588ee4d7 --- /dev/null +++ b/test/sequence/convert_boost_tuple.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include +#include + +#define FUSION_SEQUENCE boost::tuples::tuple +#include "convert.hpp" + diff --git a/test/sequence/convert_deque.cpp b/test/sequence/convert_deque.cpp new file mode 100644 index 00000000..5be34d3f --- /dev/null +++ b/test/sequence/convert_deque.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::deque +#include "convert.hpp" + diff --git a/test/sequence/convert_list.cpp b/test/sequence/convert_list.cpp new file mode 100644 index 00000000..57ad0507 --- /dev/null +++ b/test/sequence/convert_list.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::list +#include "convert.hpp" + diff --git a/test/sequence/convert_std_pair.cpp b/test/sequence/convert_std_pair.cpp new file mode 100644 index 00000000..aa350025 --- /dev/null +++ b/test/sequence/convert_std_pair.cpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include +#include + +#define FUSION_SEQUENCE std::pair +#include "convert.hpp" + diff --git a/test/sequence/convert_std_tuple.cpp b/test/sequence/convert_std_tuple.cpp new file mode 100644 index 00000000..3e28276c --- /dev/null +++ b/test/sequence/convert_std_tuple.cpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include + +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) + +#include +#include + +#define FUSION_SEQUENCE std::tuple +#include "convert.hpp" + +#else + +int main() +{ +} + +#endif diff --git a/test/sequence/convert_vector.cpp b/test/sequence/convert_vector.cpp new file mode 100644 index 00000000..b39014df --- /dev/null +++ b/test/sequence/convert_vector.cpp @@ -0,0 +1,13 @@ +/*============================================================================= + Copyright (c) 2015 Kohei Takahashi + + Use modification and distribution are subject to the Boost Software + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt). +==============================================================================*/ + +#include + +#define FUSION_SEQUENCE boost::fusion::vector +#include "convert.hpp" + From e61d08d953372820c311c796fcf7468a73c85d19 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 26 Aug 2015 00:20:07 +0900 Subject: [PATCH 16/34] Fix broken convert, close issue 11572. --- .../boost/fusion/container/deque/detail/convert_impl.hpp | 9 +++++++-- .../fusion/container/deque/detail/cpp03/build_deque.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/container/deque/detail/convert_impl.hpp b/include/boost/fusion/container/deque/detail/convert_impl.hpp index ba9b8477..ede0cc48 100644 --- a/include/boost/fusion/container/deque/detail/convert_impl.hpp +++ b/include/boost/fusion/container/deque/detail/convert_impl.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +13,7 @@ #include #include #include -#include +#include namespace boost { namespace fusion { @@ -41,7 +42,11 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED static type call(Sequence& seq) { - return gen::call(seq); + return gen::call(fusion::begin(seq) +#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE) + , fusion::end(seq) +#endif + ); } }; }; diff --git a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp index 99cbe584..587aa3b0 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/build_deque.hpp @@ -22,6 +22,7 @@ namespace boost { namespace fusion { template struct as_deque + : detail::as_deque::value> { typedef typename detail::as_deque::value> From c30fabf98f68039b698e2e4417e281b881150cde Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 30 Aug 2015 17:13:36 +0900 Subject: [PATCH 17/34] Apply 7fdb320 change into C++98 interface. --- include/boost/fusion/container/deque/detail/cpp03/deque.hpp | 4 +++- test/Jamfile | 2 +- test/sequence/deque_is_constructible.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp index db8a967a..a65fa4ac 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/deque.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/deque.hpp @@ -101,7 +101,9 @@ namespace boost { namespace fusion { template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* /*dummy*/ = 0) + deque(Sequence const& seq + , typename disable_if >::type* /*dummy*/ = 0 + , typename enable_if >::type* /*dummy*/ = 0) : base(base::from_iterator(fusion::begin(seq))) {} diff --git a/test/Jamfile b/test/Jamfile index fbfea3c9..8f290165 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -92,7 +92,7 @@ project [ run sequence/deque_copy.cpp : : : : ] [ run sequence/deque_iterator.cpp : : : : ] [ run sequence/deque_hash.cpp : : : : ] - [ run sequence/deque_is_constructible.cpp : : : : ] + [ compile sequence/deque_is_constructible.cpp : : : : ] [ run sequence/deque_make.cpp : : : : ] [ run sequence/deque_misc.cpp : : : : ] [ run sequence/deque_move.cpp : : : : ] diff --git a/test/sequence/deque_is_constructible.cpp b/test/sequence/deque_is_constructible.cpp index e7499363..e08b4787 100644 --- a/test/sequence/deque_is_constructible.cpp +++ b/test/sequence/deque_is_constructible.cpp @@ -5,6 +5,9 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ +#include + +#ifndef BOOST_NO_CXX11_HDR_TYPE_TRAITS #include #include @@ -14,4 +17,5 @@ struct Dummy { }; // Make sure deque's constructor is SFINAE-friendly. static_assert(!std::is_constructible, Dummy const&>::value, ""); -int main() { } +#endif + From d3449ab5e58d68c2a54d588f3bded4c1dcb2d16e Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 4 Sep 2015 00:51:56 +0900 Subject: [PATCH 18/34] Overhaul the fusion::fold family to make SFINAE-friendly. --- .../fusion/algorithm/iteration/accumulate.hpp | 15 +- .../algorithm/iteration/accumulate_fwd.hpp | 15 +- .../algorithm/iteration/detail/fold.hpp | 474 ++++-------------- .../iteration/detail/segmented_fold.hpp | 7 +- .../boost/fusion/algorithm/iteration/fold.hpp | 11 +- .../fusion/algorithm/iteration/iter_fold.hpp | 12 +- .../algorithm/iteration/reverse_fold.hpp | 11 +- .../algorithm/iteration/reverse_iter_fold.hpp | 11 +- .../boost/fusion/support/detail/result_of.hpp | 53 -- .../fusion/support/segmented_fold_until.hpp | 5 - test/algorithm/fold.cpp | 2 +- test/compile_time/sfinae_friendly.hpp | 4 +- 12 files changed, 131 insertions(+), 489 deletions(-) delete mode 100644 include/boost/fusion/support/detail/result_of.hpp diff --git a/include/boost/fusion/algorithm/iteration/accumulate.hpp b/include/boost/fusion/algorithm/iteration/accumulate.hpp index fe7112e3..7d524a15 100644 --- a/include/boost/fusion/algorithm/iteration/accumulate.hpp +++ b/include/boost/fusion/algorithm/iteration/accumulate.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,8 +11,6 @@ #include #include #include -#include -#include namespace boost { namespace fusion { @@ -27,11 +26,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f) { return fusion::fold(seq, state, f); @@ -39,11 +34,7 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f) { return fusion::fold(seq, state, f); diff --git a/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp b/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp index 50c4d39d..f00e67f9 100644 --- a/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/accumulate_fwd.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2011 Eric Niebler + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +9,6 @@ #define BOOST_FUSION_ACCUMULATE_FWD_HPP_INCLUDED #include -#include -#include namespace boost { namespace fusion { @@ -21,20 +20,12 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence& seq, State const& state, F f); template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename - lazy_enable_if< - traits::is_sequence - , result_of::accumulate - >::type + inline typename result_of::accumulate::type accumulate(Sequence const& seq, State const& state, F f); }} diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 1813bd24..f7fa995b 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2006 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -45,374 +46,121 @@ namespace boost { namespace fusion { namespace detail { - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state) - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It)) - > + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME) {}; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - Result - , N-4 - >::call( - f(state3,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it3)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it3), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it2), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } + typedef typename State::type type; }; - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it2)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it1), - f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it1)); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)), - fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it0), - f); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it0)); - } - }; - - template - struct BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME) - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it2; - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type - it3; - - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest3 - , it3 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it3 - >::type - , F - , N-4 - >::type - type; - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - it1; - - typedef typename - BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT( - BOOST_FUSION_FOLD_NAME, _lvalue_state)< - rest1 - , it1 - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - it1 const - >::type const - , F - >::type - type; - }; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 2 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - typename BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type const - , F - > - {}; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 1 - > - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME, _lvalue_state)< - StateRef - , It0 const - , F - > - {}; - - template - struct BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - StateRef - , It0 - , F - , 0 - > - { - typedef StateRef type; - }; - - template - struct BOOST_PP_CAT(result_of_first_unrolled,BOOST_FUSION_FOLD_NAME) - { - typedef typename - BOOST_PP_CAT(result_of_unrolled_,BOOST_FUSION_FOLD_NAME)< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM( - It0 const) - ) - >::type - , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl) - { - typedef typename - BOOST_PP_CAT( - result_of_first_unrolled,BOOST_FUSION_FOLD_NAME)< - StateRef - , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( - typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + template + struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)::type> + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize-1 + , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename State::type const&, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) - , F - , SeqSize - >::type - type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - BOOST_PP_CAT(unrolled_,BOOST_FUSION_FOLD_NAME)< - type - , SeqSize - > - unrolled_impl; - - return unrolled_impl::call( - state, - BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( - fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq)), - f); - } - }; - - template - struct BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)<0,StateRef,Seq,F> - { - typedef StateRef type; - - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - - template - struct BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME) - : BOOST_PP_CAT(BOOST_FUSION_FOLD_NAME,_impl)< - result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + > , F > {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + 0 + , It + , State + , F + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + SeqSize + , It + , State + , F + > + >::type + BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)(mpl::int_, It const& it, typename State::type state, F& f) + { + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type + , boost::result_of< + F( + typename State::type const&, + BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) + ) + > + , F + >( + mpl::int_() + , fusion::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION(it) + , f(state, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_TRANSFORM(it)) + , f + ); + } + + template::value + , bool = traits::is_segmented::value> + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + {}; + + template + struct BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) + : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< + result_of::size::value + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference::type> + , F + > + {}; + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME)::type + BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F& f) + { + return BOOST_PP_CAT(it_,BOOST_FUSION_FOLD_NAME)< + BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( + typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type + ) + , add_reference::type> + , F + >( + typename result_of::size::type() + , BOOST_FUSION_FOLD_IMPL_FIRST_IT_TRANSFORM( + fusion::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION(seq) + ) + , state + , f + ); + } } namespace result_of { template struct BOOST_FUSION_FOLD_NAME - : detail::BOOST_PP_CAT(result_of_, BOOST_FUSION_FOLD_NAME)< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::BOOST_PP_CAT(result_of_,BOOST_FUSION_FOLD_NAME) {}; } @@ -425,10 +173,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template @@ -440,10 +185,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State const& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template @@ -455,10 +197,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } template @@ -470,10 +209,7 @@ namespace boost { namespace fusion >::type BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) { - return result_of::BOOST_FUSION_FOLD_NAME::call( - state, - seq, - f); + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp index 4ff679af..350bff75 100644 --- a/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/segmented_fold.hpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace detail { @@ -38,11 +39,11 @@ namespace boost { namespace fusion { namespace detail }; // The default implementation of this lives in detail/fold.hpp - template + template struct result_of_fold; template - struct result_of_fold + struct result_of_fold { typedef typename result_of::segmented_fold_until< @@ -53,7 +54,7 @@ namespace boost { namespace fusion { namespace detail type; BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type call(State& state, Sequence& seq, Fun fun) + static type call(Sequence& seq, State& state, Fun& fun) { return fusion::segmented_fold_until(seq, state, segmented_fold_fun(fun)); } diff --git a/include/boost/fusion/algorithm/iteration/fold.hpp b/include/boost/fusion/algorithm/iteration/fold.hpp index a2a0146a..29748cd8 100644 --- a/include/boost/fusion/algorithm/iteration/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/fold.hpp @@ -2,6 +2,7 @@ Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2007 Dan Marsden Copyright (c) 2009-2010 Christopher Schmidt + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,23 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_FOLD_HPP #include -#include #include #include #include -#include -#include #include #include -#include +#include #include #include -#include #include -#include -#include -#include #include +#include #include #include diff --git a/include/boost/fusion/algorithm/iteration/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/iter_fold.hpp index b59a6957..952466a1 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,19 +14,14 @@ #include #include #include -#include -#include #include #include -#include -#include +#include #include #include -#include #include -#include -#include -#include +#include +#include #include #include diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp index dffff79e..f2d060f3 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,23 +11,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include +#include #include #include diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp index d36861f3..85abf12f 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp @@ -1,6 +1,7 @@ /*============================================================================= Copyright (c) 2010 Christopher Schmidt Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2015 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,23 +10,17 @@ #define BOOST_FUSION_ALGORITHM_ITERATION_REVERSE_ITER_FOLD_HPP #include -#include #include #include -#include #include -#include #include #include -#include +#include #include #include #include -#include -#include -#include -#include #include +#include #include #include diff --git a/include/boost/fusion/support/detail/result_of.hpp b/include/boost/fusion/support/detail/result_of.hpp deleted file mode 100644 index e53ea9e3..00000000 --- a/include/boost/fusion/support/detail/result_of.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2014 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_RESULT_OF_10272014_0654) -#define FUSION_RESULT_OF_10272014_0654 - -#include -#include - -#if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) -#define BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF -#endif - -#if !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) -#include -#include -#include -#endif - -namespace boost { namespace fusion { namespace detail -{ - // This is a temporary workaround for result_of before we make fusion fully - // sfinae result_of friendy, which will require some heavy lifting for some - // low level code. So far this is used only in the fold algorithm. This will - // be removed once we overhaul fold. - -#if defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - template - struct result_of_with_decltype : boost::tr1_result_of {}; - -#else // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - - BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type) - BOOST_MPL_HAS_XXX_TEMPLATE_DEF(result) - - template - struct result_of_with_decltype; - - template - struct result_of_with_decltype - : mpl::if_, detail::has_result >, - boost::tr1_result_of, - boost::detail::cpp0x_result_of >::type {}; - -#endif // defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) - -}}} - -#endif diff --git a/include/boost/fusion/support/segmented_fold_until.hpp b/include/boost/fusion/support/segmented_fold_until.hpp index 9e6f4a50..8fb09ee3 100644 --- a/include/boost/fusion/support/segmented_fold_until.hpp +++ b/include/boost/fusion/support/segmented_fold_until.hpp @@ -11,11 +11,6 @@ #include #include #include -#include -#include -#include -#include -#include namespace boost { namespace fusion { diff --git a/test/algorithm/fold.cpp b/test/algorithm/fold.cpp index 249f1bb3..c441ceaf 100644 --- a/test/algorithm/fold.cpp +++ b/test/algorithm/fold.cpp @@ -238,7 +238,7 @@ main() } { -#if !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) +#if defined(BOOST_RESULT_OF_USE_DECLTYPE) { boost::fusion::vector container{1, 2, 3}; functor f; diff --git a/test/compile_time/sfinae_friendly.hpp b/test/compile_time/sfinae_friendly.hpp index 77b148b8..1111cd8c 100644 --- a/test/compile_time/sfinae_friendly.hpp +++ b/test/compile_time/sfinae_friendly.hpp @@ -12,9 +12,9 @@ #include #include #include -#include +#include -#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_FUSION_NO_DECLTYPE_BASED_RESULT_OF) +#if !defined(BOOST_NO_SFINAE) && defined(BOOST_RESULT_OF_USE_DECLTYPE) #include From 59dfeec8157c419fabfb2a26f2412547d9a18d85 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 8 Sep 2015 00:18:37 +0900 Subject: [PATCH 19/34] Add workarounds for older MSVC. --- .../fusion/algorithm/iteration/detail/fold.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index f7fa995b..22cb6ecd 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -59,13 +59,18 @@ namespace boost { namespace fusion template struct BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)::type> + // MSVC9 issues a compile error as a partial specialization is ambiguous. + , typename boost::enable_if_has_type< + typename boost::disable_if_c::type::type + >::type> : BOOST_PP_CAT(result_of_it_,BOOST_FUSION_FOLD_NAME)< SeqSize-1 , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( - typename State::type const&, + typename add_reference::type>::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > @@ -103,7 +108,9 @@ namespace boost { namespace fusion typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( - typename State::type const&, + typename add_reference::type>::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > From 9b77c26a24500a19612589ef54235f64ede41a40 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 8 Sep 2015 00:22:58 +0900 Subject: [PATCH 20/34] Remove unnecessary overloads, state should always be const. --- .../algorithm/iteration/detail/fold.hpp | 24 ------------------- .../fusion/algorithm/iteration/fold_fwd.hpp | 18 -------------- .../algorithm/iteration/iter_fold_fwd.hpp | 18 -------------- .../algorithm/iteration/reverse_fold_fwd.hpp | 18 -------------- .../iteration/reverse_iter_fold_fwd.hpp | 18 -------------- 5 files changed, 96 deletions(-) diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 22cb6ecd..5c3ec765 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -194,30 +194,6 @@ namespace boost { namespace fusion { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::BOOST_FUSION_FOLD_NAME< - Seq - , State const - , F - >::type - BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) - { - return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); - } - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::BOOST_FUSION_FOLD_NAME< - Seq const - , State const - , F - >::type - BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) - { - return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); - } }} #undef BOOST_FUSION_FOLD_NAME diff --git a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp index f8328e80..06dd6dda 100644 --- a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp @@ -33,24 +33,6 @@ namespace boost { namespace fusion , F >::type fold(Seq const& seq, State const& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::fold< - Seq - , State const - , F - >::type - fold(Seq& seq, State& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::fold< - Seq const - , State const - , F - >::type - fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index 6c595cf1..e7b7f434 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp @@ -33,24 +33,6 @@ namespace boost { namespace fusion , F >::type iter_fold(Seq const& seq, State const& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::iter_fold< - Seq - , State const - , F - >::type - iter_fold(Seq& seq, State& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::iter_fold< - Seq const - , State const - , F - >::type - iter_fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index 42c8ac21..f1dd8ac7 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp @@ -33,24 +33,6 @@ namespace boost { namespace fusion , F >::type reverse_fold(Seq const& seq, State const& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::reverse_fold< - Seq - , State const - , F - >::type - reverse_fold(Seq& seq, State& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::reverse_fold< - Seq const - , State const - , F - >::type - reverse_fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 21d99dee..6a60931d 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp @@ -33,24 +33,6 @@ namespace boost { namespace fusion , F >::type reverse_iter_fold(Seq const& seq, State const& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::reverse_iter_fold< - Seq - , State const - , F - >::type - reverse_iter_fold(Seq& seq, State& state, F f); - - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - inline typename result_of::reverse_iter_fold< - Seq const - , State const - , F - >::type - reverse_iter_fold(Seq const& seq, State& state, F f); }} #endif From 1df7fc1dcad0023693cb4065fd1dcc851ae858d1 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 8 Sep 2015 13:59:48 +0900 Subject: [PATCH 21/34] Revert "Remove unnecessary overloads, state should always be const." This reverts commit 9b77c26a24500a19612589ef54235f64ede41a40. As discussed on github, the original code was wrong. --- .../algorithm/iteration/detail/fold.hpp | 24 +++++++++++++++++++ .../fusion/algorithm/iteration/fold_fwd.hpp | 18 ++++++++++++++ .../algorithm/iteration/iter_fold_fwd.hpp | 18 ++++++++++++++ .../algorithm/iteration/reverse_fold_fwd.hpp | 18 ++++++++++++++ .../iteration/reverse_iter_fold_fwd.hpp | 18 ++++++++++++++ 5 files changed, 96 insertions(+) diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 5c3ec765..22cb6ecd 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -194,6 +194,30 @@ namespace boost { namespace fusion { return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::BOOST_FUSION_FOLD_NAME< + Seq + , State const + , F + >::type + BOOST_FUSION_FOLD_NAME(Seq& seq, State& state, F f) + { + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); + } + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::BOOST_FUSION_FOLD_NAME< + Seq const + , State const + , F + >::type + BOOST_FUSION_FOLD_NAME(Seq const& seq, State& state, F f) + { + return detail::BOOST_FUSION_FOLD_NAME(seq, state, f); + } }} #undef BOOST_FUSION_FOLD_NAME diff --git a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp index 06dd6dda..f8328e80 100644 --- a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp @@ -33,6 +33,24 @@ namespace boost { namespace fusion , F >::type fold(Seq const& seq, State const& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::fold< + Seq + , State const + , F + >::type + fold(Seq& seq, State& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::fold< + Seq const + , State const + , F + >::type + fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index e7b7f434..6c595cf1 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp @@ -33,6 +33,24 @@ namespace boost { namespace fusion , F >::type iter_fold(Seq const& seq, State const& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::iter_fold< + Seq + , State const + , F + >::type + iter_fold(Seq& seq, State& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::iter_fold< + Seq const + , State const + , F + >::type + iter_fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index f1dd8ac7..42c8ac21 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp @@ -33,6 +33,24 @@ namespace boost { namespace fusion , F >::type reverse_fold(Seq const& seq, State const& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::reverse_fold< + Seq + , State const + , F + >::type + reverse_fold(Seq& seq, State& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::reverse_fold< + Seq const + , State const + , F + >::type + reverse_fold(Seq const& seq, State& state, F f); }} #endif diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 6a60931d..21d99dee 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp @@ -33,6 +33,24 @@ namespace boost { namespace fusion , F >::type reverse_iter_fold(Seq const& seq, State const& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::reverse_iter_fold< + Seq + , State const + , F + >::type + reverse_iter_fold(Seq& seq, State& state, F f); + + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of::reverse_iter_fold< + Seq const + , State const + , F + >::type + reverse_iter_fold(Seq const& seq, State& state, F f); }} #endif From 76b7697ba5e5449276a9a9dcbd881aa180a28624 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 8 Sep 2015 15:14:27 +0900 Subject: [PATCH 22/34] fusion::fold allows to take non-const lv-ref state properly. --- doc/algorithm.qbk | 16 ++++++++++++++++ .../fusion/algorithm/iteration/detail/fold.hpp | 16 ++++++---------- .../boost/fusion/algorithm/iteration/fold.hpp | 1 - .../fusion/algorithm/iteration/fold_fwd.hpp | 4 ++-- .../fusion/algorithm/iteration/iter_fold.hpp | 1 - .../fusion/algorithm/iteration/iter_fold_fwd.hpp | 4 ++-- .../fusion/algorithm/iteration/reverse_fold.hpp | 1 - .../algorithm/iteration/reverse_fold_fwd.hpp | 4 ++-- .../algorithm/iteration/reverse_iter_fold.hpp | 1 - .../iteration/reverse_iter_fold_fwd.hpp | 4 ++-- test/algorithm/fold.hpp | 2 +- 11 files changed, 31 insertions(+), 23 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index f47fce5c..975887a1 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -258,6 +258,22 @@ the first call) and [arg_desc] of `seq`. typename result_of_name_macro::type name_macro( Sequence const& seq, State const& initial_state, F f); + template< + typename Sequence, + typename State, + typename F + > + typename result_of_name_macro::type name_macro( + Sequence& seq, State& initial_state, F f); + + template< + typename Sequence, + typename State, + typename F + > + typename result_of_name_macro::type name_macro( + Sequence const& seq, State& initial_state, F f); + [def seq_concept_macro [seq_concept]] [def arg_type_id_macro [arg_type_id]] [def arg_id_macro [arg_id]] diff --git a/include/boost/fusion/algorithm/iteration/detail/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/fold.hpp index 22cb6ecd..ddc4d0af 100644 --- a/include/boost/fusion/algorithm/iteration/detail/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/fold.hpp @@ -68,9 +68,7 @@ namespace boost { namespace fusion , typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( - typename add_reference::type>::type, + typename add_reference::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > @@ -108,9 +106,7 @@ namespace boost { namespace fusion typename result_of::BOOST_FUSION_FOLD_IMPL_NEXT_IT_FUNCTION::type , boost::result_of< F( - typename add_reference::type>::type, + typename add_reference::type, BOOST_FUSION_FOLD_IMPL_INVOKE_IT_META_TRANSFORM(It const) ) > @@ -136,7 +132,7 @@ namespace boost { namespace fusion , BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type ) - , add_reference::type> + , add_reference , F > {}; @@ -150,7 +146,7 @@ namespace boost { namespace fusion BOOST_FUSION_FOLD_IMPL_FIRST_IT_META_TRANSFORM( typename result_of::BOOST_FUSION_FOLD_IMPL_FIRST_IT_FUNCTION::type ) - , add_reference::type> + , add_reference , F >( typename result_of::size::type() @@ -199,7 +195,7 @@ namespace boost { namespace fusion 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) @@ -211,7 +207,7 @@ namespace boost { namespace fusion 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) diff --git a/include/boost/fusion/algorithm/iteration/fold.hpp b/include/boost/fusion/algorithm/iteration/fold.hpp index 29748cd8..039e01c0 100644 --- a/include/boost/fusion/algorithm/iteration/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/fold.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) diff --git a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp index f8328e80..0dbac761 100644 --- a/include/boost/fusion/algorithm/iteration/fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/iter_fold.hpp index 952466a1..cff5b4ed 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #define BOOST_FUSION_ITER_FOLD diff --git a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp index 6c595cf1..1d8543ca 100644 --- a/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp index f2d060f3..252ad308 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp index 42c8ac21..c5e24b34 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f); diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp index 85abf12f..3276bbde 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BOOST_FUSION_REVERSE_FOLD diff --git a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp index 21d99dee..76f01863 100644 --- a/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp +++ b/include/boost/fusion/algorithm/iteration/reverse_iter_fold_fwd.hpp @@ -38,7 +38,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f); @@ -47,7 +47,7 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f); diff --git a/test/algorithm/fold.hpp b/test/algorithm/fold.hpp index 87a81a7c..997623ea 100644 --- a/test/algorithm/fold.hpp +++ b/test/algorithm/fold.hpp @@ -189,7 +189,7 @@ struct fold_test_n >::type , typename mpl::if_c< !n - , mpl::vector, mpl::int_<0> > const& + , mpl::vector, mpl::int_<0> >& , mpl::vector, mpl::int_ > >::type > From a6d1b303b36a8a9f7db1afbd5e650181d849d3cc Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 9 Sep 2015 13:35:03 +0900 Subject: [PATCH 23/34] Fix block comment style. Intel Compiler warns on nested comment. --- include/boost/fusion/algorithm/transformation/flatten.hpp | 4 ++-- include/boost/fusion/view/flatten_view.hpp | 4 ++-- include/boost/fusion/view/flatten_view/flatten_view.hpp | 4 ++-- .../boost/fusion/view/flatten_view/flatten_view_iterator.hpp | 4 ++-- test/algorithm/flatten.cpp | 4 ++-- test/sequence/flatten_view.cpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/boost/fusion/algorithm/transformation/flatten.hpp b/include/boost/fusion/algorithm/transformation/flatten.hpp index e3cfa983..43ac34df 100644 --- a/include/boost/fusion/algorithm/transformation/flatten.hpp +++ b/include/boost/fusion/algorithm/transformation/flatten.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #ifndef BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED #define BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED diff --git a/include/boost/fusion/view/flatten_view.hpp b/include/boost/fusion/view/flatten_view.hpp index dcef08de..25428544 100644 --- a/include/boost/fusion/view/flatten_view.hpp +++ b/include/boost/fusion/view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #ifndef BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED diff --git a/include/boost/fusion/view/flatten_view/flatten_view.hpp b/include/boost/fusion/view/flatten_view/flatten_view.hpp index 8e40158d..401f65dc 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #ifndef BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED diff --git a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp index 1ecf6928..be115d91 100644 --- a/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp +++ b/include/boost/fusion/view/flatten_view/flatten_view_iterator.hpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #ifndef BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED #define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED diff --git a/test/algorithm/flatten.cpp b/test/algorithm/flatten.cpp index 28d6359f..ddc71006 100644 --- a/test/algorithm/flatten.cpp +++ b/test/algorithm/flatten.cpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #include #include #include diff --git a/test/sequence/flatten_view.cpp b/test/sequence/flatten_view.cpp index f24c1d95..da8e6527 100644 --- a/test/sequence/flatten_view.cpp +++ b/test/sequence/flatten_view.cpp @@ -1,9 +1,9 @@ -/*////////////////////////////////////////////////////////////////////////////// +/*============================================================================== Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -//////////////////////////////////////////////////////////////////////////////*/ +==============================================================================*/ #include #include #include From cbd2e1dc1d43a73c9fb159ec1c760502dbb88f85 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 9 Sep 2015 18:05:04 +0900 Subject: [PATCH 24/34] Suppress unused warning. --- test/algorithm/pop_back.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp index 5e45e779..fcb5b75c 100644 --- a/test/algorithm/pop_back.cpp +++ b/test/algorithm/pop_back.cpp @@ -88,6 +88,7 @@ main() auto i1 = find(popv); auto i2 = find(pop); + (void)push; BOOST_TEST(i1 != end(pop)); BOOST_TEST(i2 != end(pop)); BOOST_TEST(i1 != i2); From ef39bc86517e3ca0df346538c4010178cc6346f7 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 21 Sep 2015 16:19:41 +0900 Subject: [PATCH 25/34] Update docs for variadic containers. --- doc/container.qbk | 178 ++++++++++++++++++++++++++++------------------ 1 file changed, 110 insertions(+), 68 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 8a29e29b..fccd2102 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -66,6 +66,11 @@ cases the most efficient. template struct vectorN; +[important Numbered forms will be deprecated in C++11 and it will be provided + via aliasing templates. It means that your partial specialization + might be compile error. You can detect whether it is aliasing + templates or not, using `BOOST_FUSION_HAS_VARIADIC_VECTOR`.] + [*Variadic form] template < @@ -81,9 +86,11 @@ The numbered form accepts the exact number of elements. Example: vector3 -The variadic form accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, where -`FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the The variadic form accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. Example: vector @@ -232,9 +239,11 @@ each element is peculiarly constant (see __recursive_inline__). > struct list; -The variadic class interface accepts `0` to `FUSION_MAX_LIST_SIZE` -elements, where `FUSION_MAX_LIST_SIZE` is a user definable predefined -maximum that defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: list @@ -532,9 +541,11 @@ complexity (see __overloaded_functions__). > struct set; -The variadic class interface accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: set @@ -614,9 +625,11 @@ __overloaded_functions__). > struct map; -The variadic class interface accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic class interface accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user +definable predefined maximum that defaults to `10`. Example: map<__pair__, __pair__, __pair__ > @@ -697,10 +710,13 @@ Create a __list__ from one or more values. typename __result_of_make_list__::type make_list(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -794,11 +810,13 @@ Create a __vector__ from one or more values. typename __result_of_make_vector__::type make_vector(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. You may define +the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any +Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -896,11 +914,13 @@ Create a __set__ from one or more values. typename __result_of_make_set__::type make_set(T0 const& x0, T1 const& x1... TN const& xN); -The variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_SET_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_SET_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_SET_SIZE 20 @@ -1049,10 +1069,13 @@ Constructs a tie using a __list__ sequence. __list__ list_tie(T0& x0, T1& x1... TN& xN); -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1096,11 +1119,13 @@ Constructs a tie using a __vector__ sequence. __vector__ vector_tie(T0& x0, T1& x1... TN& xN); -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a +user definable predefined maximum that defaults to `10`. You may define +the preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any +Fusion header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1144,11 +1169,14 @@ Constructs a tie using a __map__ sequence. __map__<__pair__, __pair__,... __pair__ > map_tie(D0& d0, D1& d1... DN& dN); -The variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`, and a corresponding number of key types. -You may define the preprocessor constant `FUSION_MAX_MAP_SIZE` before -including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user +definable predefined maximum that defaults to `10`, and a corresponding +number of key types. You may define the preprocessor constant +`FUSION_MAX_MAP_SIZE` before including any Fusion header to change the +default. Example: #define FUSION_MAX_MAP_SIZE 20 @@ -1249,10 +1277,13 @@ Returns the result type of __make_list__. template struct make_list; -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1333,11 +1364,13 @@ Returns the result type of __make_vector__. template struct make_vector; -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1427,11 +1460,13 @@ Returns the result type of __make_set__. template struct make_set; -The variadic function accepts `0` to `FUSION_MAX_SET_SIZE` elements, -where `FUSION_MAX_SET_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_SET_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_SET_SIZE` elements, where `FUSION_MAX_SET_SIZE` is a user definable +predefined maximum that defaults to `10`. You may define the preprocessor +constant `FUSION_MAX_SET_SIZE` before including any Fusion header to change +the default. Example: #define FUSION_MAX_SET_SIZE 20 @@ -1559,10 +1594,13 @@ Returns the result type of __list_tie__. template struct list_tie; -The variadic function accepts `0` to `FUSION_MAX_LIST_SIZE` elements, where -`FUSION_MAX_LIST_SIZE` is a user definable predefined maximum that defaults -to `10`. You may define the preprocessor constant `FUSION_MAX_LIST_SIZE` -before including any Fusion header to change the default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_LIST_SIZE` elements, where `FUSION_MAX_LIST_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_LIST_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_LIST_SIZE 20 @@ -1603,11 +1641,13 @@ Returns the result type of __vector_tie__. template struct vector_tie; -The variadic function accepts `0` to `FUSION_MAX_VECTOR_SIZE` elements, -where `FUSION_MAX_VECTOR_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_VECTOR_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_VECTOR_SIZE` elements, where `FUSION_MAX_VECTOR_SIZE` is a user +definable predefined maximum that defaults to `10`. You may define the +preprocessor constant `FUSION_MAX_VECTOR_SIZE` before including any Fusion +header to change the default. Example: #define FUSION_MAX_VECTOR_SIZE 20 @@ -1695,11 +1735,13 @@ Returns the result type of __map_tie__. template struct map_tie; -The variadic function accepts `0` to `FUSION_MAX_MAP_SIZE` elements, -where `FUSION_MAX_MAP_SIZE` is a user definable predefined maximum that -defaults to `10`. You may define the preprocessor constant -`FUSION_MAX_MAP_SIZE` before including any Fusion header to change the -default. Example: +For C++11 compilers, the variadic function interface has no upper bound. + +For C++03 compilers, the variadic function accepts `0` to +`FUSION_MAX_MAP_SIZE` elements, where `FUSION_MAX_MAP_SIZE` is a user definable +predefined maximum that defaults to `10`. You may define the preprocessor +constant `FUSION_MAX_MAP_SIZE` before including any Fusion header to change +the default. Example: #define FUSION_MAX_MAP_SIZE 20 From 999dad386e2b5fdfcf075c2f09aea3616cb8ad7e Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 6 Oct 2015 01:24:45 +0900 Subject: [PATCH 26/34] doc: Fix return type of algorithms, close #3358. --- doc/algorithm.qbk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/algorithm.qbk b/doc/algorithm.qbk index f47fce5c..682d5035 100644 --- a/doc/algorithm.qbk +++ b/doc/algorithm.qbk @@ -1722,7 +1722,7 @@ Takes 2 sequences and returns a sequence containing the elements of the first fo template< typename LhSequence, typename RhSequence> - typename __result_of_join__::type join(LhSequence const& lhs, RhSequence const& rhs); + typename __result_of_join__::type join(LhSequence const& lhs, RhSequence const& rhs); [table Parameters [[Parameter][Requirement][Description]] @@ -1767,7 +1767,7 @@ Zips sequences together to form a single sequence, whose members are tuples of t ... typename SequenceN > - typename __result_of_zip__::type + typename __result_of_zip__::type zip(Sequence1 const& seq1, Sequence2 const& seq2, ... SequenceN const& seqN); [table Parameters @@ -1886,7 +1886,7 @@ Returns a new sequence with an element added at the end. typename Sequence, typename T > - typename __result_of_push_back__::type push_back( + typename __result_of_push_back__::type push_back( Sequence const& seq, T const& t); [table Parameters @@ -1927,7 +1927,7 @@ Returns a new sequence with an element added at the beginning. typename Sequence, typename T > - typename __result_of_push_front__::type push_front( + typename __result_of_push_front__::type push_front( Sequence const& seq, T const& t); [table Parameters From c750552a0255676a0bba40261179e3c3ed3a90cd Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 6 Oct 2015 11:28:16 +0900 Subject: [PATCH 27/34] Tweak coding style. --- include/boost/fusion/container/vector/vector.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index ab1c1f04..9c5032f9 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -66,12 +66,12 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline each_elem - dispatch( T const&... ) BOOST_NOEXCEPT { return each_elem(); } + dispatch(T const&...) BOOST_NOEXCEPT { return each_elem(); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline copy_or_move - dispatch( This const& ) BOOST_NOEXCEPT { return copy_or_move(); } + dispatch(This const&) BOOST_NOEXCEPT { return copy_or_move(); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -82,7 +82,7 @@ namespace boost { namespace fusion , make_indices_from_seq >::type > - dispatch( Sequence const& ) BOOST_NOEXCEPT + dispatch(Sequence const&) BOOST_NOEXCEPT { return from_sequence::type>(); } From ca0d92e68df0a0fe109db37043847fecd7044246 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 6 Oct 2015 21:29:02 +0900 Subject: [PATCH 28/34] R-value references are now container-wide requirements. --- .../fusion/container/generation/make_set.hpp | 15 +++++++++++--- include/boost/fusion/container/set/set.hpp | 20 ------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/include/boost/fusion/container/generation/make_set.hpp b/include/boost/fusion/container/generation/make_set.hpp index 7f98532b..cd8519e5 100644 --- a/include/boost/fusion/container/generation/make_set.hpp +++ b/include/boost/fusion/container/generation/make_set.hpp @@ -19,6 +19,9 @@ /////////////////////////////////////////////////////////////////////////////// #include +#include +#include +#include namespace boost { namespace fusion { @@ -27,16 +30,22 @@ namespace boost { namespace fusion template struct make_set { - typedef set::type...> type; + typedef set< + typename detail::as_fusion_element< + typename remove_const< + typename remove_reference::type + >::type + >::type... + > type; }; } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::make_set::type - make_set(T const&... arg) + make_set(T&&... arg) { - return typename result_of::make_set::type(arg...); + return typename result_of::make_set::type(std::forward(arg)...); } }} diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 0d93290b..8d5cc13b 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -95,41 +95,22 @@ namespace boost { namespace fusion set() : data() {} - template - BOOST_FUSION_GPU_ENABLED - set(Sequence const& rhs) - : data(rhs) {} - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template BOOST_FUSION_GPU_ENABLED set(Sequence&& rhs) : data(std::forward(rhs)) {} -#endif BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit set(typename detail::call_param::type ...args) : data(args...) {} -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit set(U&& ...args) : data(std::forward(args)...) {} -#endif - template - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - set& - operator=(U const& rhs) - { - data = rhs; - return *this; - } - -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED set& @@ -138,7 +119,6 @@ namespace boost { namespace fusion data = std::forward(rhs); return *this; } -#endif BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED storage_type& get_data() { return data; } From 5114d9419e50d54fb2b8cbc6ba40e031b12fede1 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 7 Oct 2015 17:40:55 +0900 Subject: [PATCH 29/34] Drop unnecessary ctor. --- include/boost/fusion/container/set/set.hpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index 8d5cc13b..df87c495 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -100,13 +100,8 @@ namespace boost { namespace fusion set(Sequence&& rhs) : data(std::forward(rhs)) {} - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - explicit - set(typename detail::call_param::type ...args) - : data(args...) {} - template - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED explicit set(U&& ...args) : data(std::forward(args)...) {} From ce4ccb929c04dab25ba941c5ba010480d677cbbd Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 8 Oct 2015 22:23:10 +0900 Subject: [PATCH 30/34] Check the argument being fusion sequence or not. --- include/boost/fusion/container/set/set.hpp | 12 ++++++-- .../fusion/support/detail/is_same_size.hpp | 29 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 include/boost/fusion/support/detail/is_same_size.hpp diff --git a/include/boost/fusion/container/set/set.hpp b/include/boost/fusion/container/set/set.hpp index df87c495..12fd8115 100644 --- a/include/boost/fusion/container/set/set.hpp +++ b/include/boost/fusion/container/set/set.hpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,8 +33,8 @@ #include #include #include -#include #include +#include namespace boost { namespace fusion { @@ -57,7 +59,9 @@ namespace boost { namespace fusion template BOOST_FUSION_GPU_ENABLED - set(Sequence const& rhs) + set(Sequence const& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) : data(rhs) {} template @@ -97,7 +101,9 @@ namespace boost { namespace fusion template BOOST_FUSION_GPU_ENABLED - set(Sequence&& rhs) + set(Sequence&& rhs, + typename enable_if >::type* = 0, + typename enable_if >::type* = 0) : data(std::forward(rhs)) {} template diff --git a/include/boost/fusion/support/detail/is_same_size.hpp b/include/boost/fusion/support/detail/is_same_size.hpp new file mode 100644 index 00000000..b1bf7cde --- /dev/null +++ b/include/boost/fusion/support/detail/is_same_size.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2014-2015 Kohei Takahashi + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef FUSION_IS_SAME_SIZE_10082015_1156 +#define FUSION_IS_SAME_SIZE_10082015_1156 + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct is_same_size : mpl::false_ {}; + + template + struct is_same_size >::type, + typename enable_if >::type> + : mpl::equal_to, result_of::size > + {}; +}}} + +#endif From a81024f617665b9ae1c2d60d4190e50ddc17ca3f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 17 Oct 2015 11:24:19 +0900 Subject: [PATCH 31/34] Regenerate preprocessed files. --- .../iteration/detail/preprocessed/fold.hpp | 423 ++++-------------- .../detail/preprocessed/iter_fold.hpp | 423 ++++-------------- .../detail/preprocessed/reverse_fold.hpp | 423 ++++-------------- .../detail/preprocessed/reverse_iter_fold.hpp | 423 ++++-------------- .../detail/cpp03/preprocessed/deque10.hpp | 4 +- .../detail/cpp03/preprocessed/deque20.hpp | 4 +- .../detail/cpp03/preprocessed/deque30.hpp | 4 +- .../detail/cpp03/preprocessed/deque40.hpp | 4 +- .../detail/cpp03/preprocessed/deque50.hpp | 4 +- 9 files changed, 375 insertions(+), 1337 deletions(-) diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp index bd3b1dbd..eb5bc9ab 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/fold.hpp @@ -12,341 +12,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > + template + struct result_of_it_fold {}; - template - struct unrolled_fold + template + struct result_of_it_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::next(it0), - f); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_fold - { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_fold< - typename fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - fold_lvalue_state< - typename fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 2 - > - : fold_lvalue_state< - typename fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_fold::type::type + >::type> + : result_of_it_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_fold< + 0 + , It + , State , F - , 1 - > - : fold_lvalue_state< - StateRef - , It0 const + >::type + it_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledfold - { - typedef typename - result_of_unrolled_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct fold_impl - { - typedef typename - result_of_first_unrolledfold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_fold - : fold_impl< + {}; + template + struct result_of_fold + : result_of_it_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_fold::type + fold(Seq& seq, State& state, F& f) + { + return it_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct fold - : detail::result_of_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_fold {}; } template @@ -358,10 +127,7 @@ namespace boost { namespace fusion >::type fold(Seq& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -372,37 +138,28 @@ namespace boost { namespace fusion >::type fold(Seq const& seq, State const& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq - , State const + , State , F >::type fold(Seq& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::fold< Seq const - , State const + , State , F >::type fold(Seq const& seq, State& state, F f) { - return result_of::fold::call( - state, - seq, - f); + return detail::fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp index 1d294a87..3895526c 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/iter_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > + template + struct result_of_it_iter_fold {}; - template - struct unrolled_iter_fold + template + struct result_of_it_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::next(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::next(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::next(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::next(it0), - f); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_iter_fold - { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::next::type - it2; - typedef typename - iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::next::type - it3; - typedef typename - result_of_unrolled_iter_fold< - typename iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::next< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::next< - It0 const - >::type - it1; - typedef typename - iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::next< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 2 - > - : iter_fold_lvalue_state< - typename iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::next< - It0 const - >::type const + template + struct result_of_it_iter_fold::type::type + >::type> + : result_of_it_iter_fold< + SeqSize-1 + , typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_iter_fold< + 0 + , It + , State , F - , 1 - > - : iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrollediter_fold - { - typedef typename - result_of_unrolled_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::next< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct iter_fold_impl - { - typedef typename - result_of_first_unrollediter_fold< - StateRef - , typename result_of::begin::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::begin(seq), - f); - } - }; - template - struct iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_iter_fold< + typename result_of::next::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::next(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_iter_fold - : iter_fold_impl< + {}; + template + struct result_of_iter_fold + : result_of_it_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename result_of::begin::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_iter_fold::type + iter_fold(Seq& seq, State& state, F& f) + { + return it_iter_fold< + typename result_of::begin::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::begin(seq) + , state + , f + ); + } } namespace result_of { template struct iter_fold - : detail::result_of_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_iter_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type iter_fold(Seq& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type iter_fold(Seq const& seq, State const& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq - , State const + , State , F >::type iter_fold(Seq& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::iter_fold< Seq const - , State const + , State , F >::type iter_fold(Seq const& seq, State& state, F f) { - return result_of::iter_fold::call( - state, - seq, - f); + return detail::iter_fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp index 94789782..a6705b08 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct reverse_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - typename fusion::result_of::deref::type) - > + template + struct result_of_it_reverse_fold {}; - template - struct unrolled_reverse_fold + template + struct result_of_it_reverse_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_fold< - Result - , N-4 - >::call( - f(state3,fusion::deref(it3)), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,fusion::deref(it2)), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,fusion::deref(it2)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,fusion::deref(it1)), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,fusion::deref(it1)); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,fusion::deref(it0)), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - fusion::deref(it0)); - } - }; - template - struct unrolled_reverse_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_fold - { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_fold< - typename reverse_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_fold_lvalue_state< - typename reverse_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_fold::type::type + >::type> + : result_of_it_reverse_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > , F > {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_fold< + 0 + , It + , State , F - , 1 - > - : reverse_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_fold - { - typedef typename - result_of_unrolled_reverse_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - typename fusion::result_of::deref< It0 const>::type - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_fold_impl - { - typedef typename - result_of_first_unrolledreverse_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + typename fusion::result_of::deref::type + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, fusion::deref(it)) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_fold - : reverse_fold_impl< + {}; + template + struct result_of_reverse_fold + : result_of_it_reverse_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_fold::type + reverse_fold(Seq& seq, State& state, F& f) + { + return it_reverse_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_fold - : detail::result_of_reverse_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type reverse_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type reverse_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq - , State const + , State , F >::type reverse_fold(Seq& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_fold< Seq const - , State const + , State , F >::type reverse_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_fold::call( - state, - seq, - f); + return detail::reverse_fold(seq, state, f); } }} diff --git a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp index bf1edca5..b6101cb1 100644 --- a/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp +++ b/include/boost/fusion/algorithm/iteration/detail/preprocessed/reverse_iter_fold.hpp @@ -11,341 +11,110 @@ namespace boost { namespace fusion { namespace detail { - template - struct reverse_iter_fold_lvalue_state - : fusion::detail::result_of_with_decltype< - F( - typename add_reference::type>::type, - It&) - > + template + struct result_of_it_reverse_iter_fold {}; - template - struct unrolled_reverse_iter_fold + template + struct result_of_it_reverse_iter_fold<0,It,State,F + , typename boost::enable_if_has_type::type> { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_3(State3 const& state3,It3 const& it3,F& f) - { - return unrolled_reverse_iter_fold< - Result - , N-4 - >::call( - f(state3,it3), - fusion::prior(it3), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return call_3( - f(state2,it2), - fusion::prior(it2), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } + typedef typename State::type type; }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_2(State2 const& state2,It2 const& it2,F& f) - { - return f(state2,it2); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return call_2( - f(state1,it1), - fusion::prior(it1), - f); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call_1(State1 const& state1,It1 const& it1,F& f) - { - return f(state1,it1); - } - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return call_1( - f(state,it0), - fusion::prior(it0), - f); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const& it0,F f) - { - return f(state, - it0); - } - }; - template - struct unrolled_reverse_iter_fold - { - template - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static Result - call(State const& state,It0 const&, F) - { - return static_cast(state); - } - }; - template - struct result_of_unrolled_reverse_iter_fold - { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - rest2; - typedef typename - result_of::prior::type - it2; - typedef typename - reverse_iter_fold_lvalue_state< - rest2 - , it2 - , F - >::type - rest3; - typedef typename - result_of::prior::type - it3; - typedef typename - result_of_unrolled_reverse_iter_fold< - typename reverse_iter_fold_lvalue_state< - rest3 - , it3 - , F - >::type - , typename result_of::prior< - it3 - >::type - , F - , N-4 - >::type - type; - }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 3 - > - { - typedef typename - reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - rest1; - typedef typename - result_of::prior< - It0 const - >::type - it1; - typedef typename - reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - rest1 - , it1 - , F - >::type - , typename result_of::prior< - it1 const - >::type const - , F - >::type - type; - }; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 2 - > - : reverse_iter_fold_lvalue_state< - typename reverse_iter_fold_lvalue_state< - StateRef - , It0 const - , F - >::type - , typename result_of::prior< - It0 const - >::type const + template + struct result_of_it_reverse_iter_fold::type::type + >::type> + : result_of_it_reverse_iter_fold< + SeqSize-1 + , typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > , F > {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_it_reverse_iter_fold< + 0 + , It + , State , F - , 1 - > - : reverse_iter_fold_lvalue_state< - StateRef - , It0 const + >::type + it_reverse_iter_fold(mpl::int_<0>, It const&, typename State::type state, F&) + { + return state; + } + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename lazy_enable_if_c< + SeqSize != 0 + , result_of_it_reverse_iter_fold< + SeqSize + , It + , State , F > - {}; - template - struct result_of_unrolled_reverse_iter_fold< - StateRef - , It0 - , F - , 0 - > + >::type + it_reverse_iter_fold(mpl::int_, It const& it, typename State::type state, F& f) { - typedef StateRef type; - }; - template - struct result_of_first_unrolledreverse_iter_fold - { - typedef typename - result_of_unrolled_reverse_iter_fold< - typename fusion::detail::result_of_with_decltype< - F( - StateRef, - It0 const& - ) - >::type - , typename result_of::prior< - It0 const - >::type - , F - , SeqSize-1 - >::type - type; - }; - template - struct reverse_iter_fold_impl - { - typedef typename - result_of_first_unrolledreverse_iter_fold< - StateRef - , typename fusion::result_of::prior< typename result_of::end::type >::type - , F - , SeqSize - >::type - type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static type - call(StateRef state, Seq& seq, F f) - { - typedef - unrolled_reverse_iter_fold< - type - , SeqSize - > - unrolled_impl; - return unrolled_impl::call( - state, - fusion::prior( fusion::end(seq)), - f); - } - }; - template - struct reverse_iter_fold_impl<0,StateRef,Seq,F> - { - typedef StateRef type; - BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - static StateRef - call(StateRef state, Seq&, F) - { - return static_cast(state); - } - }; - template + return it_reverse_iter_fold< + typename result_of::prior::type + , boost::result_of< + F( + typename add_reference::type, + It const& + ) + > + , F + >( + mpl::int_() + , fusion::prior(it) + , f(state, it) + , f + ); + } + template::value + , bool = traits::is_segmented::value> struct result_of_reverse_iter_fold - : reverse_iter_fold_impl< + {}; + template + struct result_of_reverse_iter_fold + : result_of_it_reverse_iter_fold< result_of::size::value - , typename add_reference< - typename add_const::type - >::type - , Seq + , typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference , F > {}; + template + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + inline typename result_of_reverse_iter_fold::type + reverse_iter_fold(Seq& seq, State& state, F& f) + { + return it_reverse_iter_fold< + typename fusion::result_of::prior< typename result_of::end::type >::type + , add_reference + , F + >( + typename result_of::size::type() + , fusion::prior( fusion::end(seq) ) + , state + , f + ); + } } namespace result_of { template struct reverse_iter_fold - : detail::result_of_reverse_iter_fold< - Seq - , State - , F - , traits::is_segmented::type::value - > + : detail::result_of_reverse_iter_fold {}; } template @@ -357,10 +126,7 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -371,37 +137,28 @@ namespace boost { namespace fusion >::type reverse_iter_fold(Seq const& seq, State const& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq - , State const + , State , F >::type reverse_iter_fold(Seq& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline typename result_of::reverse_iter_fold< Seq const - , State const + , State , F >::type reverse_iter_fold(Seq const& seq, State& state, F f) { - return result_of::reverse_iter_fold::call( - state, - seq, - f); + return detail::reverse_iter_fold(seq, state, f); } }} diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp index ae1828a5..95cd8c1c 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque10.hpp @@ -201,7 +201,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp index 78224634..ad069451 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque20.hpp @@ -381,7 +381,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp index 8653217b..44a5b2b1 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque30.hpp @@ -561,7 +561,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp index 3bfd488a..e642288e 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque40.hpp @@ -741,7 +741,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template diff --git a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp index 04441da6..a387708b 100644 --- a/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp +++ b/include/boost/fusion/container/deque/detail/cpp03/preprocessed/deque50.hpp @@ -921,7 +921,9 @@ deque(T_0 && t0 , T_1 && t1 , T_2 && t2 , T_3 && t3 , T_4 && t4 , T_5 && t5 , T_ {} template BOOST_FUSION_GPU_ENABLED - deque(Sequence const& seq, typename disable_if >::type* = 0) + deque(Sequence const& seq + , typename disable_if >::type* = 0 + , typename enable_if >::type* = 0) : base(base::from_iterator(fusion::begin(seq))) {} template From 1ad2e59e072d726abe3dad78fe130af19c1445b8 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 20 Oct 2015 20:12:14 +0900 Subject: [PATCH 32/34] Make fusion::at,N> O(1). --- .../fusion/container/vector/detail/config.hpp | 3 +- .../container/vector/detail/value_at_impl.hpp | 24 ++++---------- .../boost/fusion/container/vector/vector.hpp | 32 ++++++++++++------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/include/boost/fusion/container/vector/detail/config.hpp b/include/boost/fusion/container/vector/detail/config.hpp index 475fe641..84f4605d 100644 --- a/include/boost/fusion/container/vector/detail/config.hpp +++ b/include/boost/fusion/container/vector/detail/config.hpp @@ -13,7 +13,8 @@ #if (defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \ || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) \ - || defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)) \ + || 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 diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index 220807c7..3d748afd 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -21,8 +21,9 @@ /////////////////////////////////////////////////////////////////////////////// // C++11 interface /////////////////////////////////////////////////////////////////////////////// -#include #include +#include +#include namespace boost { namespace fusion { @@ -42,23 +43,12 @@ namespace boost { namespace fusion template <> struct value_at_impl { - template - struct apply_impl; - - template - struct apply_impl, 0> - { - typedef H type; - }; - - template - struct apply_impl, N> - : apply_impl, N - 1> - {}; - template - struct apply : apply_impl - {}; + struct apply + { + typedef typename boost::remove_cv::type seq; + typedef decltype(seq::template value_at_impl(boost::declval())) type; + }; }; } }} diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 9c5032f9..4ca4b237 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -230,27 +230,37 @@ namespace boost { namespace fusion assign(std::forward(seq), detail::index_sequence()); } - typedef extension::value_at_impl value_at_impl; + template + static BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store* this_) -> decltype(this_->get()) + { + return this_->get(); + } + + template + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + auto at_detail(store const* this_) -> decltype(this_->get()) + { + return this_->get(); + } template BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - typename value_at_impl::template apply::type& - at_impl(J) + auto at_impl(J) -> decltype(at_detail(this)) { - typedef typename value_at_impl::template apply::type U; - typedef store S; - return static_cast(this)->get(); + return at_detail(this); } template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - typename value_at_impl::template apply::type const& - at_impl(J) const + auto at_impl(J) const -> decltype(at_detail(this)) { - typedef typename value_at_impl::template apply::type U; - typedef store S; - return static_cast(this)->get(); + return at_detail(this); } + + template + static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + U value_at_impl(store*); }; template From 73045b4d49cc1d7f24050f726ea5885d8ac3560f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 25 Sep 2015 08:19:31 +0900 Subject: [PATCH 33/34] Fix compile error on by-elem ctor. Single element vector of fusion sequence cannot construct from its element type. --- .../boost/fusion/container/vector/vector.hpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 4ca4b237..f22dc464 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,16 @@ namespace boost { namespace fusion template struct pure : remove_cv::type> {}; + template ::value> + struct is_convertible_to_first + : boost::is_convertible::type> + {}; + + template + struct is_convertible_to_first + : mpl::false_ + {}; + template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline each_elem @@ -77,12 +88,13 @@ namespace boost { namespace fusion BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED inline from_sequence< typename lazy_enable_if_c< - (traits::is_sequence::value && - !is_same::value) + (traits::is_sequence::type>::value && + !is_same::type>::value && + !is_convertible_to_first::value) , make_indices_from_seq >::type > - dispatch(Sequence const&) BOOST_NOEXCEPT + dispatch(Sequence&&) BOOST_NOEXCEPT { return from_sequence::type>(); } @@ -306,7 +318,7 @@ namespace boost { namespace fusion // In the (near) future release, should be fixed. /* BOOST_CONSTEXPR */ BOOST_FUSION_GPU_ENABLED vector(U&&... u) - : base(vector_detail::dispatch(u...), std::forward(u)...) + : base(vector_detail::dispatch(std::forward(u)...), std::forward(u)...) {} template From 4d5da0371b53c3632ec38a6282dd0756ff57c9d8 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 27 Oct 2015 07:59:55 +0900 Subject: [PATCH 34/34] Suppress undefined inline function warning. --- include/boost/fusion/container/vector/vector.hpp | 3 ++- include/boost/fusion/view/detail/strictest_traversal.hpp | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index f22dc464..df306714 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -272,7 +273,7 @@ namespace boost { namespace fusion template static BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - U value_at_impl(store*); + U value_at_impl(store*) { return boost::declval(); } }; template diff --git a/include/boost/fusion/view/detail/strictest_traversal.hpp b/include/boost/fusion/view/detail/strictest_traversal.hpp index 9ad1f7aa..d1aa7883 100644 --- a/include/boost/fusion/view/detail/strictest_traversal.hpp +++ b/include/boost/fusion/view/detail/strictest_traversal.hpp @@ -17,6 +17,9 @@ #include #include #include +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include +#endif namespace boost { namespace fusion { @@ -61,7 +64,10 @@ namespace boost { namespace fusion template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED typename result::type - operator()(StrictestSoFar&&, Next&&) const; + operator()(StrictestSoFar&&, Next&&) const + { + return boost::declval::type>(); + } #endif };