mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix optional
This commit is contained in:
parent
a1c119a9bb
commit
6a78f64feb
9 changed files with 233 additions and 67 deletions
|
@ -1,11 +1,11 @@
|
|||
#ifndef SPROUT_UTILITY_PAIR_PAIR_HPP
|
||||
#define SPROUT_UTILITY_PAIR_PAIR_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/utility/pair/pair_decl.hpp>
|
||||
#include <sprout/tuple/tuple/tuple.hpp>
|
||||
|
@ -41,29 +41,41 @@ namespace sprout {
|
|||
, second(y)
|
||||
{}
|
||||
template <typename T1, typename T2>
|
||||
template<typename U, typename V>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(U&& x, V&& y)
|
||||
: first(sprout::forward<U>(x))
|
||||
, second(sprout::forward<V>(y))
|
||||
{}
|
||||
template <typename T1, typename T2>
|
||||
template<typename U, typename V>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::pair<U, V> const& other)
|
||||
: first(other.first)
|
||||
, second(other.second)
|
||||
{}
|
||||
template <typename T1, typename T2>
|
||||
template<typename U, typename V>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::pair<U, V>&& other)
|
||||
: first(sprout::move(other.first))
|
||||
, second(sprout::move(other.second))
|
||||
: first(sprout::forward<U>(other.first))
|
||||
, second(sprout::forward<V>(other.second))
|
||||
{}
|
||||
#if SPROUT_USE_DELEGATING_CONSTRUCTORS
|
||||
template <typename T1, typename T2>
|
||||
template <typename... Args1, typename... Args2>
|
||||
template<
|
||||
typename... Args1, typename... Args2,
|
||||
typename
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(
|
||||
sprout::tuples::tuple<Args1...> first_args,
|
||||
sprout::tuples::tuple<Args2...> second_args
|
||||
std::piecewise_construct_t,
|
||||
sprout::tuples::tuple<Args1...> first_args, sprout::tuples::tuple<Args2...> second_args
|
||||
)
|
||||
: pair(
|
||||
first_args,
|
||||
|
@ -74,29 +86,75 @@ namespace sprout {
|
|||
{}
|
||||
#endif // #if SPROUT_USE_DELEGATING_CONSTRUCTORS
|
||||
template <typename T1, typename T2>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair const& other) = default;
|
||||
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))
|
||||
{}
|
||||
template <typename T1, typename T2>
|
||||
template<typename U, typename V>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V> const& other) {
|
||||
first = other.first;
|
||||
second = other.second;
|
||||
return *this;
|
||||
}
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::tuples::tuple<U, V>&& other)
|
||||
: first(sprout::forward<U>(sprout::tuples::get<0>(other)))
|
||||
, second(sprout::forward<V>(sprout::tuples::get<1>(other)))
|
||||
{}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair&& other)
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair const& rhs) = default;
|
||||
template <typename T1, typename T2>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair&& rhs)
|
||||
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<T1>::value && std::is_nothrow_move_assignable<T2>::value)
|
||||
{
|
||||
first = sprout::move(other.first);
|
||||
second = sprout::move(other.second);
|
||||
first = sprout::forward<T1>(rhs.first);
|
||||
second = sprout::forward<T2>(rhs.second);
|
||||
return *this;
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
template<typename U, typename V>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V>&& other) {
|
||||
first = sprout::move(other.first);
|
||||
second = sprout::move(other.second);
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V> const& rhs) {
|
||||
first = rhs.first;
|
||||
second = rhs.second;
|
||||
return *this;
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V>&& rhs) {
|
||||
first = sprout::forward<U>(rhs.first);
|
||||
second = sprout::forward<V>(rhs.second);
|
||||
return *this;
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::tuples::tuple<U, V> const& rhs) {
|
||||
first = sprout::tuples::get<0>(rhs);
|
||||
second = sprout::tuples::get<0>(rhs);
|
||||
return *this;
|
||||
}
|
||||
template <typename T1, typename T2>
|
||||
template<
|
||||
typename U, typename V,
|
||||
typename
|
||||
>
|
||||
inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::tuples::tuple<U, V>&& rhs) {
|
||||
first = sprout::forward<U>(sprout::tuples::get<0>(rhs));
|
||||
second = sprout::forward<V>(sprout::tuples::get<1>(rhs));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline void sprout::pair<T1, T2>::swap(pair& other)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue