summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/utility
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/include/utility')
-rw-r--r--contrib/libc++/include/utility178
1 files changed, 128 insertions, 50 deletions
diff --git a/contrib/libc++/include/utility b/contrib/libc++/include/utility
index ba65649..2c1f62c 100644
--- a/contrib/libc++/include/utility
+++ b/contrib/libc++/include/utility
@@ -38,10 +38,10 @@ template <class T, size_t N>
void
swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
-template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept;
-template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept;
+template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
+template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
-template <class T> typename remove_reference<T>::type&& move(T&&) noexcept;
+template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
template <class T>
typename conditional
@@ -50,7 +50,7 @@ template <class T>
const T&,
T&&
>::type
- move_if_noexcept(T& x) noexcept;
+ move_if_noexcept(T& x) noexcept; // constexpr in C++14
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
@@ -66,10 +66,10 @@ struct pair
pair(const pair&) = default;
pair(pair&&) = default;
constexpr pair();
- pair(const T1& x, const T2& y);
- template <class U, class V> pair(U&& x, V&& y);
- template <class U, class V> pair(const pair<U, V>& p);
- template <class U, class V> pair(pair<U, V>&& p);
+ pair(const T1& x, const T2& y); // constexpr in C++14
+ template <class U, class V> pair(U&& x, V&& y); // constexpr in C++14
+ template <class U, class V> pair(const pair<U, V>& p); // constexpr in C++14
+ template <class U, class V> pair(pair<U, V>&& p); // constexpr in C++14
template <class... Args1, class... Args2>
pair(piecewise_construct_t, tuple<Args1...> first_args,
tuple<Args2...> second_args);
@@ -83,14 +83,14 @@ struct pair
noexcept(swap(second, p.second)));
};
-template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
-template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
-template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
-template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
-template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
-template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
+template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
-template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
+template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14
template <class T1, class T2>
void
swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
@@ -107,15 +107,24 @@ template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
template<size_t I, class T1, class T2>
typename tuple_element<I, std::pair<T1, T2> >::type&
- get(std::pair<T1, T2>&) noexcept;
+ get(std::pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
const typename const tuple_element<I, std::pair<T1, T2> >::type&
- get(const std::pair<T1, T2>&) noexcept;
+ get(const std::pair<T1, T2>&) noexcept; // constexpr in C++14
template<size_t I, class T1, class T2>
typename tuple_element<I, std::pair<T1, T2> >::type&&
- get(std::pair<T1, T2>&&) noexcept;
+ get(std::pair<T1, T2>&&) noexcept; // constexpr in C++14
+
+template<class T1, class T2>
+ constexpr T1& get(std::pair<T1, T2>&) noexcept; // C++14
+
+template<size_t I, class T1, class T2>
+ constexpr T1 const& get(std::pair<T1, T2> const &) noexcept; // C++14
+
+template<size_t I, class T1, class T2>
+ constexpr T1&& get(std::pair<T1, T2>&&) noexcept; // C++14
// C++14
@@ -138,6 +147,8 @@ template<size_t N>
template<class... T>
using index_sequence_for = make_index_sequence<sizeof...(T)>;
+template<class T, class U=T>
+ T exchange(T& obj, U&& new_value);
} // std
*/
@@ -210,7 +221,7 @@ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::v
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
typename conditional
<
@@ -226,7 +237,7 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT
return _VSTD::move(__x);
}
-struct _LIBCPP_TYPE_VIS piecewise_construct_t { };
+struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { };
#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY)
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
#else
@@ -234,7 +245,7 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
#endif
template <class _T1, class _T2>
-struct _LIBCPP_TYPE_VIS pair
+struct _LIBCPP_TYPE_VIS_ONLY pair
{
typedef _T1 first_type;
typedef _T2 second_type;
@@ -247,11 +258,12 @@ struct _LIBCPP_TYPE_VIS pair
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
- _LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+ pair(const _T1& __x, const _T2& __y)
: first(__x), second(__y) {}
template<class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(const pair<_U1, _U2>& __p
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
,typename enable_if<is_convertible<const _U1&, _T1>::value &&
@@ -260,6 +272,10 @@ struct _LIBCPP_TYPE_VIS pair
)
: first(__p.first), second(__p.second) {}
+#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
+ _LIBCPP_INLINE_VISIBILITY
+ pair(const pair& __p) = default;
+#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
_LIBCPP_INLINE_VISIBILITY
pair(const pair& __p)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
@@ -268,6 +284,7 @@ struct _LIBCPP_TYPE_VIS pair
second(__p.second)
{
}
+#endif
_LIBCPP_INLINE_VISIBILITY
pair& operator=(const pair& __p)
@@ -284,20 +301,24 @@ struct _LIBCPP_TYPE_VIS pair
template <class _U1, class _U2,
class = typename enable_if<is_convertible<_U1, first_type>::value &&
is_convertible<_U2, second_type>::value>::type>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_U1&& __u1, _U2&& __u2)
: first(_VSTD::forward<_U1>(__u1)),
second(_VSTD::forward<_U2>(__u2))
{}
template<class _U1, class _U2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2>&& __p,
typename enable_if<is_convertible<_U1, _T1>::value &&
is_convertible<_U2, _T2>::value>::type* = 0)
: first(_VSTD::forward<_U1>(__p.first)),
second(_VSTD::forward<_U2>(__p.second)) {}
+#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
+ _LIBCPP_INLINE_VISIBILITY
+ pair(pair&& __p) = default;
+#else
_LIBCPP_INLINE_VISIBILITY
pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
is_nothrow_move_constructible<second_type>::value)
@@ -305,6 +326,7 @@ struct _LIBCPP_TYPE_VIS pair
second(_VSTD::forward<second_type>(__p.second))
{
}
+#endif
_LIBCPP_INLINE_VISIBILITY
pair&
@@ -320,7 +342,7 @@ struct _LIBCPP_TYPE_VIS pair
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_Tuple&& __p)
: first(_VSTD::forward<typename tuple_element<0,
typename __make_tuple_types<_Tuple>::type>::type>(get<0>(__p))),
@@ -376,7 +398,7 @@ private:
};
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -384,7 +406,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -392,7 +414,7 @@ operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -400,7 +422,7 @@ operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -408,7 +430,7 @@ operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -416,7 +438,7 @@ operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
}
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
bool
operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
@@ -440,7 +462,7 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-template <class _Tp> class _LIBCPP_TYPE_VIS reference_wrapper;
+template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
template <class _Tp>
struct ___make_pair_return
@@ -461,7 +483,7 @@ struct __make_pair_return
};
template <class _T1, class _T2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
make_pair(_T1&& __t1, _T2&& __t2)
{
@@ -482,36 +504,36 @@ make_pair(_T1 __x, _T2 __y)
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _T1, class _T2>
- class _LIBCPP_TYPE_VIS tuple_size<pair<_T1, _T2> >
+ class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
- class _LIBCPP_TYPE_VIS tuple_size<const pair<_T1, _T2> >
+ class _LIBCPP_TYPE_VIS_ONLY tuple_size<const pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS tuple_element<0, pair<_T1, _T2> >
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> >
{
public:
typedef _T1 type;
};
template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS tuple_element<1, pair<_T1, _T2> >
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> >
{
public:
typedef _T2 type;
};
template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS tuple_element<0, const pair<_T1, _T2> >
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> >
{
public:
typedef const _T1 type;
};
template <class _T1, class _T2>
-class _LIBCPP_TYPE_VIS tuple_element<1, const pair<_T1, _T2> >
+class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> >
{
public:
typedef const _T2 type;
@@ -524,13 +546,13 @@ struct __get_pair<0>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T1&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _T1&
get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
@@ -538,7 +560,7 @@ struct __get_pair<0>
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T1&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
@@ -550,13 +572,13 @@ struct __get_pair<1>
{
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T2&
get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _T2&
get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
@@ -564,7 +586,7 @@ struct __get_pair<1>
template <class _T1, class _T2>
static
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_T2&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
@@ -572,7 +594,7 @@ struct __get_pair<1>
};
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>& __p) _NOEXCEPT
{
@@ -580,7 +602,7 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT
}
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>& __p) _NOEXCEPT
{
@@ -590,7 +612,7 @@ get(const pair<_T1, _T2>& __p) _NOEXCEPT
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <size_t _Ip, class _T1, class _T2>
-_LIBCPP_INLINE_VISIBILITY inline
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&& __p) _NOEXCEPT
{
@@ -600,9 +622,54 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#if _LIBCPP_STD_VER > 11
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT
+{
+ return __get_pair<0>::get(_VSTD::move(__p));
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(__p);
+}
+
+template <class _T1, class _T2>
+inline _LIBCPP_INLINE_VISIBILITY
+constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
+{
+ return __get_pair<1>::get(_VSTD::move(__p));
+}
+
+#endif
+
+#if _LIBCPP_STD_VER > 11
template<class _Tp, _Tp... _Ip>
-struct _LIBCPP_TYPE_VIS integer_sequence
+struct _LIBCPP_TYPE_VIS_ONLY integer_sequence
{
typedef _Tp value_type;
static_assert( is_integral<_Tp>::value,
@@ -685,6 +752,17 @@ template<class... _Tp>
#endif // _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
+template<class _T1, class _T2 = _T1>
+inline _LIBCPP_INLINE_VISIBILITY
+_T1 exchange(_T1& __obj, _T2 && __new_value)
+{
+ _T1 __old_value = _VSTD::move(__obj);
+ __obj = _VSTD::forward<_T2>(__new_value);
+ return __old_value;
+}
+#endif // _LIBCPP_STD_VER > 11
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_UTILITY
OpenPOWER on IntegriCloud