14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===-------------------------- utility -----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open 74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_UTILITY 124684ddb6SLionel Sambuc#define _LIBCPP_UTILITY 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc utility synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std 184684ddb6SLionel Sambuc{ 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambuctemplate <class T> 214684ddb6SLionel Sambuc void 224684ddb6SLionel Sambuc swap(T& a, T& b); 234684ddb6SLionel Sambuc 244684ddb6SLionel Sambucnamespace rel_ops 254684ddb6SLionel Sambuc{ 264684ddb6SLionel Sambuc template<class T> bool operator!=(const T&, const T&); 274684ddb6SLionel Sambuc template<class T> bool operator> (const T&, const T&); 284684ddb6SLionel Sambuc template<class T> bool operator<=(const T&, const T&); 294684ddb6SLionel Sambuc template<class T> bool operator>=(const T&, const T&); 304684ddb6SLionel Sambuc} 314684ddb6SLionel Sambuc 324684ddb6SLionel Sambuctemplate<class T> 334684ddb6SLionel Sambucvoid 344684ddb6SLionel Sambucswap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value && 354684ddb6SLionel Sambuc is_nothrow_move_assignable<T>::value); 364684ddb6SLionel Sambuc 374684ddb6SLionel Sambuctemplate <class T, size_t N> 384684ddb6SLionel Sambucvoid 394684ddb6SLionel Sambucswap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b))); 404684ddb6SLionel Sambuc 414684ddb6SLionel Sambuctemplate <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14 424684ddb6SLionel Sambuctemplate <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14 434684ddb6SLionel Sambuc 444684ddb6SLionel Sambuctemplate <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14 454684ddb6SLionel Sambuc 464684ddb6SLionel Sambuctemplate <class T> 474684ddb6SLionel Sambuc typename conditional 484684ddb6SLionel Sambuc < 494684ddb6SLionel Sambuc !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value, 504684ddb6SLionel Sambuc const T&, 514684ddb6SLionel Sambuc T&& 524684ddb6SLionel Sambuc >::type 534684ddb6SLionel Sambuc move_if_noexcept(T& x) noexcept; // constexpr in C++14 544684ddb6SLionel Sambuc 554684ddb6SLionel Sambuctemplate <class T> typename add_rvalue_reference<T>::type declval() noexcept; 564684ddb6SLionel Sambuc 574684ddb6SLionel Sambuctemplate <class T1, class T2> 584684ddb6SLionel Sambucstruct pair 594684ddb6SLionel Sambuc{ 604684ddb6SLionel Sambuc typedef T1 first_type; 614684ddb6SLionel Sambuc typedef T2 second_type; 624684ddb6SLionel Sambuc 634684ddb6SLionel Sambuc T1 first; 644684ddb6SLionel Sambuc T2 second; 654684ddb6SLionel Sambuc 664684ddb6SLionel Sambuc pair(const pair&) = default; 674684ddb6SLionel Sambuc pair(pair&&) = default; 684684ddb6SLionel Sambuc constexpr pair(); 694684ddb6SLionel Sambuc pair(const T1& x, const T2& y); // constexpr in C++14 704684ddb6SLionel Sambuc template <class U, class V> pair(U&& x, V&& y); // constexpr in C++14 714684ddb6SLionel Sambuc template <class U, class V> pair(const pair<U, V>& p); // constexpr in C++14 724684ddb6SLionel Sambuc template <class U, class V> pair(pair<U, V>&& p); // constexpr in C++14 734684ddb6SLionel Sambuc template <class... Args1, class... Args2> 744684ddb6SLionel Sambuc pair(piecewise_construct_t, tuple<Args1...> first_args, 754684ddb6SLionel Sambuc tuple<Args2...> second_args); 764684ddb6SLionel Sambuc 774684ddb6SLionel Sambuc template <class U, class V> pair& operator=(const pair<U, V>& p); 784684ddb6SLionel Sambuc pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value && 794684ddb6SLionel Sambuc is_nothrow_move_assignable<T2>::value); 804684ddb6SLionel Sambuc template <class U, class V> pair& operator=(pair<U, V>&& p); 814684ddb6SLionel Sambuc 824684ddb6SLionel Sambuc void swap(pair& p) noexcept(noexcept(swap(first, p.first)) && 834684ddb6SLionel Sambuc noexcept(swap(second, p.second))); 844684ddb6SLionel Sambuc}; 854684ddb6SLionel Sambuc 864684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 874684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 884684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 894684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 904684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 914684ddb6SLionel Sambuctemplate <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 924684ddb6SLionel Sambuc 934684ddb6SLionel Sambuctemplate <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14 944684ddb6SLionel Sambuctemplate <class T1, class T2> 954684ddb6SLionel Sambucvoid 964684ddb6SLionel Sambucswap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); 974684ddb6SLionel Sambuc 984684ddb6SLionel Sambucstruct piecewise_construct_t { }; 994684ddb6SLionel Sambucconstexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); 1004684ddb6SLionel Sambuc 1014684ddb6SLionel Sambuctemplate <class T> class tuple_size; 1024684ddb6SLionel Sambuctemplate <size_t I, class T> class tuple_element; 1034684ddb6SLionel Sambuc 104*0a6a1f1dSLionel Sambuctemplate <class T1, class T2> struct tuple_size<pair<T1, T2> >; 105*0a6a1f1dSLionel Sambuctemplate <class T1, class T2> struct tuple_element<0, pair<T1, T2> >; 106*0a6a1f1dSLionel Sambuctemplate <class T1, class T2> struct tuple_element<1, pair<T1, T2> >; 1074684ddb6SLionel Sambuc 1084684ddb6SLionel Sambuctemplate<size_t I, class T1, class T2> 109*0a6a1f1dSLionel Sambuc typename tuple_element<I, pair<T1, T2> >::type& 110*0a6a1f1dSLionel Sambuc get(pair<T1, T2>&) noexcept; // constexpr in C++14 1114684ddb6SLionel Sambuc 1124684ddb6SLionel Sambuctemplate<size_t I, class T1, class T2> 113*0a6a1f1dSLionel Sambuc const typename const tuple_element<I, pair<T1, T2> >::type& 114*0a6a1f1dSLionel Sambuc get(const pair<T1, T2>&) noexcept; // constexpr in C++14 1154684ddb6SLionel Sambuc 1164684ddb6SLionel Sambuctemplate<size_t I, class T1, class T2> 117*0a6a1f1dSLionel Sambuc typename tuple_element<I, pair<T1, T2> >::type&& 118*0a6a1f1dSLionel Sambuc get(pair<T1, T2>&&) noexcept; // constexpr in C++14 1194684ddb6SLionel Sambuc 1204684ddb6SLionel Sambuctemplate<class T1, class T2> 121*0a6a1f1dSLionel Sambuc constexpr T1& get(pair<T1, T2>&) noexcept; // C++14 1224684ddb6SLionel Sambuc 1234684ddb6SLionel Sambuctemplate<size_t I, class T1, class T2> 124*0a6a1f1dSLionel Sambuc constexpr T1 const& get(pair<T1, T2> const &) noexcept; // C++14 1254684ddb6SLionel Sambuc 1264684ddb6SLionel Sambuctemplate<size_t I, class T1, class T2> 127*0a6a1f1dSLionel Sambuc constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14 1284684ddb6SLionel Sambuc 1294684ddb6SLionel Sambuc// C++14 1304684ddb6SLionel Sambuc 1314684ddb6SLionel Sambuctemplate<class T, T... I> 1324684ddb6SLionel Sambucstruct integer_sequence 1334684ddb6SLionel Sambuc{ 1344684ddb6SLionel Sambuc typedef T value_type; 1354684ddb6SLionel Sambuc 1364684ddb6SLionel Sambuc static constexpr size_t size() noexcept; 1374684ddb6SLionel Sambuc}; 1384684ddb6SLionel Sambuc 1394684ddb6SLionel Sambuctemplate<size_t... I> 1404684ddb6SLionel Sambuc using index_sequence = integer_sequence<size_t, I...>; 1414684ddb6SLionel Sambuc 1424684ddb6SLionel Sambuctemplate<class T, T N> 1434684ddb6SLionel Sambuc using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>; 1444684ddb6SLionel Sambuctemplate<size_t N> 1454684ddb6SLionel Sambuc using make_index_sequence = make_integer_sequence<size_t, N>; 1464684ddb6SLionel Sambuc 1474684ddb6SLionel Sambuctemplate<class... T> 1484684ddb6SLionel Sambuc using index_sequence_for = make_index_sequence<sizeof...(T)>; 1494684ddb6SLionel Sambuc 1504684ddb6SLionel Sambuctemplate<class T, class U=T> 1514684ddb6SLionel Sambuc T exchange(T& obj, U&& new_value); 1524684ddb6SLionel Sambuc} // std 1534684ddb6SLionel Sambuc 1544684ddb6SLionel Sambuc*/ 1554684ddb6SLionel Sambuc 1564684ddb6SLionel Sambuc#include <__config> 1574684ddb6SLionel Sambuc#include <__tuple> 1584684ddb6SLionel Sambuc#include <type_traits> 1594684ddb6SLionel Sambuc 1604684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1614684ddb6SLionel Sambuc#pragma GCC system_header 1624684ddb6SLionel Sambuc#endif 1634684ddb6SLionel Sambuc 1644684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 1654684ddb6SLionel Sambuc 1664684ddb6SLionel Sambucnamespace rel_ops 1674684ddb6SLionel Sambuc{ 1684684ddb6SLionel Sambuc 1694684ddb6SLionel Sambuctemplate<class _Tp> 1704684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1714684ddb6SLionel Sambucbool 1724684ddb6SLionel Sambucoperator!=(const _Tp& __x, const _Tp& __y) 1734684ddb6SLionel Sambuc{ 1744684ddb6SLionel Sambuc return !(__x == __y); 1754684ddb6SLionel Sambuc} 1764684ddb6SLionel Sambuc 1774684ddb6SLionel Sambuctemplate<class _Tp> 1784684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1794684ddb6SLionel Sambucbool 1804684ddb6SLionel Sambucoperator> (const _Tp& __x, const _Tp& __y) 1814684ddb6SLionel Sambuc{ 1824684ddb6SLionel Sambuc return __y < __x; 1834684ddb6SLionel Sambuc} 1844684ddb6SLionel Sambuc 1854684ddb6SLionel Sambuctemplate<class _Tp> 1864684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1874684ddb6SLionel Sambucbool 1884684ddb6SLionel Sambucoperator<=(const _Tp& __x, const _Tp& __y) 1894684ddb6SLionel Sambuc{ 1904684ddb6SLionel Sambuc return !(__y < __x); 1914684ddb6SLionel Sambuc} 1924684ddb6SLionel Sambuc 1934684ddb6SLionel Sambuctemplate<class _Tp> 1944684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 1954684ddb6SLionel Sambucbool 1964684ddb6SLionel Sambucoperator>=(const _Tp& __x, const _Tp& __y) 1974684ddb6SLionel Sambuc{ 1984684ddb6SLionel Sambuc return !(__x < __y); 1994684ddb6SLionel Sambuc} 2004684ddb6SLionel Sambuc 2014684ddb6SLionel Sambuc} // rel_ops 2024684ddb6SLionel Sambuc 2034684ddb6SLionel Sambuc// swap_ranges 2044684ddb6SLionel Sambuc 205*0a6a1f1dSLionel Sambuc// forward 206*0a6a1f1dSLionel Sambuctemplate<class _Tp, size_t _Np> 207*0a6a1f1dSLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 208*0a6a1f1dSLionel Sambucvoid swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); 209*0a6a1f1dSLionel Sambuc 2104684ddb6SLionel Sambuctemplate <class _ForwardIterator1, class _ForwardIterator2> 2114684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2124684ddb6SLionel Sambuc_ForwardIterator2 2134684ddb6SLionel Sambucswap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) 2144684ddb6SLionel Sambuc{ 215*0a6a1f1dSLionel Sambuc for(; __first1 != __last1; ++__first1, (void) ++__first2) 2164684ddb6SLionel Sambuc swap(*__first1, *__first2); 2174684ddb6SLionel Sambuc return __first2; 2184684ddb6SLionel Sambuc} 2194684ddb6SLionel Sambuc 2204684ddb6SLionel Sambuctemplate<class _Tp, size_t _Np> 2214684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 2224684ddb6SLionel Sambucvoid 2234684ddb6SLionel Sambucswap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) 2244684ddb6SLionel Sambuc{ 2254684ddb6SLionel Sambuc _VSTD::swap_ranges(__a, __a + _Np, __b); 2264684ddb6SLionel Sambuc} 2274684ddb6SLionel Sambuc 2284684ddb6SLionel Sambuctemplate <class _Tp> 2294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 2304684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 2314684ddb6SLionel Sambuctypename conditional 2324684ddb6SLionel Sambuc< 2334684ddb6SLionel Sambuc !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, 2344684ddb6SLionel Sambuc const _Tp&, 2354684ddb6SLionel Sambuc _Tp&& 2364684ddb6SLionel Sambuc>::type 2374684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 2384684ddb6SLionel Sambucconst _Tp& 2394684ddb6SLionel Sambuc#endif 2404684ddb6SLionel Sambucmove_if_noexcept(_Tp& __x) _NOEXCEPT 2414684ddb6SLionel Sambuc{ 2424684ddb6SLionel Sambuc return _VSTD::move(__x); 2434684ddb6SLionel Sambuc} 2444684ddb6SLionel Sambuc 2454684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { }; 2464684ddb6SLionel Sambuc#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY) 2474684ddb6SLionel Sambucextern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); 2484684ddb6SLionel Sambuc#else 2494684ddb6SLionel Sambucconstexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); 2504684ddb6SLionel Sambuc#endif 2514684ddb6SLionel Sambuc 2524684ddb6SLionel Sambuctemplate <class _T1, class _T2> 2534684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY pair 2544684ddb6SLionel Sambuc{ 2554684ddb6SLionel Sambuc typedef _T1 first_type; 2564684ddb6SLionel Sambuc typedef _T2 second_type; 2574684ddb6SLionel Sambuc 2584684ddb6SLionel Sambuc _T1 first; 2594684ddb6SLionel Sambuc _T2 second; 2604684ddb6SLionel Sambuc 2614684ddb6SLionel Sambuc // pair(const pair&) = default; 2624684ddb6SLionel Sambuc // pair(pair&&) = default; 2634684ddb6SLionel Sambuc 2644684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} 2654684ddb6SLionel Sambuc 2664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 2674684ddb6SLionel Sambuc pair(const _T1& __x, const _T2& __y) 2684684ddb6SLionel Sambuc : first(__x), second(__y) {} 2694684ddb6SLionel Sambuc 2704684ddb6SLionel Sambuc template<class _U1, class _U2> 2714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 2724684ddb6SLionel Sambuc pair(const pair<_U1, _U2>& __p 2734684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 2744684ddb6SLionel Sambuc ,typename enable_if<is_convertible<const _U1&, _T1>::value && 2754684ddb6SLionel Sambuc is_convertible<const _U2&, _T2>::value>::type* = 0 2764684ddb6SLionel Sambuc#endif 2774684ddb6SLionel Sambuc ) 2784684ddb6SLionel Sambuc : first(__p.first), second(__p.second) {} 2794684ddb6SLionel Sambuc 2804684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 2814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2824684ddb6SLionel Sambuc pair(const pair& __p) = default; 2834684ddb6SLionel Sambuc#elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR 2844684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2854684ddb6SLionel Sambuc pair(const pair& __p) 2864684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && 2874684ddb6SLionel Sambuc is_nothrow_copy_constructible<second_type>::value) 2884684ddb6SLionel Sambuc : first(__p.first), 2894684ddb6SLionel Sambuc second(__p.second) 2904684ddb6SLionel Sambuc { 2914684ddb6SLionel Sambuc } 2924684ddb6SLionel Sambuc#endif 2934684ddb6SLionel Sambuc 2944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 2954684ddb6SLionel Sambuc pair& operator=(const pair& __p) 2964684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value && 2974684ddb6SLionel Sambuc is_nothrow_copy_assignable<second_type>::value) 2984684ddb6SLionel Sambuc { 2994684ddb6SLionel Sambuc first = __p.first; 3004684ddb6SLionel Sambuc second = __p.second; 3014684ddb6SLionel Sambuc return *this; 3024684ddb6SLionel Sambuc } 3034684ddb6SLionel Sambuc 3044684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 3054684ddb6SLionel Sambuc 3064684ddb6SLionel Sambuc template <class _U1, class _U2, 3074684ddb6SLionel Sambuc class = typename enable_if<is_convertible<_U1, first_type>::value && 3084684ddb6SLionel Sambuc is_convertible<_U2, second_type>::value>::type> 3094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 3104684ddb6SLionel Sambuc pair(_U1&& __u1, _U2&& __u2) 3114684ddb6SLionel Sambuc : first(_VSTD::forward<_U1>(__u1)), 3124684ddb6SLionel Sambuc second(_VSTD::forward<_U2>(__u2)) 3134684ddb6SLionel Sambuc {} 3144684ddb6SLionel Sambuc 3154684ddb6SLionel Sambuc template<class _U1, class _U2> 3164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 3174684ddb6SLionel Sambuc pair(pair<_U1, _U2>&& __p, 3184684ddb6SLionel Sambuc typename enable_if<is_convertible<_U1, _T1>::value && 3194684ddb6SLionel Sambuc is_convertible<_U2, _T2>::value>::type* = 0) 3204684ddb6SLionel Sambuc : first(_VSTD::forward<_U1>(__p.first)), 3214684ddb6SLionel Sambuc second(_VSTD::forward<_U2>(__p.second)) {} 3224684ddb6SLionel Sambuc 3234684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS 3244684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3254684ddb6SLionel Sambuc pair(pair&& __p) = default; 3264684ddb6SLionel Sambuc#else 3274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3284684ddb6SLionel Sambuc pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value && 3294684ddb6SLionel Sambuc is_nothrow_move_constructible<second_type>::value) 3304684ddb6SLionel Sambuc : first(_VSTD::forward<first_type>(__p.first)), 3314684ddb6SLionel Sambuc second(_VSTD::forward<second_type>(__p.second)) 3324684ddb6SLionel Sambuc { 3334684ddb6SLionel Sambuc } 3344684ddb6SLionel Sambuc#endif 3354684ddb6SLionel Sambuc 3364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3374684ddb6SLionel Sambuc pair& 3384684ddb6SLionel Sambuc operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value && 3394684ddb6SLionel Sambuc is_nothrow_move_assignable<second_type>::value) 3404684ddb6SLionel Sambuc { 3414684ddb6SLionel Sambuc first = _VSTD::forward<first_type>(__p.first); 3424684ddb6SLionel Sambuc second = _VSTD::forward<second_type>(__p.second); 3434684ddb6SLionel Sambuc return *this; 3444684ddb6SLionel Sambuc } 3454684ddb6SLionel Sambuc 3464684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 3474684ddb6SLionel Sambuc 3484684ddb6SLionel Sambuc template<class _Tuple, 3494684ddb6SLionel Sambuc class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type> 3504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 3514684ddb6SLionel Sambuc pair(_Tuple&& __p) 3524684ddb6SLionel Sambuc : first(_VSTD::forward<typename tuple_element<0, 353*0a6a1f1dSLionel Sambuc typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))), 3544684ddb6SLionel Sambuc second(_VSTD::forward<typename tuple_element<1, 355*0a6a1f1dSLionel Sambuc typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p))) 3564684ddb6SLionel Sambuc {} 3574684ddb6SLionel Sambuc 3584684ddb6SLionel Sambuc 3594684ddb6SLionel Sambuc 3604684ddb6SLionel Sambuc template <class... _Args1, class... _Args2> 3614684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3624684ddb6SLionel Sambuc pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, 3634684ddb6SLionel Sambuc tuple<_Args2...> __second_args) 3644684ddb6SLionel Sambuc : pair(__pc, __first_args, __second_args, 3654684ddb6SLionel Sambuc typename __make_tuple_indices<sizeof...(_Args1)>::type(), 3664684ddb6SLionel Sambuc typename __make_tuple_indices<sizeof...(_Args2) >::type()) 3674684ddb6SLionel Sambuc {} 3684684ddb6SLionel Sambuc 3694684ddb6SLionel Sambuc template <class _Tuple, 3704684ddb6SLionel Sambuc class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type> 3714684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3724684ddb6SLionel Sambuc pair& 3734684ddb6SLionel Sambuc operator=(_Tuple&& __p) 3744684ddb6SLionel Sambuc { 3754684ddb6SLionel Sambuc typedef typename __make_tuple_types<_Tuple>::type _TupleRef; 3764684ddb6SLionel Sambuc typedef typename tuple_element<0, _TupleRef>::type _U0; 3774684ddb6SLionel Sambuc typedef typename tuple_element<1, _TupleRef>::type _U1; 3784684ddb6SLionel Sambuc first = _VSTD::forward<_U0>(_VSTD::get<0>(__p)); 3794684ddb6SLionel Sambuc second = _VSTD::forward<_U1>(_VSTD::get<1>(__p)); 3804684ddb6SLionel Sambuc return *this; 3814684ddb6SLionel Sambuc } 3824684ddb6SLionel Sambuc 3834684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 3844684ddb6SLionel Sambuc 3854684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 3864684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3874684ddb6SLionel Sambuc void 3884684ddb6SLionel Sambuc swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value && 3894684ddb6SLionel Sambuc __is_nothrow_swappable<second_type>::value) 3904684ddb6SLionel Sambuc { 3914684ddb6SLionel Sambuc _VSTD::iter_swap(&first, &__p.first); 3924684ddb6SLionel Sambuc _VSTD::iter_swap(&second, &__p.second); 3934684ddb6SLionel Sambuc } 3944684ddb6SLionel Sambucprivate: 3954684ddb6SLionel Sambuc 3964684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_VARIADICS 3974684ddb6SLionel Sambuc template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 3984684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 3994684ddb6SLionel Sambuc pair(piecewise_construct_t, 4004684ddb6SLionel Sambuc tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, 4014684ddb6SLionel Sambuc __tuple_indices<_I1...>, __tuple_indices<_I2...>); 4024684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_VARIADICS 4034684ddb6SLionel Sambuc}; 4044684ddb6SLionel Sambuc 4054684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4064684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4074684ddb6SLionel Sambucbool 4084684ddb6SLionel Sambucoperator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4094684ddb6SLionel Sambuc{ 4104684ddb6SLionel Sambuc return __x.first == __y.first && __x.second == __y.second; 4114684ddb6SLionel Sambuc} 4124684ddb6SLionel Sambuc 4134684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4144684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4154684ddb6SLionel Sambucbool 4164684ddb6SLionel Sambucoperator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4174684ddb6SLionel Sambuc{ 4184684ddb6SLionel Sambuc return !(__x == __y); 4194684ddb6SLionel Sambuc} 4204684ddb6SLionel Sambuc 4214684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4234684ddb6SLionel Sambucbool 4244684ddb6SLionel Sambucoperator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4254684ddb6SLionel Sambuc{ 4264684ddb6SLionel Sambuc return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second); 4274684ddb6SLionel Sambuc} 4284684ddb6SLionel Sambuc 4294684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4314684ddb6SLionel Sambucbool 4324684ddb6SLionel Sambucoperator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4334684ddb6SLionel Sambuc{ 4344684ddb6SLionel Sambuc return __y < __x; 4354684ddb6SLionel Sambuc} 4364684ddb6SLionel Sambuc 4374684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4394684ddb6SLionel Sambucbool 4404684ddb6SLionel Sambucoperator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4414684ddb6SLionel Sambuc{ 4424684ddb6SLionel Sambuc return !(__x < __y); 4434684ddb6SLionel Sambuc} 4444684ddb6SLionel Sambuc 4454684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4474684ddb6SLionel Sambucbool 4484684ddb6SLionel Sambucoperator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 4494684ddb6SLionel Sambuc{ 4504684ddb6SLionel Sambuc return !(__y < __x); 4514684ddb6SLionel Sambuc} 4524684ddb6SLionel Sambuc 4534684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4544684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4554684ddb6SLionel Sambuctypename enable_if 4564684ddb6SLionel Sambuc< 4574684ddb6SLionel Sambuc __is_swappable<_T1>::value && 4584684ddb6SLionel Sambuc __is_swappable<_T2>::value, 4594684ddb6SLionel Sambuc void 4604684ddb6SLionel Sambuc>::type 4614684ddb6SLionel Sambucswap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) 4624684ddb6SLionel Sambuc _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && 4634684ddb6SLionel Sambuc __is_nothrow_swappable<_T2>::value)) 4644684ddb6SLionel Sambuc{ 4654684ddb6SLionel Sambuc __x.swap(__y); 4664684ddb6SLionel Sambuc} 4674684ddb6SLionel Sambuc 4684684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 4694684ddb6SLionel Sambuc 4704684ddb6SLionel Sambuctemplate <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; 4714684ddb6SLionel Sambuc 4724684ddb6SLionel Sambuctemplate <class _Tp> 473*0a6a1f1dSLionel Sambucstruct __make_pair_return_impl 4744684ddb6SLionel Sambuc{ 4754684ddb6SLionel Sambuc typedef _Tp type; 4764684ddb6SLionel Sambuc}; 4774684ddb6SLionel Sambuc 4784684ddb6SLionel Sambuctemplate <class _Tp> 479*0a6a1f1dSLionel Sambucstruct __make_pair_return_impl<reference_wrapper<_Tp>> 4804684ddb6SLionel Sambuc{ 4814684ddb6SLionel Sambuc typedef _Tp& type; 4824684ddb6SLionel Sambuc}; 4834684ddb6SLionel Sambuc 4844684ddb6SLionel Sambuctemplate <class _Tp> 4854684ddb6SLionel Sambucstruct __make_pair_return 4864684ddb6SLionel Sambuc{ 487*0a6a1f1dSLionel Sambuc typedef typename __make_pair_return_impl<typename decay<_Tp>::type>::type type; 4884684ddb6SLionel Sambuc}; 4894684ddb6SLionel Sambuc 4904684ddb6SLionel Sambuctemplate <class _T1, class _T2> 4914684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4924684ddb6SLionel Sambucpair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type> 4934684ddb6SLionel Sambucmake_pair(_T1&& __t1, _T2&& __t2) 4944684ddb6SLionel Sambuc{ 4954684ddb6SLionel Sambuc return pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type> 4964684ddb6SLionel Sambuc (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2)); 4974684ddb6SLionel Sambuc} 4984684ddb6SLionel Sambuc 4994684ddb6SLionel Sambuc#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5004684ddb6SLionel Sambuc 5014684ddb6SLionel Sambuctemplate <class _T1, class _T2> 5024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5034684ddb6SLionel Sambucpair<_T1,_T2> 5044684ddb6SLionel Sambucmake_pair(_T1 __x, _T2 __y) 5054684ddb6SLionel Sambuc{ 5064684ddb6SLionel Sambuc return pair<_T1, _T2>(__x, __y); 5074684ddb6SLionel Sambuc} 5084684ddb6SLionel Sambuc 5094684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5104684ddb6SLionel Sambuc 5114684ddb6SLionel Sambuctemplate <class _T1, class _T2> 5124684ddb6SLionel Sambuc class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> > 5134684ddb6SLionel Sambuc : public integral_constant<size_t, 2> {}; 5144684ddb6SLionel Sambuc 5154684ddb6SLionel Sambuctemplate <class _T1, class _T2> 5164684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> > 5174684ddb6SLionel Sambuc{ 5184684ddb6SLionel Sambucpublic: 5194684ddb6SLionel Sambuc typedef _T1 type; 5204684ddb6SLionel Sambuc}; 5214684ddb6SLionel Sambuc 5224684ddb6SLionel Sambuctemplate <class _T1, class _T2> 5234684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> > 5244684ddb6SLionel Sambuc{ 5254684ddb6SLionel Sambucpublic: 5264684ddb6SLionel Sambuc typedef _T2 type; 5274684ddb6SLionel Sambuc}; 5284684ddb6SLionel Sambuc 5294684ddb6SLionel Sambuctemplate <size_t _Ip> struct __get_pair; 5304684ddb6SLionel Sambuc 5314684ddb6SLionel Sambuctemplate <> 5324684ddb6SLionel Sambucstruct __get_pair<0> 5334684ddb6SLionel Sambuc{ 5344684ddb6SLionel Sambuc template <class _T1, class _T2> 5354684ddb6SLionel Sambuc static 5364684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5374684ddb6SLionel Sambuc _T1& 5384684ddb6SLionel Sambuc get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 5394684ddb6SLionel Sambuc 5404684ddb6SLionel Sambuc template <class _T1, class _T2> 5414684ddb6SLionel Sambuc static 5424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5434684ddb6SLionel Sambuc const _T1& 5444684ddb6SLionel Sambuc get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 5454684ddb6SLionel Sambuc 5464684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5474684ddb6SLionel Sambuc 5484684ddb6SLionel Sambuc template <class _T1, class _T2> 5494684ddb6SLionel Sambuc static 5504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5514684ddb6SLionel Sambuc _T1&& 5524684ddb6SLionel Sambuc get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} 5534684ddb6SLionel Sambuc 5544684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5554684ddb6SLionel Sambuc}; 5564684ddb6SLionel Sambuc 5574684ddb6SLionel Sambuctemplate <> 5584684ddb6SLionel Sambucstruct __get_pair<1> 5594684ddb6SLionel Sambuc{ 5604684ddb6SLionel Sambuc template <class _T1, class _T2> 5614684ddb6SLionel Sambuc static 5624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5634684ddb6SLionel Sambuc _T2& 5644684ddb6SLionel Sambuc get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 5654684ddb6SLionel Sambuc 5664684ddb6SLionel Sambuc template <class _T1, class _T2> 5674684ddb6SLionel Sambuc static 5684684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5694684ddb6SLionel Sambuc const _T2& 5704684ddb6SLionel Sambuc get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 5714684ddb6SLionel Sambuc 5724684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 5734684ddb6SLionel Sambuc 5744684ddb6SLionel Sambuc template <class _T1, class _T2> 5754684ddb6SLionel Sambuc static 5764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5774684ddb6SLionel Sambuc _T2&& 5784684ddb6SLionel Sambuc get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} 5794684ddb6SLionel Sambuc 5804684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 5814684ddb6SLionel Sambuc}; 5824684ddb6SLionel Sambuc 5834684ddb6SLionel Sambuctemplate <size_t _Ip, class _T1, class _T2> 5844684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5854684ddb6SLionel Sambuctypename tuple_element<_Ip, pair<_T1, _T2> >::type& 5864684ddb6SLionel Sambucget(pair<_T1, _T2>& __p) _NOEXCEPT 5874684ddb6SLionel Sambuc{ 5884684ddb6SLionel Sambuc return __get_pair<_Ip>::get(__p); 5894684ddb6SLionel Sambuc} 5904684ddb6SLionel Sambuc 5914684ddb6SLionel Sambuctemplate <size_t _Ip, class _T1, class _T2> 5924684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 5934684ddb6SLionel Sambucconst typename tuple_element<_Ip, pair<_T1, _T2> >::type& 5944684ddb6SLionel Sambucget(const pair<_T1, _T2>& __p) _NOEXCEPT 5954684ddb6SLionel Sambuc{ 5964684ddb6SLionel Sambuc return __get_pair<_Ip>::get(__p); 5974684ddb6SLionel Sambuc} 5984684ddb6SLionel Sambuc 5994684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 6004684ddb6SLionel Sambuc 6014684ddb6SLionel Sambuctemplate <size_t _Ip, class _T1, class _T2> 6024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 6034684ddb6SLionel Sambuctypename tuple_element<_Ip, pair<_T1, _T2> >::type&& 6044684ddb6SLionel Sambucget(pair<_T1, _T2>&& __p) _NOEXCEPT 6054684ddb6SLionel Sambuc{ 6064684ddb6SLionel Sambuc return __get_pair<_Ip>::get(_VSTD::move(__p)); 6074684ddb6SLionel Sambuc} 6084684ddb6SLionel Sambuc 6094684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 6104684ddb6SLionel Sambuc 6114684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 6124684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6134684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6144684ddb6SLionel Sambucconstexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT 6154684ddb6SLionel Sambuc{ 6164684ddb6SLionel Sambuc return __get_pair<0>::get(__p); 6174684ddb6SLionel Sambuc} 6184684ddb6SLionel Sambuc 6194684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6204684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6214684ddb6SLionel Sambucconstexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT 6224684ddb6SLionel Sambuc{ 6234684ddb6SLionel Sambuc return __get_pair<0>::get(__p); 6244684ddb6SLionel Sambuc} 6254684ddb6SLionel Sambuc 6264684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6274684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6284684ddb6SLionel Sambucconstexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT 6294684ddb6SLionel Sambuc{ 6304684ddb6SLionel Sambuc return __get_pair<0>::get(_VSTD::move(__p)); 6314684ddb6SLionel Sambuc} 6324684ddb6SLionel Sambuc 6334684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6344684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6354684ddb6SLionel Sambucconstexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT 6364684ddb6SLionel Sambuc{ 6374684ddb6SLionel Sambuc return __get_pair<1>::get(__p); 6384684ddb6SLionel Sambuc} 6394684ddb6SLionel Sambuc 6404684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6424684ddb6SLionel Sambucconstexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT 6434684ddb6SLionel Sambuc{ 6444684ddb6SLionel Sambuc return __get_pair<1>::get(__p); 6454684ddb6SLionel Sambuc} 6464684ddb6SLionel Sambuc 6474684ddb6SLionel Sambuctemplate <class _T1, class _T2> 6484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6494684ddb6SLionel Sambucconstexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT 6504684ddb6SLionel Sambuc{ 6514684ddb6SLionel Sambuc return __get_pair<1>::get(_VSTD::move(__p)); 6524684ddb6SLionel Sambuc} 6534684ddb6SLionel Sambuc 6544684ddb6SLionel Sambuc#endif 6554684ddb6SLionel Sambuc 6564684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 6574684ddb6SLionel Sambuc 6584684ddb6SLionel Sambuctemplate<class _Tp, _Tp... _Ip> 6594684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY integer_sequence 6604684ddb6SLionel Sambuc{ 6614684ddb6SLionel Sambuc typedef _Tp value_type; 6624684ddb6SLionel Sambuc static_assert( is_integral<_Tp>::value, 6634684ddb6SLionel Sambuc "std::integer_sequence can only be instantiated with an integral type" ); 6644684ddb6SLionel Sambuc static 6654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 6664684ddb6SLionel Sambuc constexpr 6674684ddb6SLionel Sambuc size_t 6684684ddb6SLionel Sambuc size() noexcept { return sizeof...(_Ip); } 6694684ddb6SLionel Sambuc}; 6704684ddb6SLionel Sambuc 6714684ddb6SLionel Sambuctemplate<size_t... _Ip> 6724684ddb6SLionel Sambuc using index_sequence = integer_sequence<size_t, _Ip...>; 6734684ddb6SLionel Sambuc 6744684ddb6SLionel Sambucnamespace __detail { 6754684ddb6SLionel Sambuc 6764684ddb6SLionel Sambuctemplate<typename _Tp, size_t ..._Extra> struct __repeat; 6774684ddb6SLionel Sambuctemplate<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<integer_sequence<_Tp, _Np...>, _Extra...> { 6784684ddb6SLionel Sambuc typedef integer_sequence<_Tp, 6794684ddb6SLionel Sambuc _Np..., 6804684ddb6SLionel Sambuc sizeof...(_Np) + _Np..., 6814684ddb6SLionel Sambuc 2 * sizeof...(_Np) + _Np..., 6824684ddb6SLionel Sambuc 3 * sizeof...(_Np) + _Np..., 6834684ddb6SLionel Sambuc 4 * sizeof...(_Np) + _Np..., 6844684ddb6SLionel Sambuc 5 * sizeof...(_Np) + _Np..., 6854684ddb6SLionel Sambuc 6 * sizeof...(_Np) + _Np..., 6864684ddb6SLionel Sambuc 7 * sizeof...(_Np) + _Np..., 6874684ddb6SLionel Sambuc _Extra...> type; 6884684ddb6SLionel Sambuc}; 6894684ddb6SLionel Sambuc 6904684ddb6SLionel Sambuctemplate<size_t _Np> struct __parity; 6914684ddb6SLionel Sambuctemplate<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {}; 6924684ddb6SLionel Sambuc 6934684ddb6SLionel Sambuctemplate<> struct __make<0> { typedef integer_sequence<size_t> type; }; 6944684ddb6SLionel Sambuctemplate<> struct __make<1> { typedef integer_sequence<size_t, 0> type; }; 6954684ddb6SLionel Sambuctemplate<> struct __make<2> { typedef integer_sequence<size_t, 0, 1> type; }; 6964684ddb6SLionel Sambuctemplate<> struct __make<3> { typedef integer_sequence<size_t, 0, 1, 2> type; }; 6974684ddb6SLionel Sambuctemplate<> struct __make<4> { typedef integer_sequence<size_t, 0, 1, 2, 3> type; }; 6984684ddb6SLionel Sambuctemplate<> struct __make<5> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4> type; }; 6994684ddb6SLionel Sambuctemplate<> struct __make<6> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; }; 7004684ddb6SLionel Sambuctemplate<> struct __make<7> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; }; 7014684ddb6SLionel Sambuc 7024684ddb6SLionel Sambuctemplate<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; }; 7034684ddb6SLionel Sambuctemplate<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; }; 7044684ddb6SLionel Sambuctemplate<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; }; 7054684ddb6SLionel Sambuctemplate<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; }; 7064684ddb6SLionel Sambuctemplate<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; 7074684ddb6SLionel Sambuctemplate<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; 7084684ddb6SLionel Sambuctemplate<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; 7094684ddb6SLionel Sambuctemplate<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; 7104684ddb6SLionel Sambuc 7114684ddb6SLionel Sambuctemplate<typename _Tp, typename _Up> struct __convert { 7124684ddb6SLionel Sambuc template<typename> struct __result; 7134684ddb6SLionel Sambuc template<_Tp ..._Np> struct __result<integer_sequence<_Tp, _Np...> > { typedef integer_sequence<_Up, _Np...> type; }; 7144684ddb6SLionel Sambuc}; 7154684ddb6SLionel Sambuctemplate<typename _Tp> struct __convert<_Tp, _Tp> { template<typename _Up> struct __result { typedef _Up type; }; }; 7164684ddb6SLionel Sambuc 7174684ddb6SLionel Sambuc} 7184684ddb6SLionel Sambuc 7194684ddb6SLionel Sambuctemplate<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked = 7204684ddb6SLionel Sambuc typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type; 7214684ddb6SLionel Sambuc 7224684ddb6SLionel Sambuctemplate <class _Tp, _Tp _Ep> 7234684ddb6SLionel Sambucstruct __make_integer_sequence 7244684ddb6SLionel Sambuc{ 7254684ddb6SLionel Sambuc static_assert(is_integral<_Tp>::value, 7264684ddb6SLionel Sambuc "std::make_integer_sequence can only be instantiated with an integral type" ); 7274684ddb6SLionel Sambuc static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative"); 7284684ddb6SLionel Sambuc typedef __make_integer_sequence_unchecked<_Tp, _Ep> type; 7294684ddb6SLionel Sambuc}; 7304684ddb6SLionel Sambuc 7314684ddb6SLionel Sambuctemplate<class _Tp, _Tp _Np> 7324684ddb6SLionel Sambuc using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type; 7334684ddb6SLionel Sambuc 7344684ddb6SLionel Sambuctemplate<size_t _Np> 7354684ddb6SLionel Sambuc using make_index_sequence = make_integer_sequence<size_t, _Np>; 7364684ddb6SLionel Sambuc 7374684ddb6SLionel Sambuctemplate<class... _Tp> 7384684ddb6SLionel Sambuc using index_sequence_for = make_index_sequence<sizeof...(_Tp)>; 7394684ddb6SLionel Sambuc 7404684ddb6SLionel Sambuc#endif // _LIBCPP_STD_VER > 11 7414684ddb6SLionel Sambuc 7424684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 7434684ddb6SLionel Sambuctemplate<class _T1, class _T2 = _T1> 7444684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7454684ddb6SLionel Sambuc_T1 exchange(_T1& __obj, _T2 && __new_value) 7464684ddb6SLionel Sambuc{ 7474684ddb6SLionel Sambuc _T1 __old_value = _VSTD::move(__obj); 7484684ddb6SLionel Sambuc __obj = _VSTD::forward<_T2>(__new_value); 7494684ddb6SLionel Sambuc return __old_value; 7504684ddb6SLionel Sambuc} 7514684ddb6SLionel Sambuc#endif // _LIBCPP_STD_VER > 11 7524684ddb6SLionel Sambuc 7534684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 7544684ddb6SLionel Sambuc 7554684ddb6SLionel Sambuc#endif // _LIBCPP_UTILITY 756