From 062058e6147a97c3cf7263d3989b1194361716cb Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 17 Aug 2014 22:07:12 +0900 Subject: [PATCH] add types::apply, types::quote --- sprout/functional/bind/bind.hpp | 4 +- sprout/tuple/traits.hpp | 4 +- sprout/type.hpp | 2 + sprout/type/algorithm.hpp | 1 + sprout/type/algorithm/contains.hpp | 6 +- sprout/type/algorithm/contains_if.hpp | 37 ++++++++++++ sprout/type/algorithm/find_index.hpp | 32 ++++++++--- sprout/type/algorithm/find_index_if.hpp | 33 ++++++++--- sprout/type/algorithm/fold.hpp | 3 +- sprout/type/algorithm/lower_bound_index.hpp | 5 +- sprout/type/algorithm/partial_sum.hpp | 13 ++--- sprout/type/algorithm/transform.hpp | 18 +++--- sprout/type/algorithm/upper_bound_index.hpp | 5 +- sprout/type/apply.hpp | 64 +++++++++++++++++++++ sprout/type/joint_types.hpp | 40 +++++-------- sprout/type/operation/append_front.hpp | 3 +- sprout/type/operation/assign.hpp | 3 +- sprout/type/operation/pop_back.hpp | 6 +- sprout/type/operation/pop_front.hpp | 6 +- sprout/type/operation/push_front.hpp | 3 +- sprout/type/operation/rebind.hpp | 3 +- sprout/type/operation/tuple_cat.hpp | 16 +++--- sprout/type/quote.hpp | 34 +++++++++++ sprout/type/rebind_types.hpp | 34 ++++------- sprout/type/seq/algorithm/find_if.hpp | 5 +- sprout/variant/variant.hpp | 5 +- 26 files changed, 265 insertions(+), 120 deletions(-) create mode 100644 sprout/type/algorithm/contains_if.hpp create mode 100644 sprout/type/apply.hpp create mode 100644 sprout/type/quote.hpp diff --git a/sprout/functional/bind/bind.hpp b/sprout/functional/bind/bind.hpp index 67320110..d167de14 100644 --- a/sprout/functional/bind/bind.hpp +++ b/sprout/functional/bind/bind.hpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -212,7 +212,7 @@ namespace sprout { struct is_variadic_bounds : public sprout::integral_constant< bool, - (sprout::types::find_index_if::value != sprout::tuples::tuple_size::value) + sprout::types::contains_if::value > {}; diff --git a/sprout/tuple/traits.hpp b/sprout/tuple/traits.hpp index 50e0b464..b01dd79a 100644 --- a/sprout/tuple/traits.hpp +++ b/sprout/tuple/traits.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,8 @@ namespace sprout { struct default_copied; template struct default_copied > - : public sprout::tuples::rebind_types::template apply< + : public sprout::types::apply< + sprout::tuples::rebind_types, typename std::decay< typename sprout::tuples::tuple_element::type >::type... diff --git a/sprout/type.hpp b/sprout/type.hpp index 5c0e0b02..f95eca7e 100644 --- a/sprout/type.hpp +++ b/sprout/type.hpp @@ -9,6 +9,8 @@ #define SPROUT_TYPE_HPP #include +#include +#include #include #include #include diff --git a/sprout/type/algorithm.hpp b/sprout/type/algorithm.hpp index 57d9b699..c18f8d3e 100644 --- a/sprout/type/algorithm.hpp +++ b/sprout/type/algorithm.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/sprout/type/algorithm/contains.hpp b/sprout/type/algorithm/contains.hpp index 768190a8..80516507 100644 --- a/sprout/type/algorithm/contains.hpp +++ b/sprout/type/algorithm/contains.hpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace sprout { namespace types { @@ -20,10 +19,7 @@ namespace sprout { // template struct contains - : public sprout::integral_constant< - bool, - sprout::types::find_index::value != sprout::types::tuple_size::value - > + : public sprout::types::find_index::found {}; #if SPROUT_USE_TEMPLATE_ALIASES diff --git a/sprout/type/algorithm/contains_if.hpp b/sprout/type/algorithm/contains_if.hpp new file mode 100644 index 00000000..85ebbd62 --- /dev/null +++ b/sprout/type/algorithm/contains_if.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_TYPE_ALGORITHM_CONTAINTS_IF_HPP +#define SPROUT_TYPE_ALGORITHM_CONTAINTS_IF_HPP + +#include +#include +#include + +namespace sprout { + namespace types { + // + // contains_if + // + template + struct contains_if + : public sprout::types::find_index_if::found + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using contains_if_t = typename sprout::types::contains_if::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool contains_if_v = sprout::types::contains_if::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_CONTAINTS_IF_HPP diff --git a/sprout/type/algorithm/find_index.hpp b/sprout/type/algorithm/find_index.hpp index 73844a54..537c87c4 100644 --- a/sprout/type/algorithm/find_index.hpp +++ b/sprout/type/algorithm/find_index.hpp @@ -17,24 +17,40 @@ namespace sprout { namespace types { namespace detail { - template + template< + typename Tuple, typename T, std::size_t I, + bool Valid = (I != sprout::types::tuple_size::value), + typename Enable = void + > struct find_index_impl; template struct find_index_impl< - Tuple, T, I, + Tuple, T, I, false, + void + > + : public sprout::integral_constant + { + public: + typedef sprout::false_type found; + }; + template + struct find_index_impl< + Tuple, T, I, true, typename std::enable_if< - I == sprout::types::tuple_size::value - || std::is_same::type, T>::value + std::is_same::type, T>::value >::type > : public sprout::integral_constant - {}; + { + public: + typedef sprout::true_type found; + typedef typename sprout::types::tuple_element::type element; + }; template struct find_index_impl< - Tuple, T, I, + Tuple, T, I, true, typename std::enable_if< - I != sprout::types::tuple_size::value - && !std::is_same::type, T>::value + !std::is_same::type, T>::value >::type > : public sprout::types::detail::find_index_impl diff --git a/sprout/type/algorithm/find_index_if.hpp b/sprout/type/algorithm/find_index_if.hpp index bea9cf64..46f7e2c5 100644 --- a/sprout/type/algorithm/find_index_if.hpp +++ b/sprout/type/algorithm/find_index_if.hpp @@ -11,30 +11,47 @@ #include #include #include +#include #include #include namespace sprout { namespace types { namespace detail { - template + template< + typename Tuple, typename Predicate, std::size_t I, + bool Valid = (I != sprout::types::tuple_size::value), + typename Enable = void + > struct find_index_if_impl; template struct find_index_if_impl< - Tuple, Predicate, I, + Tuple, Predicate, I, false, + void + > + : public sprout::integral_constant + { + public: + typedef sprout::false_type found; + }; + template + struct find_index_if_impl< + Tuple, Predicate, I, true, typename std::enable_if< - I == sprout::types::tuple_size::value - || Predicate::template apply::type>::type::value + sprout::types::apply::type>::type::value >::type > : public sprout::integral_constant - {}; + { + public: + typedef sprout::true_type found; + typedef typename sprout::types::tuple_element::type element; + }; template struct find_index_if_impl< - Tuple, Predicate, I, + Tuple, Predicate, I, true, typename std::enable_if< - I != sprout::types::tuple_size::value - && !Predicate::template apply::type>::type::value + !sprout::types::apply::type>::type::value >::type > : public sprout::types::detail::find_index_if_impl diff --git a/sprout/type/algorithm/fold.hpp b/sprout/type/algorithm/fold.hpp index 0d1e8f02..380df5a2 100644 --- a/sprout/type/algorithm/fold.hpp +++ b/sprout/type/algorithm/fold.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -29,7 +30,7 @@ namespace sprout { struct fold_impl : public sprout::types::detail::fold_impl< Tuple, - typename BinaryOp::template apply::type>::type, + typename sprout::types::apply::type>::type, BinaryOp, I + 1 > diff --git a/sprout/type/algorithm/lower_bound_index.hpp b/sprout/type/algorithm/lower_bound_index.hpp index 2ffbc980..588f0f48 100644 --- a/sprout/type/algorithm/lower_bound_index.hpp +++ b/sprout/type/algorithm/lower_bound_index.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,7 @@ namespace sprout { > : public sprout::integral_constant< std::size_t, - Compare::template apply::type, T>::type::value ? Last : First + sprout::types::apply::type, T>::type::value ? Last : First > {}; template< @@ -50,7 +51,7 @@ namespace sprout { > struct lower_bound_index_impl : public std::conditional< - Compare::template apply::type, T>::type::value, + sprout::types::apply::type, T>::type::value, sprout::types::detail::lower_bound_index_impl, sprout::types::detail::lower_bound_index_impl >::type diff --git a/sprout/type/algorithm/partial_sum.hpp b/sprout/type/algorithm/partial_sum.hpp index 16e39c87..b8928b24 100644 --- a/sprout/type/algorithm/partial_sum.hpp +++ b/sprout/type/algorithm/partial_sum.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -23,17 +24,13 @@ namespace sprout { struct partial_sum_impl : public sprout::types::detail::partial_sum_impl< Tuple, BinaryOp, I + 1, N - 1, - typename BinaryOp::template apply::type>::type, + typename sprout::types::apply::type>::type, Types..., T > {}; template struct partial_sum_impl - : public sprout::types::rebind_types< - Tuple - >::template apply< - Types..., T - > + : public sprout::types::apply, Types..., T> {}; template @@ -42,9 +39,7 @@ namespace sprout { {}; template struct partial_sum - : public sprout::types::rebind_types< - Tuple - >::template apply<> + : public sprout::types::apply > {}; } // namespace detail // diff --git a/sprout/type/algorithm/transform.hpp b/sprout/type/algorithm/transform.hpp index a91a8434..37d8c611 100644 --- a/sprout/type/algorithm/transform.hpp +++ b/sprout/type/algorithm/transform.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -21,12 +22,9 @@ namespace sprout { struct transform_impl; template struct transform_impl > - : public sprout::types::rebind_types< - Tuple - >::template apply< - typename UnaryOp::template apply< - typename sprout::types::tuple_element::type - >::type... + : public sprout::types::apply< + sprout::types::rebind_types, + typename sprout::types::apply::type>::type... > {}; @@ -34,10 +32,10 @@ namespace sprout { struct transform2_impl; template struct transform2_impl > - : public sprout::types::rebind_types< - Tuple1 - >::template apply< - typename BinaryOp::template apply< + : public sprout::types::apply< + sprout::types::rebind_types, + typename sprout::types::apply< + BinaryOp, typename sprout::types::tuple_element::type, typename sprout::types::tuple_element::type >::type... diff --git a/sprout/type/algorithm/upper_bound_index.hpp b/sprout/type/algorithm/upper_bound_index.hpp index 90d39e95..21374bca 100644 --- a/sprout/type/algorithm/upper_bound_index.hpp +++ b/sprout/type/algorithm/upper_bound_index.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,7 @@ namespace sprout { > : public sprout::integral_constant< std::size_t, - !Compare::template apply::type>::type::value ? Last : First + !sprout::types::apply::type>::type::value ? Last : First > {}; template< @@ -50,7 +51,7 @@ namespace sprout { > struct upper_bound_index_impl : public std::conditional< - !Compare::template apply::type>::type::value, + !sprout::types::apply::type>::type::value, sprout::types::detail::upper_bound_index_impl, sprout::types::detail::upper_bound_index_impl >::type diff --git a/sprout/type/apply.hpp b/sprout/type/apply.hpp new file mode 100644 index 00000000..70ade3f8 --- /dev/null +++ b/sprout/type/apply.hpp @@ -0,0 +1,64 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_TYPE_APPLY_HPP +#define SPROUT_TYPE_APPLY_HPP + +#include +#include + +namespace sprout { + namespace types { + // + // apply + // +#if SPROUT_USE_TEMPLATE_ALIASES + template + using apply = typename F::template apply; +#else // #if SPROUT_USE_TEMPLATE_ALIASES + template + struct apply + : public F::template apply + {}; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using apply_t = typename sprout::types::apply::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR decltype(sprout::types::apply::value) apply_v = sprout::types::apply::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + + // + // apply_q + // +#if SPROUT_USE_TEMPLATE_ALIASES + template class F, typename... Types> + using apply_q = sprout::types::apply, Types...>; +#else // #if SPROUT_USE_TEMPLATE_ALIASES + template class F, typename... Types> + struct apply_q + : public sprout::types::apply, Types...> + {}; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_TEMPLATE_ALIASES + template class F, typename... Types> + using apply_q_t = typename sprout::types::apply_q::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template class F, typename... Types> + SPROUT_STATIC_CONSTEXPR decltype(sprout::types::apply_q::value) apply_q_v = sprout::types::apply_q::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_APPLY_HPP diff --git a/sprout/type/joint_types.hpp b/sprout/type/joint_types.hpp index de2bfb50..31fbe256 100644 --- a/sprout/type/joint_types.hpp +++ b/sprout/type/joint_types.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -26,9 +27,8 @@ namespace sprout { struct apply_impl; template struct apply_impl, sprout::index_tuple > - : public sprout::types::rebind_types< - Tuple - >::template apply< + : public sprout::types::apply< + sprout::types::rebind_types, typename sprout::types::tuple_element::type..., typename sprout::types::tuple_element::type... > @@ -243,42 +243,28 @@ namespace sprout { struct joint_types { public: template - struct apply { - public: - typedef typename sprout::types::joint_types< - Tuple - >::template apply< - Tup - >::type const type; - }; + struct apply + : public sprout::identity, Tup>::type const> + {}; }; template struct joint_types { public: template - struct apply { - public: - typedef typename sprout::types::joint_types< - Tuple - >::template apply< - Tup - >::type volatile type; - }; + struct apply + : public sprout::identity, Tup>::type volatile> + {}; }; template struct joint_types { public: template - struct apply { - public: - typedef typename sprout::types::joint_types< - Tuple - >::template apply< - Tup - >::type const volatile type; - }; + struct apply + : public sprout::identity, Tup>::type const volatile> + {}; + }; } // namespace types diff --git a/sprout/type/operation/append_front.hpp b/sprout/type/operation/append_front.hpp index 13402105..512533ca 100644 --- a/sprout/type/operation/append_front.hpp +++ b/sprout/type/operation/append_front.hpp @@ -9,6 +9,7 @@ #define SPROUT_TYPE_OPERATION_APPEND_FRONT_HPP #include +#include #include #include @@ -20,7 +21,7 @@ namespace sprout { template struct append_front : public sprout::types::tuple_cat< - typename sprout::types::rebind_types::template apply<>::type, + typename sprout::types::apply >::type, InputTuples..., Tuple > {}; diff --git a/sprout/type/operation/assign.hpp b/sprout/type/operation/assign.hpp index 0b1cfa81..1a832262 100644 --- a/sprout/type/operation/assign.hpp +++ b/sprout/type/operation/assign.hpp @@ -9,6 +9,7 @@ #define SPROUT_TYPE_OPERATION_ASSIGN_HPP #include +#include #include #include @@ -20,7 +21,7 @@ namespace sprout { template struct assign : public sprout::types::tuple_cat< - typename sprout::types::rebind_types::template apply<>::type, + typename sprout::types::apply >::type, InputTuple > {}; diff --git a/sprout/type/operation/pop_back.hpp b/sprout/type/operation/pop_back.hpp index b930016b..fe3ea419 100644 --- a/sprout/type/operation/pop_back.hpp +++ b/sprout/type/operation/pop_back.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -25,9 +26,8 @@ namespace sprout { struct apply_impl; template struct apply_impl > - : public sprout::types::rebind_types< - Tuple - >::template apply< + : public sprout::types::apply< + sprout::types::rebind_types, typename sprout::types::tuple_element::type... > {}; diff --git a/sprout/type/operation/pop_front.hpp b/sprout/type/operation/pop_front.hpp index e92de1fb..ccfd418f 100644 --- a/sprout/type/operation/pop_front.hpp +++ b/sprout/type/operation/pop_front.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -25,9 +26,8 @@ namespace sprout { struct apply_impl; template struct apply_impl > - : public sprout::types::rebind_types< - Tuple - >::template apply< + : public sprout::types::apply< + sprout::types::rebind_types, typename sprout::types::tuple_element::type... > {}; diff --git a/sprout/type/operation/push_front.hpp b/sprout/type/operation/push_front.hpp index 2a8447ea..e100247c 100644 --- a/sprout/type/operation/push_front.hpp +++ b/sprout/type/operation/push_front.hpp @@ -9,6 +9,7 @@ #define SPROUT_TYPE_OPERATION_PUSH_FRONT_HPP #include +#include #include #include #include @@ -21,7 +22,7 @@ namespace sprout { template struct push_front : public sprout::types::tuple_cat< - typename sprout::types::rebind_types::template apply<>::type, + typename sprout::types::apply >::type, sprout::types::type_tuple, Tuple > {}; diff --git a/sprout/type/operation/rebind.hpp b/sprout/type/operation/rebind.hpp index 4cbd89ce..80d4318b 100644 --- a/sprout/type/operation/rebind.hpp +++ b/sprout/type/operation/rebind.hpp @@ -9,6 +9,7 @@ #define SPROUT_TYPE_OPERATION_REBIND_HPP #include +#include #include namespace sprout { @@ -18,7 +19,7 @@ namespace sprout { // template struct rebind - : public sprout::types::rebind_types::template apply + : public sprout::types::apply, Ts...> {}; #if SPROUT_USE_TEMPLATE_ALIASES diff --git a/sprout/type/operation/tuple_cat.hpp b/sprout/type/operation/tuple_cat.hpp index 064c4d82..962698d1 100644 --- a/sprout/type/operation/tuple_cat.hpp +++ b/sprout/type/operation/tuple_cat.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -28,13 +29,14 @@ namespace sprout { struct tuple_cat_impl; template struct tuple_cat_impl, sprout::index_tuple > - : public sprout::types::joint_types< - typename sprout::types::detail::tuple_cat_impl< - sprout::types::type_tuple::type...>, - typename sprout::index_range<0, sizeof...(LIndexes) / 2>::type, - typename sprout::index_range::type - >::type - >::template apply< + : public sprout::types::apply< + sprout::types::joint_types< + typename sprout::types::detail::tuple_cat_impl< + sprout::types::type_tuple::type...>, + typename sprout::index_range<0, sizeof...(LIndexes) / 2>::type, + typename sprout::index_range::type + >::type + >, typename sprout::types::detail::tuple_cat_impl< sprout::types::type_tuple::type...>, typename sprout::index_range<0, sizeof...(RIndexes) / 2>::type, diff --git a/sprout/type/quote.hpp b/sprout/type/quote.hpp new file mode 100644 index 00000000..5493dab4 --- /dev/null +++ b/sprout/type/quote.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + Copyright (c) 2011-2014 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + 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 SPROUT_TYPE_QUOTE_HPP +#define SPROUT_TYPE_QUOTE_HPP + +#include + +namespace sprout { + namespace types { + // + // quote + // + template class F> + struct quote { + public: +#if SPROUT_USE_TEMPLATE_ALIASES + template + using apply = F; +#else // #if SPROUT_USE_TEMPLATE_ALIASES + template + struct apply + : public F + {}; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + }; + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_QUOTE_HPP diff --git a/sprout/type/rebind_types.hpp b/sprout/type/rebind_types.hpp index f0888508..0d6ad463 100644 --- a/sprout/type/rebind_types.hpp +++ b/sprout/type/rebind_types.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace sprout { namespace types { @@ -75,42 +76,27 @@ namespace sprout { struct rebind_types { public: template - struct apply { - public: - typedef typename sprout::types::rebind_types< - Tuple - >::template apply< - Types... - >::type const type; - }; + struct apply + : public sprout::identity, Types...>::type const> + {}; }; template struct rebind_types { public: template - struct apply { - public: - typedef typename sprout::types::rebind_types< - Tuple - >::template apply< - Types... - >::type volatile type; - }; + struct apply + : public sprout::identity, Types...>::type volatile> + {}; }; template struct rebind_types { public: template - struct apply { - public: - typedef typename sprout::types::rebind_types< - Tuple - >::template apply< - Types... - >::type const volatile type; - }; + struct apply + : public sprout::identity, Types...>::type const volatile> + {}; }; } // namespace types diff --git a/sprout/type/seq/algorithm/find_if.hpp b/sprout/type/seq/algorithm/find_if.hpp index 7cf255de..d2fa1a10 100644 --- a/sprout/type/seq/algorithm/find_if.hpp +++ b/sprout/type/seq/algorithm/find_if.hpp @@ -10,6 +10,7 @@ #include #include +#include #include namespace sprout { @@ -25,7 +26,7 @@ namespace sprout { struct find_if_impl_1< First, Last, Predicate, typename std::enable_if< - Predicate::template apply::type>::type::value + sprout::types::apply::type>::type::value >::type > { public: @@ -35,7 +36,7 @@ namespace sprout { struct find_if_impl_1< First, Last, Predicate, typename std::enable_if< - !Predicate::template apply::type>::type::value + !sprout::types::apply::type>::type::value >::type > : public sprout::types::seq::detail::find_if_impl< diff --git a/sprout/variant/variant.hpp b/sprout/variant/variant.hpp index 1795a8f7..c3b7b794 100644 --- a/sprout/variant/variant.hpp +++ b/sprout/variant/variant.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -312,14 +313,14 @@ namespace sprout { } template SPROUT_CONSTEXPR typename std::enable_if< - sprout::types::find_index::value != sizeof...(Types), + sprout::types::contains::value, U const& >::type get() const { return get_at::value>(); } template SPROUT_CXX14_CONSTEXPR typename std::enable_if< - sprout::types::find_index::value != sizeof...(Types), + sprout::types::contains::value, U& >::type get() { return get_at::value>();