2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2014-01-08 07:48:12 +00:00
|
|
|
Copyright (c) 2011-2014 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)
|
|
|
|
=============================================================================*/
|
2012-10-08 05:14:59 +00:00
|
|
|
#ifndef SPROUT_UTILITY_PAIR_PAIR_HPP
|
|
|
|
#define SPROUT_UTILITY_PAIR_PAIR_HPP
|
|
|
|
|
2013-03-31 01:09:02 +00:00
|
|
|
#include <utility>
|
2012-10-08 05:14:59 +00:00
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/index_tuple/metafunction.hpp>
|
2012-10-08 05:14:59 +00:00
|
|
|
#include <sprout/utility/forward.hpp>
|
2013-03-27 08:55:14 +00:00
|
|
|
#include <sprout/utility/pair/pair_decl.hpp>
|
2013-02-04 14:10:24 +00:00
|
|
|
#include <sprout/tuple/tuple/tuple.hpp>
|
|
|
|
#include <sprout/tuple/tuple/get.hpp>
|
2012-10-08 05:14:59 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// pair
|
|
|
|
//
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
|
|
|
template<typename... Args1, typename... Args2, sprout::index_t... Indexes1, sprout::index_t... Indexes2>
|
2013-03-27 08:55:14 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(
|
2013-04-05 09:11:56 +00:00
|
|
|
sprout::tuples::tuple<Args1...> first_args, sprout::tuples::tuple<Args2...> second_args,
|
|
|
|
sprout::index_tuple<Indexes1...>, sprout::index_tuple<Indexes2...>
|
2013-03-27 08:55:14 +00:00
|
|
|
)
|
|
|
|
: first(sprout::tuples::get<Indexes1>(first_args)...)
|
|
|
|
, second(sprout::tuples::get<Indexes2>(second_args)...)
|
|
|
|
{}
|
2012-10-08 05:14:59 +00:00
|
|
|
#if SPROUT_USE_DELEGATING_CONSTRUCTORS
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
2013-03-31 01:09:02 +00:00
|
|
|
template<
|
|
|
|
typename... Args1, typename... Args2,
|
|
|
|
typename
|
|
|
|
>
|
2013-03-27 08:55:14 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(
|
2013-03-31 01:09:02 +00:00
|
|
|
std::piecewise_construct_t,
|
|
|
|
sprout::tuples::tuple<Args1...> first_args, sprout::tuples::tuple<Args2...> second_args
|
2013-03-27 08:55:14 +00:00
|
|
|
)
|
|
|
|
: pair(
|
|
|
|
first_args,
|
|
|
|
second_args,
|
2013-05-10 10:52:39 +00:00
|
|
|
sprout::index_pack<Args1...>::make(),
|
|
|
|
sprout::index_pack<Args2...>::make()
|
2012-10-08 05:14:59 +00:00
|
|
|
)
|
2013-03-27 08:55:14 +00:00
|
|
|
{}
|
2012-10-08 05:14:59 +00:00
|
|
|
#endif // #if SPROUT_USE_DELEGATING_CONSTRUCTORS
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
2013-03-31 01:09:02 +00:00
|
|
|
template<
|
|
|
|
typename U, typename V,
|
|
|
|
typename
|
|
|
|
>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::tuples::tuple<U, V> const& other)
|
|
|
|
: first(sprout::tuples::get<0>(other))
|
|
|
|
, second(sprout::tuples::get<1>(other))
|
|
|
|
{}
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
2013-03-31 01:09:02 +00:00
|
|
|
template<
|
|
|
|
typename U, typename V,
|
|
|
|
typename
|
|
|
|
>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::tuples::tuple<U, V>&& other)
|
2014-02-22 07:32:51 +00:00
|
|
|
: first(SPROUT_FORWARD(U, sprout::tuples::get<0>(other)))
|
|
|
|
, second(SPROUT_FORWARD(V, sprout::tuples::get<1>(other)))
|
2013-03-31 01:09:02 +00:00
|
|
|
{}
|
|
|
|
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
2013-03-31 01:09:02 +00:00
|
|
|
template<
|
|
|
|
typename U, typename V,
|
|
|
|
typename
|
|
|
|
>
|
2013-10-15 05:01:34 +00:00
|
|
|
inline SPROUT_CXX14_CONSTEXPR sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::tuples::tuple<U, V> const& rhs) {
|
2013-03-31 01:09:02 +00:00
|
|
|
first = sprout::tuples::get<0>(rhs);
|
|
|
|
second = sprout::tuples::get<0>(rhs);
|
|
|
|
return *this;
|
|
|
|
}
|
2013-11-20 13:04:11 +00:00
|
|
|
template<typename T1, typename T2>
|
2013-03-31 01:09:02 +00:00
|
|
|
template<
|
|
|
|
typename U, typename V,
|
|
|
|
typename
|
|
|
|
>
|
2013-10-15 05:01:34 +00:00
|
|
|
inline SPROUT_CXX14_CONSTEXPR sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::tuples::tuple<U, V>&& rhs) {
|
2014-02-22 07:32:51 +00:00
|
|
|
first = SPROUT_FORWARD(U, sprout::tuples::get<0>(rhs));
|
|
|
|
second = SPROUT_FORWARD(V, sprout::tuples::get<1>(rhs));
|
2013-03-31 01:09:02 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2012-10-08 05:14:59 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_HPP
|