2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2015-01-10 10:13:57 +00:00
|
|
|
Copyright (c) 2011-2015 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2011-11-03 17:11:19 +00:00
|
|
|
#ifndef SPROUT_TUPLE_TRAITS_HPP
|
|
|
|
#define SPROUT_TUPLE_TRAITS_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/index_tuple/metafunction.hpp>
|
2011-11-03 17:11:19 +00:00
|
|
|
#include <sprout/tuple/tuple.hpp>
|
2013-03-31 06:14:10 +00:00
|
|
|
#include <sprout/tuple/indexes.hpp>
|
2014-08-17 13:07:12 +00:00
|
|
|
#include <sprout/type/apply.hpp>
|
2011-11-06 01:56:57 +00:00
|
|
|
#include <sprout/type/rebind_types.hpp>
|
2012-07-15 12:20:56 +00:00
|
|
|
#include <sprout/utility/forward.hpp>
|
2015-01-10 10:13:57 +00:00
|
|
|
#include <sprout/type_traits/remove_cvref.hpp>
|
2011-11-03 17:11:19 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace tuples {
|
|
|
|
//
|
|
|
|
// rebind_types
|
|
|
|
//
|
|
|
|
template<typename Tuple>
|
2011-11-06 01:56:57 +00:00
|
|
|
struct rebind_types
|
|
|
|
: public sprout::types::rebind_types<Tuple>
|
|
|
|
{};
|
2011-11-03 17:11:19 +00:00
|
|
|
|
|
|
|
//
|
2012-03-31 07:24:13 +00:00
|
|
|
// tuple_construct_traits
|
2011-11-03 17:11:19 +00:00
|
|
|
//
|
|
|
|
template<typename Tuple>
|
2012-03-31 07:24:13 +00:00
|
|
|
struct tuple_construct_traits;
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template<typename Tuple, typename IndexTuple>
|
|
|
|
struct default_copied;
|
|
|
|
template<typename Tuple, sprout::index_t... Indexes>
|
2013-03-26 17:02:16 +00:00
|
|
|
struct default_copied<Tuple, sprout::index_tuple<Indexes...> >
|
2014-08-17 13:07:12 +00:00
|
|
|
: public sprout::types::apply<
|
|
|
|
sprout::tuples::rebind_types<Tuple>,
|
2015-01-10 10:13:57 +00:00
|
|
|
typename sprout::remove_cvref<
|
2012-03-31 07:24:13 +00:00
|
|
|
typename sprout::tuples::tuple_element<Indexes, Tuple>::type
|
|
|
|
>::type...
|
2013-03-26 17:02:16 +00:00
|
|
|
>
|
|
|
|
{};
|
2012-03-31 07:24:13 +00:00
|
|
|
|
|
|
|
template<typename Tuple, typename... Args>
|
|
|
|
SPROUT_CONSTEXPR typename sprout::tuples::tuple_construct_traits<Tuple>::copied_type
|
|
|
|
default_make_tuple(Args&&... args) {
|
|
|
|
typedef typename sprout::tuples::tuple_construct_traits<Tuple>::copied_type copied_type;
|
2015-01-11 14:29:58 +00:00
|
|
|
return copied_type{SPROUT_FORWARD(Args, args)...};
|
2011-11-03 17:11:19 +00:00
|
|
|
}
|
2012-03-31 07:24:13 +00:00
|
|
|
} // namespace detail
|
2011-11-03 17:11:19 +00:00
|
|
|
|
|
|
|
template<typename Tuple>
|
2012-03-31 07:24:13 +00:00
|
|
|
struct tuple_construct_traits {
|
2011-11-03 17:11:19 +00:00
|
|
|
public:
|
2012-03-31 07:24:13 +00:00
|
|
|
typedef typename sprout::tuples::detail::default_copied<
|
|
|
|
Tuple,
|
2013-03-31 06:14:10 +00:00
|
|
|
typename sprout::tuple_indexes<Tuple>::type
|
2012-03-31 07:24:13 +00:00
|
|
|
>::type copied_type;
|
|
|
|
public:
|
|
|
|
template<typename Tup>
|
|
|
|
static SPROUT_CONSTEXPR copied_type deep_copy(Tup&& tup) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return SPROUT_FORWARD(Tup, tup);
|
2012-03-31 07:24:13 +00:00
|
|
|
}
|
2011-11-03 17:11:19 +00:00
|
|
|
template<typename... Args>
|
2012-03-31 07:24:13 +00:00
|
|
|
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::tuples::detail::default_make_tuple<Tuple>(SPROUT_FORWARD(Args, args)...);
|
2011-11-03 17:11:19 +00:00
|
|
|
}
|
2012-03-31 07:24:13 +00:00
|
|
|
template<typename Tup, typename... Args>
|
|
|
|
static SPROUT_CONSTEXPR copied_type remake(
|
2013-07-22 13:00:09 +00:00
|
|
|
Tup&&,
|
2011-11-03 17:11:19 +00:00
|
|
|
Args&&... args
|
2012-03-31 07:24:13 +00:00
|
|
|
)
|
2011-11-03 17:11:19 +00:00
|
|
|
{
|
2014-02-22 07:32:51 +00:00
|
|
|
return make(SPROUT_FORWARD(Args, args)...);
|
2011-11-03 17:11:19 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
template<typename Tuple>
|
2012-03-31 07:24:13 +00:00
|
|
|
struct tuple_construct_traits<Tuple const>
|
|
|
|
: public sprout::tuples::tuple_construct_traits<Tuple>
|
2011-11-03 17:11:19 +00:00
|
|
|
{};
|
|
|
|
} // namespace tuples
|
|
|
|
|
2012-03-31 07:24:13 +00:00
|
|
|
using sprout::tuples::tuple_construct_traits;
|
2011-11-03 17:11:19 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_TUPLE_TRAITS_HPP
|