/*============================================================================= Copyright (c) 2011-2017 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_TUPLE_APPLY_HPP #define SPROUT_TUPLE_APPLY_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace tuples { // // apply_result // namespace detail { template struct apply_result_impl; template struct apply_result_impl > { public: typedef decltype( std::declval()( sprout::tuples::get(std::declval())... ) ) type; }; } // namespace detail template struct apply_result : public sprout::tuples::detail::apply_result_impl< F, Tuple, typename sprout::tuple_indexes::type>::type > {}; // // apply // namespace detail { template inline SPROUT_CONSTEXPR Result apply_impl(F&& f, Tuple&& t, sprout::index_tuple) { return SPROUT_FORWARD(F, f)(sprout::tuples::get(SPROUT_FORWARD(Tuple, t))...); } } // namespace detail template inline SPROUT_CONSTEXPR typename sprout::tuples::apply_result::type apply(F&& f, Tuple&& t) { return sprout::tuples::detail::apply_impl::type>( SPROUT_FORWARD(F, f), SPROUT_FORWARD(Tuple, t), sprout::tuple_indexes::type>::make() ); } } // namespace tuples using sprout::tuples::apply_result; using sprout::tuples::apply; } // namespace sprout #endif // #ifndef SPROUT_TUPLE_APPLY_HPP