/*============================================================================= Copyright (c) 2011-2019 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_TRAITS_HPP #define SPROUT_TUPLE_TRAITS_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace tuples { // // rebind_types // template struct rebind_types : public sprout::types::rebind_types {}; // // tuple_construct_traits // template struct tuple_construct_traits; namespace detail { template struct default_copied; template struct default_copied > : public sprout::types::apply< sprout::tuples::rebind_types, typename sprout::remove_cvref< typename sprout::tuples::tuple_element::type >::type... > {}; template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::detail::is_array_like::value, typename sprout::tuples::tuple_construct_traits::copied_type >::type default_make_tuple(Args&&... args) { typedef typename sprout::tuples::tuple_construct_traits::copied_type copied_type; return copied_type{{SPROUT_FORWARD(Args, args)...}}; } template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::detail::is_array_like::value, typename sprout::tuples::tuple_construct_traits::copied_type >::type default_make_tuple(Args&&... args) { typedef typename sprout::tuples::tuple_construct_traits::copied_type copied_type; return copied_type(SPROUT_FORWARD(Args, args)...); } } // namespace detail template struct tuple_construct_traits { public: typedef typename sprout::tuples::detail::default_copied< Tuple, typename sprout::tuple_indexes::type >::type copied_type; public: template static SPROUT_CONSTEXPR copied_type deep_copy(Tup&& tup) { return SPROUT_FORWARD(Tup, tup); } template static SPROUT_CONSTEXPR copied_type make(Args&&... args) { return sprout::tuples::detail::default_make_tuple(SPROUT_FORWARD(Args, args)...); } template static SPROUT_CONSTEXPR copied_type remake( Tup&&, Args&&... args ) { return make(SPROUT_FORWARD(Args, args)...); } }; template struct tuple_construct_traits : public sprout::tuples::tuple_construct_traits {}; } // namespace tuples using sprout::tuples::tuple_construct_traits; } // namespace sprout #endif // #ifndef SPROUT_TUPLE_TRAITS_HPP