diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:24:46 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-09-13 11:25:39 +0900 |
commit | 4fadd968fa12130524c8380f33fcfe25d4de79e5 (patch) | |
tree | fd26a490cd15388d42fc6652b3c5c13012e7f93e /boost/hana/tuple.hpp | |
parent | b5c87084afaef42b2d058f68091be31988a6a874 (diff) | |
download | boost-upstream/1.65.0.tar.gz boost-upstream/1.65.0.tar.bz2 boost-upstream/1.65.0.zip |
Imported Upstream version 1.65.0upstream/1.65.0
Change-Id: Icf8400b375482cb11bcf77440a6934ba360d6ba4
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/hana/tuple.hpp')
-rw-r--r-- | boost/hana/tuple.hpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/boost/hana/tuple.hpp b/boost/hana/tuple.hpp index cab5eaa4d6..3354a84bee 100644 --- a/boost/hana/tuple.hpp +++ b/boost/hana/tuple.hpp @@ -3,6 +3,7 @@ Defines `boost::hana::tuple`. @copyright Louis Dionne 2013-2017 +@copyright Jason Rice 2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ @@ -27,7 +28,7 @@ Distributed under the Boost Software License, Version 1.0. #include <boost/hana/fwd/at.hpp> #include <boost/hana/fwd/core/make.hpp> #include <boost/hana/fwd/drop_front.hpp> -#include <boost/hana/fwd/find_if.hpp> +#include <boost/hana/fwd/index_if.hpp> #include <boost/hana/fwd/is_empty.hpp> #include <boost/hana/fwd/length.hpp> #include <boost/hana/fwd/optional.hpp> @@ -140,7 +141,7 @@ BOOST_HANA_NAMESPACE_BEGIN // The three following constructors are required to make sure that // the tuple(Yn&&...) constructor is _not_ preferred over the copy // constructor for unary tuples containing a type that is constructible - // from tuple<...>. See test/tuple/trap_construct.cpp + // from tuple<...>. See test/tuple/cnstr.trap.cpp template <typename ...dummy, typename = typename std::enable_if< detail::fast_and<BOOST_HANA_TT_IS_CONSTRUCTIBLE(Xn, Xn const&, dummy...)...>::value >::type> @@ -283,6 +284,14 @@ BOOST_HANA_NAMESPACE_BEGIN return hana::at_c<n>(static_cast<tuple<Xs...>&&>(xs).storage_); } + template <> + struct index_if_impl<tuple_tag> { + template <typename ...Xs, typename Pred> + static constexpr auto apply(tuple<Xs...> const&, Pred const&) + -> typename detail::index_if<Pred, Xs...>::type + { return {}; } + }; + ////////////////////////////////////////////////////////////////////////// // Sequence ////////////////////////////////////////////////////////////////////////// @@ -298,27 +307,6 @@ BOOST_HANA_NAMESPACE_BEGIN tuple<typename detail::decay<Xs>::type...> apply(Xs&& ...xs) { return {static_cast<Xs&&>(xs)...}; } }; - - template <> - struct find_if_impl<tuple_tag> { - template <std::size_t index, typename Xs> - static constexpr auto helper(Xs&&, hana::true_) { - return hana::nothing; - } - - template <std::size_t index, typename Xs> - static constexpr auto helper(Xs&& xs, hana::false_) { - return hana::just(hana::at_c<index>(static_cast<Xs&&>(xs))); - } - - template <typename Xs, typename Pred> - static constexpr auto apply(Xs&& xs, Pred&&) { - using Pack = typename detail::make_pack<Xs>::type; - constexpr std::size_t index = detail::index_if<Pred&&, Pack>::value; - constexpr std::size_t len = Pack::length; - return helper<index>(static_cast<Xs&&>(xs), hana::bool_c<index == len>); - } - }; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_TUPLE_HPP |