From d9370039621553844ded593b7f35514028b8d6c6 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sun, 9 Nov 2014 15:27:54 +0900 Subject: [PATCH 01/19] 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/19] 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/19] 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/19] 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/19] 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/19] 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/19] 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/19] 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/19] 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/19] 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 6689de502b3c94888e74921123f338648ea3ba2f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 30 Jul 2015 11:56:09 +0900 Subject: [PATCH 11/19] 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 12/19] 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 13/19] 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 ef39bc86517e3ca0df346538c4010178cc6346f7 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Mon, 21 Sep 2015 16:19:41 +0900 Subject: [PATCH 14/19] 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 c750552a0255676a0bba40261179e3c3ed3a90cd Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 6 Oct 2015 11:28:16 +0900 Subject: [PATCH 15/19] 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 16/19] 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 17/19] 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 18/19] 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 1ad2e59e072d726abe3dad78fe130af19c1445b8 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Tue, 20 Oct 2015 20:12:14 +0900 Subject: [PATCH 19/19] 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