add tuple construction (from pair)

This commit is contained in:
bolero-MURAKAMI 2013-03-27 17:55:14 +09:00
parent 2e8b85e90c
commit f905d1f02a
9 changed files with 685 additions and 447 deletions

View file

@ -3,6 +3,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/tuple/tuple/tuple_fwd.hpp> #include <sprout/tuple/tuple/tuple_fwd.hpp>
#include <sprout/tuple/tuple/tuple_decl.hpp>
#include <sprout/tuple/tuple/tuple.hpp> #include <sprout/tuple/tuple/tuple.hpp>
#include <sprout/tuple/tuple/comparison.hpp> #include <sprout/tuple/tuple/comparison.hpp>
#include <sprout/tuple/tuple/get.hpp> #include <sprout/tuple/tuple/get.hpp>

View file

@ -1,328 +1,149 @@
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_HPP #ifndef SPROUT_TUPLE_TUPLE_TUPLE_HPP
#define SPROUT_TUPLE_TUPLE_TUPLE_HPP #define SPROUT_TUPLE_TUPLE_TUPLE_HPP
#include <cstddef>
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>
#include <tuple>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
#include <sprout/utility/move.hpp> #include <sprout/utility/move.hpp>
#include <sprout/utility/swap.hpp> #include <sprout/utility/swap.hpp>
#include <sprout/utility/pair/pair_decl.hpp>
#include <sprout/type_traits/is_convert_constructible.hpp> #include <sprout/type_traits/is_convert_constructible.hpp>
#include <sprout/tpp/algorithm/all_of.hpp> #include <sprout/tpp/algorithm/all_of.hpp>
#include <sprout/tuple/tuple/tuple_fwd.hpp> #include <sprout/tuple/tuple/tuple_decl.hpp>
#include <sprout/tuple/tuple/flexibly_construct.hpp> #include <sprout/tuple/tuple/flexibly_construct.hpp>
namespace sprout { namespace sprout {
namespace tuples { namespace tuples {
namespace detail { //
template<std::size_t Index, typename Head, bool IsEmpty> // tuple
class head_base; //
// EBO disabled // tuple construction
// template<std::size_t Index, typename Head> template<typename... Types>
// class head_base<Index, Head, true> inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple()
// : public Head : impl_type()
// { {}
// public: template<typename... Types>
// static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT { inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(Types const&... elements)
// return t; : impl_type(elements...)
// } {}
// static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT { template<typename... Types>
// return t; template<
// } typename... UTypes,
// public: typename
// SPROUT_CONSTEXPR head_base() >
// : Head() inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(UTypes&&... elements)
// {} : impl_type(sprout::forward<UTypes>(elements)...)
// SPROUT_CONSTEXPR head_base(Head const& v) {}
// : Head(v) template<typename... Types>
// {} inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(tuple const&) = default;
// template<typename UHead> template<typename... Types>
// SPROUT_CONSTEXPR head_base(UHead&& v) inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(tuple&&) = default;
// : Head(sprout::forward<UHead>(v)) template<typename... Types>
// {} template<
// }; typename... UTypes,
template<std::size_t Index, typename Head> typename
class head_base<Index, Head, true> { >
public: inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::tuple<UTypes...> const& t)
static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT { : impl_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...> const&>(t))
return t.head_; {}
} template<typename... Types>
static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT { template<
return t.head_; typename... UTypes,
} typename
private: >
Head head_; inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::tuple<UTypes...>&& t)
public: : impl_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...>&&>(t))
SPROUT_CONSTEXPR head_base() {}
: head_() template<typename... Types>
{} template<
SPROUT_CONSTEXPR head_base(Head const& v) typename... UTypes,
: head_(v) typename
{} >
template<typename UHead> inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::pair<UTypes...> const& t)
SPROUT_CONSTEXPR head_base(UHead&& v) : impl_type(t.first, t.second)
: head_(sprout::forward<UHead>(v)) {}
{} template<typename... Types>
}; template<
template<std::size_t Index, typename Head> typename... UTypes,
class head_base<Index, Head, false> { typename
public: >
static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT { inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::pair<UTypes...>&& t)
return t.head_; : impl_type(sprout::move(t.first), sprout::move(t.second))
} {}
static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT { template<typename... Types>
return t.head_; template<typename... UTypes>
} inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements)
private: : impl_type(sprout::forward<UTypes>(elements)...)
Head head_; {}
public: template<typename... Types>
SPROUT_CONSTEXPR head_base() template<typename... UTypes>
: head_() inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...> const& t)
{} : impl_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...> const&>(t))
SPROUT_CONSTEXPR head_base(Head const& v) {}
: head_(v) template<typename... Types>
{} template<typename... UTypes>
template<typename UHead> inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...>&& t)
SPROUT_CONSTEXPR head_base(UHead&& v) : impl_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...>&&>(t))
: head_(sprout::forward<UHead>(v)) {}
{} template<typename... Types>
}; template<typename... UTypes>
inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::flexibly_construct_t, sprout::pair<UTypes...> const& t)
template<std::size_t Index, typename... Types> : impl_type(t.first, t.second)
class tuple_impl; {}
template<std::size_t Index> template<typename... Types>
class tuple_impl<Index> { template<typename... UTypes>
public: inline SPROUT_CONSTEXPR sprout::tuples::tuple<Types...>::tuple(sprout::tuples::flexibly_construct_t, sprout::pair<UTypes...>&& t)
template<typename...> : impl_type(sprout::move(t.first), sprout::move(t.second))
friend class tuple; {}
template<std::size_t, typename...> // tuple assignment
friend class sprout::tuples::detail::tuple_impl; template<typename... Types>
protected: sprout::tuples::tuple<Types...>& sprout::tuples::tuple<Types...>::operator=(tuple const& rhs) {
void swap(tuple_impl&) SPROUT_NOEXCEPT {} static_cast<impl_type&>(*this) = rhs;
public: return *this;
tuple_impl() = default; }
template<typename... UTypes> template<typename... Types>
explicit SPROUT_CONSTEXPR tuple_impl(UTypes&&... args) SPROUT_NOEXCEPT {} sprout::tuples::tuple<Types...>& sprout::tuples::tuple<Types...>::operator=(tuple&& rhs)
SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default; SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of<std::is_nothrow_move_assignable<Types>...>::value)
SPROUT_CONSTEXPR tuple_impl(tuple_impl&&) = default; {
template<typename... UTypes> static_cast<impl_type&>(*this) = sprout::move(rhs);
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...> const& t) SPROUT_NOEXCEPT {} return *this;
template<typename... UTypes> }
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...>&& t) SPROUT_NOEXCEPT {} template<typename... Types>
tuple_impl& operator=(tuple_impl const&) = default; template<typename... UTypes>
tuple_impl& operator=(tuple_impl&& t) = default; sprout::tuples::tuple<Types...>& sprout::tuples::tuple<Types...>::operator=(sprout::tuples::tuple<UTypes...> const& rhs) {
template<typename... UTypes> static_cast<impl_type&>(*this) = rhs;
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...> const&) SPROUT_NOEXCEPT { return *this;
return *this; }
} template<typename... Types>
template<typename... UTypes> template<typename... UTypes>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...>&&) SPROUT_NOEXCEPT { sprout::tuples::tuple<Types...>& sprout::tuples::tuple<Types...>::operator=(sprout::tuples::tuple<UTypes...>&& rhs) {
return *this; static_cast<impl_type&>(*this) = sprout::move(rhs);
} return *this;
}; }
template<std::size_t Index, typename Head, typename... Tail> // tuple swap
class tuple_impl<Index, Head, Tail...> template<typename... Types>
: public sprout::tuples::detail::tuple_impl<Index + 1, Tail...> inline void sprout::tuples::tuple<Types...>::swap(tuple& other)
, private sprout::tuples::detail::head_base<Index, Head, std::is_empty<Head>::value> SPROUT_NOEXCEPT_EXPR(has_nothrow_swap::value)
{ {
public: impl_type::swap(other);
template<typename...> }
friend class tuple;
template<std::size_t, typename...>
friend class sprout::tuples::detail::tuple_impl;
public:
typedef sprout::tuples::detail::tuple_impl<Index + 1, Tail...> inherited_type;
typedef sprout::tuples::detail::head_base<Index, Head, std::is_empty<Head>::value> base_type;
public:
static SPROUT_CONSTEXPR Head& head(tuple_impl& t) SPROUT_NOEXCEPT {
return base_type::head(t);
}
static SPROUT_CONSTEXPR Head const& head(tuple_impl const& t) SPROUT_NOEXCEPT {
return base_type::head(t);
}
static SPROUT_CONSTEXPR inherited_type& tail(tuple_impl& t) SPROUT_NOEXCEPT {
return t;
}
static SPROUT_CONSTEXPR inherited_type const& tail(tuple_impl const& t) SPROUT_NOEXCEPT {
return t;
}
public:
void swap(tuple_impl& t)
SPROUT_NOEXCEPT_EXPR(
SPROUT_NOEXCEPT_EXPR(sprout::swap(head(std::declval<tuple_impl&>()), head(t)))
&& SPROUT_NOEXCEPT_EXPR(std::declval<inherited_type&>().swap(tail(t)))
)
{
sprout::swap(head(*this), head(t));
inherited_type::swap(tail(t));
}
public:
SPROUT_CONSTEXPR tuple_impl()
: inherited_type()
, base_type()
{}
explicit SPROUT_CONSTEXPR tuple_impl(Head const& h, Tail const&... tail)
: inherited_type(tail...)
, base_type(h)
{}
template<typename UHead, typename... UTail>
explicit SPROUT_CONSTEXPR tuple_impl(UHead&& h, UTail&&... tail)
: inherited_type(sprout::forward<UTail>(tail)...)
, base_type(sprout::forward<UHead>(h))
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default;
SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_constructible<Head>::value && std::is_nothrow_move_constructible<inherited_type>::value)
: inherited_type(sprout::move(tail(t)))
, base_type(sprout::forward<Head>(head(t)))
{}
template<typename... UTypes>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...> const& t)
: inherited_type(sprout::tuples::detail::tuple_impl<Index, UTypes...>::tail(t))
, base_type(sprout::tuples::detail::tuple_impl<Index, UTypes...>::head(t))
{}
template<typename UHead, typename... UTail>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UHead, UTail...>&& t)
: inherited_type(sprout::move(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::tail(t)))
, base_type(sprout::forward<UHead>(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::head(t)))
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index> const& t)
: inherited_type()
, base_type()
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index>&& t)
: inherited_type()
, base_type()
{}
tuple_impl& operator=(tuple_impl const& t) {
head(*this) = head(t);
tail(*this) = tail(t);
return *this;
}
tuple_impl& operator=(tuple_impl&& t)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<Head>::value && std::is_nothrow_move_assignable<inherited_type>::value)
{
head(*this) = sprout::forward<Head>(head(t));
tail(*this) = sprout::move(tail(t));
return *this;
}
template<typename... UTypes>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...> const& t) {
head(*this) = sprout::tuples::detail::tuple_impl<Index, UTypes...>::head(t);
tail(*this) = sprout::tuples::detail::tuple_impl<Index, UTypes...>::tail(t);
return *this;
}
template<typename UHead, typename... UTail>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>&& t) {
head(*this) = sprout::forward<UHead>(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::head(t));
tail(*this) = sprout::move(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::tail(t));
return *this;
}
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index> const& t) {
*this = sprout::move(tuple_impl());
return *this;
}
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index>&& t) {
*this = sprout::move(tuple_impl());
return *this;
}
};
} // namespace detail
// //
// tuple // tuple
// //
template<typename... Types> // tuple construction
class tuple inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple() = default;
: public sprout::tuples::detail::tuple_impl<0, Types...> inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(tuple const&) = default;
{ inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(tuple&&) = default;
private: template<typename... UTypes>
typedef sprout::tuples::detail::tuple_impl<0, Types...> inherited_type; inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements) {}
public: template<typename... UTypes>
// tuple construction inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...> const& t) {}
SPROUT_CONSTEXPR tuple() template<typename... UTypes>
: inherited_type() inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...>&& t) {}
{} // tuple swap
explicit SPROUT_CONSTEXPR tuple(Types const&... elements) inline void sprout::tuples::tuple<>::swap(tuple&) SPROUT_NOEXCEPT {}
: inherited_type(elements...)
{}
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
explicit SPROUT_CONSTEXPR tuple(UTypes&&... elements)
: inherited_type(sprout::forward<UTypes>(elements)...)
{}
template<typename... UTypes>
explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements)
: inherited_type(sprout::forward<UTypes>(elements)...)
{}
SPROUT_CONSTEXPR tuple(tuple const&) = default;
SPROUT_CONSTEXPR tuple(tuple&&) = default;
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes const&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::tuples::tuple<UTypes...> const& t)
: inherited_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...> const&>(t))
{}
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::tuples::tuple<UTypes...>&& t)
: inherited_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...>&&>(t))
{}
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...> const& t)
: inherited_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...> const&>(t))
{}
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...>&& t)
: inherited_type(static_cast<sprout::tuples::detail::tuple_impl<0, UTypes...>&&>(t))
{}
// tuple assignment
tuple& operator=(tuple const& rhs) {
static_cast<inherited_type&>(*this) = rhs;
return *this;
}
tuple& operator=(tuple&& rhs)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<inherited_type>::value)
{
static_cast<inherited_type&>(*this) = sprout::move(rhs);
return *this;
}
template<typename... UTypes>
tuple& operator=(sprout::tuples::tuple<UTypes...> const& rhs) {
static_cast<inherited_type&>(*this) = rhs;
return *this;
}
template<typename... UTypes>
tuple& operator=(sprout::tuples::tuple<UTypes...>&& rhs) {
static_cast<inherited_type&>(*this) = sprout::move(rhs);
return *this;
}
// tuple swap
void swap(tuple& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<inherited_type&>().swap(other)))
{
inherited_type::swap(other);
}
};
template<>
class tuple<> {
public:
// tuple swap
void swap(tuple&) SPROUT_NOEXCEPT {}
};
// //
// swap // swap
@ -334,49 +155,7 @@ namespace sprout {
{ {
lhs.swap(rhs); lhs.swap(rhs);
} }
namespace detail {
template<std::size_t I, typename T>
struct tuple_element_impl;
template<typename Head, typename... Tail>
struct tuple_element_impl<0, sprout::tuples::tuple<Head, Tail...> > {
public:
typedef Head type;
};
template<std::size_t I, typename Head, typename... Tail>
struct tuple_element_impl<I, sprout::tuples::tuple<Head, Tail...> >
: public sprout::tuples::detail::tuple_element_impl<I - 1, sprout::tuples::tuple<Tail...> >
{};
} // namespace detail
} // namespace tuples } // namespace tuples
using sprout::tuples::tuple;
using sprout::tuples::swap;
} // namespace sprout } // namespace sprout
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
//
// tuple_size
//
template<typename... Types>
struct tuple_size<sprout::tuples::tuple<Types...> >
: public std::integral_constant<std::size_t, sizeof...(Types)>
{};
//
// tuple_element
//
template<std::size_t I, typename... Types>
struct tuple_element<I, sprout::tuples::tuple<Types...> >
: public sprout::tuples::detail::tuple_element_impl<I, sprout::tuples::tuple<Types...> >
{};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_HPP #endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_HPP

View file

@ -0,0 +1,382 @@
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_DECL_HPP
#define SPROUT_TUPLE_TUPLE_TUPLE_DECL_HPP
#include <cstddef>
#include <utility>
#include <type_traits>
#include <tuple>
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/pair/pair_fwd.hpp>
#include <sprout/type_traits/is_convert_constructible.hpp>
#include <sprout/tpp/algorithm/all_of.hpp>
#include <sprout/tuple/tuple/tuple_fwd.hpp>
#include <sprout/tuple/tuple/flexibly_construct.hpp>
namespace sprout {
namespace tuples {
namespace detail {
template<std::size_t Index, typename Head, bool IsEmpty>
class head_base;
// EBO disabled
// template<std::size_t Index, typename Head>
// class head_base<Index, Head, true>
// : public Head
// {
// public:
// static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT {
// return t;
// }
// static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT {
// return t;
// }
// public:
// SPROUT_CONSTEXPR head_base()
// : Head()
// {}
// SPROUT_CONSTEXPR head_base(Head const& v)
// : Head(v)
// {}
// template<typename UHead>
// SPROUT_CONSTEXPR head_base(UHead&& v)
// : Head(sprout::forward<UHead>(v))
// {}
// };
template<std::size_t Index, typename Head>
class head_base<Index, Head, true> {
public:
static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT {
return t.head_;
}
static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT {
return t.head_;
}
private:
Head head_;
public:
SPROUT_CONSTEXPR head_base()
: head_()
{}
SPROUT_CONSTEXPR head_base(Head const& v)
: head_(v)
{}
template<typename UHead>
SPROUT_CONSTEXPR head_base(UHead&& v)
: head_(sprout::forward<UHead>(v))
{}
};
template<std::size_t Index, typename Head>
class head_base<Index, Head, false> {
public:
static SPROUT_CONSTEXPR Head& head(head_base& t) SPROUT_NOEXCEPT {
return t.head_;
}
static SPROUT_CONSTEXPR Head const& head(head_base const& t) SPROUT_NOEXCEPT {
return t.head_;
}
private:
Head head_;
public:
SPROUT_CONSTEXPR head_base()
: head_()
{}
SPROUT_CONSTEXPR head_base(Head const& v)
: head_(v)
{}
template<typename UHead>
SPROUT_CONSTEXPR head_base(UHead&& v)
: head_(sprout::forward<UHead>(v))
{}
};
template<std::size_t Index, typename... Types>
class tuple_impl;
template<std::size_t Index>
class tuple_impl<Index> {
public:
template<typename...>
friend class tuple;
template<std::size_t, typename...>
friend class sprout::tuples::detail::tuple_impl;
protected:
void swap(tuple_impl&) SPROUT_NOEXCEPT {}
public:
tuple_impl() = default;
template<typename... UTypes>
explicit SPROUT_CONSTEXPR tuple_impl(UTypes&&... args) SPROUT_NOEXCEPT {}
SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default;
SPROUT_CONSTEXPR tuple_impl(tuple_impl&&) = default;
template<typename... UTypes>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...> const& t) SPROUT_NOEXCEPT {}
template<typename... UTypes>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...>&& t) SPROUT_NOEXCEPT {}
tuple_impl& operator=(tuple_impl const&) = default;
tuple_impl& operator=(tuple_impl&& t) = default;
template<typename... UTypes>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...> const&) SPROUT_NOEXCEPT {
return *this;
}
template<typename... UTypes>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...>&&) SPROUT_NOEXCEPT {
return *this;
}
};
template<std::size_t Index, typename Head, typename... Tail>
class tuple_impl<Index, Head, Tail...>
: public sprout::tuples::detail::tuple_impl<Index + 1, Tail...>
, private sprout::tuples::detail::head_base<Index, Head, std::is_empty<Head>::value>
{
public:
template<typename...>
friend class tuple;
template<std::size_t, typename...>
friend class sprout::tuples::detail::tuple_impl;
public:
typedef sprout::tuples::detail::tuple_impl<Index + 1, Tail...> inherited_type;
typedef sprout::tuples::detail::head_base<Index, Head, std::is_empty<Head>::value> base_type;
public:
static SPROUT_CONSTEXPR Head& head(tuple_impl& t) SPROUT_NOEXCEPT {
return base_type::head(t);
}
static SPROUT_CONSTEXPR Head const& head(tuple_impl const& t) SPROUT_NOEXCEPT {
return base_type::head(t);
}
static SPROUT_CONSTEXPR inherited_type& tail(tuple_impl& t) SPROUT_NOEXCEPT {
return t;
}
static SPROUT_CONSTEXPR inherited_type const& tail(tuple_impl const& t) SPROUT_NOEXCEPT {
return t;
}
public:
void swap(tuple_impl& t)
SPROUT_NOEXCEPT_EXPR(
SPROUT_NOEXCEPT_EXPR(sprout::swap(head(std::declval<tuple_impl&>()), head(t)))
&& SPROUT_NOEXCEPT_EXPR(std::declval<inherited_type&>().swap(tail(t)))
)
{
sprout::swap(head(*this), head(t));
inherited_type::swap(tail(t));
}
public:
SPROUT_CONSTEXPR tuple_impl()
: inherited_type()
, base_type()
{}
explicit SPROUT_CONSTEXPR tuple_impl(Head const& h, Tail const&... tail)
: inherited_type(tail...)
, base_type(h)
{}
template<typename UHead, typename... UTail>
explicit SPROUT_CONSTEXPR tuple_impl(UHead&& h, UTail&&... tail)
: inherited_type(sprout::forward<UTail>(tail)...)
, base_type(sprout::forward<UHead>(h))
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default;
SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_constructible<Head>::value && std::is_nothrow_move_constructible<inherited_type>::value)
: inherited_type(sprout::move(tail(t)))
, base_type(sprout::forward<Head>(head(t)))
{}
template<typename... UTypes>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UTypes...> const& t)
: inherited_type(sprout::tuples::detail::tuple_impl<Index, UTypes...>::tail(t))
, base_type(sprout::tuples::detail::tuple_impl<Index, UTypes...>::head(t))
{}
template<typename UHead, typename... UTail>
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index, UHead, UTail...>&& t)
: inherited_type(sprout::move(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::tail(t)))
, base_type(sprout::forward<UHead>(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::head(t)))
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index> const& t)
: inherited_type()
, base_type()
{}
SPROUT_CONSTEXPR tuple_impl(tuple_impl<Index>&& t)
: inherited_type()
, base_type()
{}
tuple_impl& operator=(tuple_impl const& t) {
head(*this) = head(t);
tail(*this) = tail(t);
return *this;
}
tuple_impl& operator=(tuple_impl&& t)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<Head>::value && std::is_nothrow_move_assignable<inherited_type>::value)
{
head(*this) = sprout::forward<Head>(head(t));
tail(*this) = sprout::move(tail(t));
return *this;
}
template<typename... UTypes>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UTypes...> const& t) {
head(*this) = sprout::tuples::detail::tuple_impl<Index, UTypes...>::head(t);
tail(*this) = sprout::tuples::detail::tuple_impl<Index, UTypes...>::tail(t);
return *this;
}
template<typename UHead, typename... UTail>
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>&& t) {
head(*this) = sprout::forward<UHead>(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::head(t));
tail(*this) = sprout::move(sprout::tuples::detail::tuple_impl<Index, UHead, UTail...>::tail(t));
return *this;
}
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index> const& t) {
*this = sprout::move(tuple_impl());
return *this;
}
tuple_impl& operator=(sprout::tuples::detail::tuple_impl<Index>&& t) {
*this = sprout::move(tuple_impl());
return *this;
}
};
} // namespace detail
//
// tuple
//
template<typename... Types>
class tuple
: public sprout::tuples::detail::tuple_impl<0, Types...>
{
private:
typedef sprout::tuples::detail::tuple_impl<0, Types...> impl_type;
public:
struct has_nothrow_swap
: public sprout::tpp::all_of_c<
SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::swap(std::declval<Types&>(), std::declval<Types&>()), false)...
>
{};
public:
// tuple construction
SPROUT_CONSTEXPR tuple();
explicit SPROUT_CONSTEXPR tuple(Types const&... elements);
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
explicit SPROUT_CONSTEXPR tuple(UTypes&&... elements);
SPROUT_CONSTEXPR tuple(tuple const&);
SPROUT_CONSTEXPR tuple(tuple&&);
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes const&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::tuples::tuple<UTypes...> const& t);
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::tuples::tuple<UTypes...>&& t);
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == 2 && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::pair<UTypes...> const& t);
template<
typename... UTypes,
typename = typename std::enable_if<
sizeof...(Types) == 2 && sprout::tpp::all_of<sprout::is_convert_constructible<Types, UTypes&&>...>::value
>::type
>
SPROUT_CONSTEXPR tuple(sprout::pair<UTypes...>&& t);
template<typename... UTypes>
explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...> const& t);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...>&& t);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair<UTypes...> const& t);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair<UTypes...>&& t);
// tuple assignment
tuple& operator=(tuple const& rhs);
tuple& operator=(tuple&& rhs)
SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of<std::is_nothrow_move_assignable<Types>...>::value);
template<typename... UTypes>
tuple& operator=(sprout::tuples::tuple<UTypes...> const& rhs);
template<typename... UTypes>
tuple& operator=(sprout::tuples::tuple<UTypes...>&& rhs);
// tuple swap
void swap(tuple& other)
SPROUT_NOEXCEPT_EXPR(has_nothrow_swap::value);
};
template<>
class tuple<> {
public:
// tuple construction
SPROUT_CONSTEXPR tuple();
SPROUT_CONSTEXPR tuple(tuple const&);
SPROUT_CONSTEXPR tuple(tuple&&);
template<typename... UTypes>
explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...> const& t);
template<typename... UTypes>
SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple<UTypes...>&& t);
// tuple swap
void swap(tuple&) SPROUT_NOEXCEPT;
};
//
// swap
//
template<typename... Types>
inline void
swap(sprout::tuples::tuple<Types...>& lhs, sprout::tuples::tuple<Types...>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)));
namespace detail {
template<std::size_t I, typename T>
struct tuple_element_impl;
template<typename Head, typename... Tail>
struct tuple_element_impl<0, sprout::tuples::tuple<Head, Tail...> > {
public:
typedef Head type;
};
template<std::size_t I, typename Head, typename... Tail>
struct tuple_element_impl<I, sprout::tuples::tuple<Head, Tail...> >
: public sprout::tuples::detail::tuple_element_impl<I - 1, sprout::tuples::tuple<Tail...> >
{};
} // namespace detail
} // namespace tuples
using sprout::tuples::tuple;
using sprout::tuples::swap;
} // namespace sprout
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
//
// tuple_size
//
template<typename... Types>
struct tuple_size<sprout::tuples::tuple<Types...> >
: public std::integral_constant<std::size_t, sizeof...(Types)>
{};
//
// tuple_element
//
template<std::size_t I, typename... Types>
struct tuple_element<I, sprout::tuples::tuple<Types...> >
: public sprout::tuples::detail::tuple_element_impl<I, sprout::tuples::tuple<Types...> >
{};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_DECL_HPP

View file

@ -5,6 +5,9 @@
namespace sprout { namespace sprout {
namespace tuples { namespace tuples {
//
// tuple
//
template<typename... Types> template<typename... Types>
class tuple; class tuple;
} // namespace tuples } // namespace tuples

View file

@ -21,10 +21,7 @@ namespace sprout {
public: public:
typedef Head type; typedef Head type;
}; };
template< template<std::size_t N, typename... Args>
std::size_t N,
typename... Args
>
struct tppack_at_impl struct tppack_at_impl
: public sprout::detail::tppack_at_impl_1<N, Args...> : public sprout::detail::tppack_at_impl_1<N, Args...>
{ {

View file

@ -2,6 +2,8 @@
#define SPROUT_UTILITY_PAIR_HPP #define SPROUT_UTILITY_PAIR_HPP
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/utility/pair/pair_fwd.hpp>
#include <sprout/utility/pair/pair_decl.hpp>
#include <sprout/utility/pair/pair.hpp> #include <sprout/utility/pair/pair.hpp>
#include <sprout/utility/pair/comparison.hpp> #include <sprout/utility/pair/comparison.hpp>
#include <sprout/utility/pair/tuple.hpp> #include <sprout/utility/pair/tuple.hpp>

View file

@ -1,121 +1,113 @@
#ifndef SPROUT_UTILITY_PAIR_PAIR_HPP #ifndef SPROUT_UTILITY_PAIR_PAIR_HPP
#define SPROUT_UTILITY_PAIR_PAIR_HPP #define SPROUT_UTILITY_PAIR_PAIR_HPP
#include <utility>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/index_tuple.hpp> #include <sprout/index_tuple.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/utility/swap.hpp> #include <sprout/utility/swap.hpp>
#include <sprout/utility/pair/pair_decl.hpp>
#include <sprout/tuple/tuple/tuple.hpp> #include <sprout/tuple/tuple/tuple.hpp>
#include <sprout/tuple/tuple/get.hpp> #include <sprout/tuple/tuple/get.hpp>
namespace sprout { namespace sprout {
// Copyright (C) 2011 RiSK (sscrisk)
// //
// pair // pair
// //
template <typename T1, typename T2> template <typename T1, typename T2>
struct pair { template <typename... Args1, typename... Args2, sprout::index_t... Indexes1, sprout::index_t... Indexes2>
public: inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(
typedef T1 first_type; sprout::tuples::tuple<Args1...> first_args,
typedef T2 second_type; sprout::tuples::tuple<Args2...> second_args,
public: sprout::index_tuple<Indexes1...>,
T1 first; sprout::index_tuple<Indexes2...>
T2 second; )
private: : first(sprout::tuples::get<Indexes1>(first_args)...)
template <typename... Args1, typename... Args2, sprout::index_t... Indexes1, sprout::index_t... Indexes2> , second(sprout::tuples::get<Indexes2>(second_args)...)
SPROUT_CONSTEXPR pair( {}
sprout::tuples::tuple<Args1...> first_args, template <typename T1, typename T2>
sprout::tuples::tuple<Args2...> second_args, inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(pair const&) = default;
sprout::index_tuple<Indexes1...>, template <typename T1, typename T2>
sprout::index_tuple<Indexes2...> inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(pair&&) = default;
) template <typename T1, typename T2>
: first(sprout::tuples::get<Indexes1>(first_args)...) inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair()
, second(sprout::tuples::get<Indexes2>(second_args)...) : first()
{} , second()
public: {}
pair(pair const&) = default; template <typename T1, typename T2>
pair(pair&&) = default; inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(T1 const& x, T2 const& y)
SPROUT_CONSTEXPR pair() : first(x)
: first() , second(y)
, second() {}
{} template <typename T1, typename T2>
SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y) template<typename U, typename V>
: first(x) inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(U&& x, V&& y)
, second(y) : first(sprout::forward<U>(x))
{} , second(sprout::forward<V>(y))
template<typename U, typename V> {}
SPROUT_CONSTEXPR pair(U&& x, V&& y) template <typename T1, typename T2>
: first(sprout::forward<U>(x)) template<typename U, typename V>
, second(sprout::forward<V>(y)) inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::pair<U, V> const& other)
{} : first(other.first)
template<typename U, typename V> , second(other.second)
SPROUT_CONSTEXPR pair(sprout::pair<U, V> const& p) {}
: first(p.first) template <typename T1, typename T2>
, second(p.second) template<typename U, typename V>
{} inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(sprout::pair<U, V>&& other)
template<typename U, typename V> : first(sprout::move(other.first))
SPROUT_CONSTEXPR pair(sprout::pair<U, V>&& p) , second(sprout::move(other.second))
: first(sprout::forward<U>(p.first)) {}
, second(sprout::forward<V>(p.second))
{}
#if SPROUT_USE_DELEGATING_CONSTRUCTORS #if SPROUT_USE_DELEGATING_CONSTRUCTORS
template <typename... Args1, typename... Args2> template <typename T1, typename T2>
SPROUT_CONSTEXPR pair( template <typename... Args1, typename... Args2>
sprout::tuples::tuple<Args1...> first_args, inline SPROUT_CONSTEXPR sprout::pair<T1, T2>::pair(
sprout::tuples::tuple<Args2...> second_args sprout::tuples::tuple<Args1...> first_args,
sprout::tuples::tuple<Args2...> second_args
)
: pair(
first_args,
second_args,
sprout::index_range<0, sizeof...(Args1)>::make(),
sprout::index_range<0, sizeof...(Args2)>::make()
) )
: pair( {}
first_args,
second_args,
sprout::index_range<0, sizeof...(Args1)>::make(),
sprout::index_range<0, sizeof...(Args2)>::make()
)
{}
#else // #if SPROUT_USE_DELEGATING_CONSTRUCTORS
template <typename... Args1, typename... Args2>
SPROUT_CONSTEXPR pair(
sprout::tuples::tuple<Args1...> first_args,
sprout::tuples::tuple<Args2...> second_args
);
#endif // #if SPROUT_USE_DELEGATING_CONSTRUCTORS #endif // #if SPROUT_USE_DELEGATING_CONSTRUCTORS
pair& operator=(pair const& p) = default; template <typename T1, typename T2>
template<typename U, typename V> inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair const& other) = default;
pair& operator=(sprout::pair<U, V> const& p) { template <typename T1, typename T2>
first = p.first; template<typename U, typename V>
second = p.second; inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V> const& other) {
return *this; first = other.first;
} second = other.second;
pair& operator=(pair&& p) return *this;
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<T1>::value && std::is_nothrow_move_assignable<T2>::value) }
{ template <typename T1, typename T2>
first = sprout::forward<T1>(p.first); inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(pair&& other)
second = std::forward<T2>(p.second); SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<T1>::value && std::is_nothrow_move_assignable<T2>::value)
return *this; {
} first = sprout::move(other.first);
template<typename U, typename V> second = sprout::move(other.second);
pair& operator=(sprout::pair<U, V>&& p) { return *this;
first = std::forward<U>(p.first); }
second = std::forward<V>(p.second); template <typename T1, typename T2>
return *this; template<typename U, typename V>
} inline sprout::pair<T1, T2>& sprout::pair<T1, T2>::operator=(sprout::pair<U, V>&& other) {
void swap(pair& p) first = sprout::move(other.first);
SPROUT_NOEXCEPT_EXPR( second = sprout::move(other.second);
SPROUT_NOEXCEPT_EXPR(swap(first, p.first)) return *this;
&& SPROUT_NOEXCEPT_EXPR(swap(second, p.second)) }
) template <typename T1, typename T2>
{ inline void sprout::pair<T1, T2>::swap(pair& other)
sprout::swap(first, p.first); SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) {
sprout::swap(second, p.second); sprout::swap(first, other.first);
} sprout::swap(second, other.second);
}; }
// //
// swap // swap
// //
template<class T1, class T2> template<typename T1, typename T2>
inline void inline void
swap(sprout::pair<T1, T2>& lhs, sprout::pair<T1, T2>& rhs) swap(sprout::pair<T1, T2>& lhs, sprout::pair<T1, T2>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)))

View file

@ -0,0 +1,68 @@
#ifndef SPROUT_UTILITY_PAIR_PAIR_DECL_HPP
#define SPROUT_UTILITY_PAIR_PAIR_DECL_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/pair/pair_fwd.hpp>
#include <sprout/tuple/tuple/tuple_fwd.hpp>
namespace sprout {
//
// pair
//
template <typename T1, typename T2>
struct pair {
public:
typedef T1 first_type;
typedef T2 second_type;
public:
T1 first;
T2 second;
private:
template <typename... Args1, typename... Args2, sprout::index_t... Indexes1, sprout::index_t... Indexes2>
SPROUT_CONSTEXPR pair(
sprout::tuples::tuple<Args1...> first_args,
sprout::tuples::tuple<Args2...> second_args,
sprout::index_tuple<Indexes1...>,
sprout::index_tuple<Indexes2...>
);
public:
SPROUT_CONSTEXPR pair(pair const&);
SPROUT_CONSTEXPR pair(pair&&);
SPROUT_CONSTEXPR pair();
SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y);
template<typename U, typename V>
SPROUT_CONSTEXPR pair(U&& x, V&& y);
template<typename U, typename V>
SPROUT_CONSTEXPR pair(sprout::pair<U, V> const& other);
template<typename U, typename V>
SPROUT_CONSTEXPR pair(sprout::pair<U, V>&& other);
template <typename... Args1, typename... Args2>
SPROUT_CONSTEXPR pair(
sprout::tuples::tuple<Args1...> first_args,
sprout::tuples::tuple<Args2...> second_args
);
pair& operator=(pair const& other);
template<typename U, typename V>
pair& operator=(sprout::pair<U, V> const& other);
pair& operator=(pair&& other)
SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable<T1>::value && std::is_nothrow_move_assignable<T2>::value);
template<typename U, typename V>
pair& operator=(sprout::pair<U, V>&& other);
void swap(pair& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second)));
};
//
// swap
//
template<typename T1, typename T2>
inline void
swap(sprout::pair<T1, T2>& lhs, sprout::pair<T1, T2>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)));
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_DECL_HPP

View file

@ -0,0 +1,14 @@
#ifndef SPROUT_UTILITY_PAIR_PAIR_FWD_HPP
#define SPROUT_UTILITY_PAIR_PAIR_FWD_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// pair
//
template <typename T1, typename T2>
struct pair;
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_FWD_HPP