1*0b57cec5SDimitry Andric// -*- C++ -*- 2*0b57cec5SDimitry Andric//===-------------------------- utility -----------------------------------===// 3*0b57cec5SDimitry Andric// 4*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*0b57cec5SDimitry Andric// 8*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 9*0b57cec5SDimitry Andric 10*0b57cec5SDimitry Andric#ifndef _LIBCPP_UTILITY 11*0b57cec5SDimitry Andric#define _LIBCPP_UTILITY 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric/* 14*0b57cec5SDimitry Andric utility synopsis 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric#include <initializer_list> 17*0b57cec5SDimitry Andric 18*0b57cec5SDimitry Andricnamespace std 19*0b57cec5SDimitry Andric{ 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andrictemplate <class T> 22*0b57cec5SDimitry Andric void 23*0b57cec5SDimitry Andric swap(T& a, T& b); 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andricnamespace rel_ops 26*0b57cec5SDimitry Andric{ 27*0b57cec5SDimitry Andric template<class T> bool operator!=(const T&, const T&); 28*0b57cec5SDimitry Andric template<class T> bool operator> (const T&, const T&); 29*0b57cec5SDimitry Andric template<class T> bool operator<=(const T&, const T&); 30*0b57cec5SDimitry Andric template<class T> bool operator>=(const T&, const T&); 31*0b57cec5SDimitry Andric} 32*0b57cec5SDimitry Andric 33*0b57cec5SDimitry Andrictemplate<class T> 34*0b57cec5SDimitry Andricvoid 35*0b57cec5SDimitry Andricswap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value && 36*0b57cec5SDimitry Andric is_nothrow_move_assignable<T>::value); 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andrictemplate <class T, size_t N> 39*0b57cec5SDimitry Andricvoid 40*0b57cec5SDimitry Andricswap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b))); 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andrictemplate <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14 43*0b57cec5SDimitry Andrictemplate <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14 44*0b57cec5SDimitry Andric 45*0b57cec5SDimitry Andrictemplate <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14 46*0b57cec5SDimitry Andric 47*0b57cec5SDimitry Andrictemplate <class T> 48*0b57cec5SDimitry Andric typename conditional 49*0b57cec5SDimitry Andric < 50*0b57cec5SDimitry Andric !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value, 51*0b57cec5SDimitry Andric const T&, 52*0b57cec5SDimitry Andric T&& 53*0b57cec5SDimitry Andric >::type 54*0b57cec5SDimitry Andric move_if_noexcept(T& x) noexcept; // constexpr in C++14 55*0b57cec5SDimitry Andric 56*0b57cec5SDimitry Andrictemplate <class T> constexpr add_const_t<T>& as_const(T& t) noexcept; // C++17 57*0b57cec5SDimitry Andrictemplate <class T> void as_const(const T&&) = delete; // C++17 58*0b57cec5SDimitry Andric 59*0b57cec5SDimitry Andrictemplate <class T> typename add_rvalue_reference<T>::type declval() noexcept; 60*0b57cec5SDimitry Andric 61*0b57cec5SDimitry Andrictemplate <class T1, class T2> 62*0b57cec5SDimitry Andricstruct pair 63*0b57cec5SDimitry Andric{ 64*0b57cec5SDimitry Andric typedef T1 first_type; 65*0b57cec5SDimitry Andric typedef T2 second_type; 66*0b57cec5SDimitry Andric 67*0b57cec5SDimitry Andric T1 first; 68*0b57cec5SDimitry Andric T2 second; 69*0b57cec5SDimitry Andric 70*0b57cec5SDimitry Andric pair(const pair&) = default; 71*0b57cec5SDimitry Andric pair(pair&&) = default; 72*0b57cec5SDimitry Andric constexpr pair(); 73*0b57cec5SDimitry Andric pair(const T1& x, const T2& y); // constexpr in C++14 74*0b57cec5SDimitry Andric template <class U, class V> pair(U&& x, V&& y); // constexpr in C++14 75*0b57cec5SDimitry Andric template <class U, class V> pair(const pair<U, V>& p); // constexpr in C++14 76*0b57cec5SDimitry Andric template <class U, class V> pair(pair<U, V>&& p); // constexpr in C++14 77*0b57cec5SDimitry Andric template <class... Args1, class... Args2> 78*0b57cec5SDimitry Andric pair(piecewise_construct_t, tuple<Args1...> first_args, 79*0b57cec5SDimitry Andric tuple<Args2...> second_args); 80*0b57cec5SDimitry Andric 81*0b57cec5SDimitry Andric template <class U, class V> pair& operator=(const pair<U, V>& p); 82*0b57cec5SDimitry Andric pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value && 83*0b57cec5SDimitry Andric is_nothrow_move_assignable<T2>::value); 84*0b57cec5SDimitry Andric template <class U, class V> pair& operator=(pair<U, V>&& p); 85*0b57cec5SDimitry Andric 86*0b57cec5SDimitry Andric void swap(pair& p) noexcept(is_nothrow_swappable_v<T1> && 87*0b57cec5SDimitry Andric is_nothrow_swappable_v<T2>); 88*0b57cec5SDimitry Andric}; 89*0b57cec5SDimitry Andric 90*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 91*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 92*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 93*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 94*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 95*0b57cec5SDimitry Andrictemplate <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 96*0b57cec5SDimitry Andric 97*0b57cec5SDimitry Andrictemplate <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14 98*0b57cec5SDimitry Andrictemplate <class T1, class T2> 99*0b57cec5SDimitry Andricvoid 100*0b57cec5SDimitry Andricswap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); 101*0b57cec5SDimitry Andric 102*0b57cec5SDimitry Andricstruct piecewise_construct_t { }; 103*0b57cec5SDimitry Andricinline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); 104*0b57cec5SDimitry Andric 105*0b57cec5SDimitry Andrictemplate <class T> struct tuple_size; 106*0b57cec5SDimitry Andrictemplate <size_t I, class T> struct tuple_element; 107*0b57cec5SDimitry Andric 108*0b57cec5SDimitry Andrictemplate <class T1, class T2> struct tuple_size<pair<T1, T2> >; 109*0b57cec5SDimitry Andrictemplate <class T1, class T2> struct tuple_element<0, pair<T1, T2> >; 110*0b57cec5SDimitry Andrictemplate <class T1, class T2> struct tuple_element<1, pair<T1, T2> >; 111*0b57cec5SDimitry Andric 112*0b57cec5SDimitry Andrictemplate<size_t I, class T1, class T2> 113*0b57cec5SDimitry Andric typename tuple_element<I, pair<T1, T2> >::type& 114*0b57cec5SDimitry Andric get(pair<T1, T2>&) noexcept; // constexpr in C++14 115*0b57cec5SDimitry Andric 116*0b57cec5SDimitry Andrictemplate<size_t I, class T1, class T2> 117*0b57cec5SDimitry Andric const typename tuple_element<I, pair<T1, T2> >::type& 118*0b57cec5SDimitry Andric get(const pair<T1, T2>&) noexcept; // constexpr in C++14 119*0b57cec5SDimitry Andric 120*0b57cec5SDimitry Andrictemplate<size_t I, class T1, class T2> 121*0b57cec5SDimitry Andric typename tuple_element<I, pair<T1, T2> >::type&& 122*0b57cec5SDimitry Andric get(pair<T1, T2>&&) noexcept; // constexpr in C++14 123*0b57cec5SDimitry Andric 124*0b57cec5SDimitry Andrictemplate<size_t I, class T1, class T2> 125*0b57cec5SDimitry Andric const typename tuple_element<I, pair<T1, T2> >::type&& 126*0b57cec5SDimitry Andric get(const pair<T1, T2>&&) noexcept; // constexpr in C++14 127*0b57cec5SDimitry Andric 128*0b57cec5SDimitry Andrictemplate<class T1, class T2> 129*0b57cec5SDimitry Andric constexpr T1& get(pair<T1, T2>&) noexcept; // C++14 130*0b57cec5SDimitry Andric 131*0b57cec5SDimitry Andrictemplate<class T1, class T2> 132*0b57cec5SDimitry Andric constexpr const T1& get(const pair<T1, T2>&) noexcept; // C++14 133*0b57cec5SDimitry Andric 134*0b57cec5SDimitry Andrictemplate<class T1, class T2> 135*0b57cec5SDimitry Andric constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14 136*0b57cec5SDimitry Andric 137*0b57cec5SDimitry Andrictemplate<class T1, class T2> 138*0b57cec5SDimitry Andric constexpr const T1&& get(const pair<T1, T2>&&) noexcept; // C++14 139*0b57cec5SDimitry Andric 140*0b57cec5SDimitry Andrictemplate<class T1, class T2> 141*0b57cec5SDimitry Andric constexpr T1& get(pair<T2, T1>&) noexcept; // C++14 142*0b57cec5SDimitry Andric 143*0b57cec5SDimitry Andrictemplate<class T1, class T2> 144*0b57cec5SDimitry Andric constexpr const T1& get(const pair<T2, T1>&) noexcept; // C++14 145*0b57cec5SDimitry Andric 146*0b57cec5SDimitry Andrictemplate<class T1, class T2> 147*0b57cec5SDimitry Andric constexpr T1&& get(pair<T2, T1>&&) noexcept; // C++14 148*0b57cec5SDimitry Andric 149*0b57cec5SDimitry Andrictemplate<class T1, class T2> 150*0b57cec5SDimitry Andric constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14 151*0b57cec5SDimitry Andric 152*0b57cec5SDimitry Andric// C++14 153*0b57cec5SDimitry Andric 154*0b57cec5SDimitry Andrictemplate<class T, T... I> 155*0b57cec5SDimitry Andricstruct integer_sequence 156*0b57cec5SDimitry Andric{ 157*0b57cec5SDimitry Andric typedef T value_type; 158*0b57cec5SDimitry Andric 159*0b57cec5SDimitry Andric static constexpr size_t size() noexcept; 160*0b57cec5SDimitry Andric}; 161*0b57cec5SDimitry Andric 162*0b57cec5SDimitry Andrictemplate<size_t... I> 163*0b57cec5SDimitry Andric using index_sequence = integer_sequence<size_t, I...>; 164*0b57cec5SDimitry Andric 165*0b57cec5SDimitry Andrictemplate<class T, T N> 166*0b57cec5SDimitry Andric using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>; 167*0b57cec5SDimitry Andrictemplate<size_t N> 168*0b57cec5SDimitry Andric using make_index_sequence = make_integer_sequence<size_t, N>; 169*0b57cec5SDimitry Andric 170*0b57cec5SDimitry Andrictemplate<class... T> 171*0b57cec5SDimitry Andric using index_sequence_for = make_index_sequence<sizeof...(T)>; 172*0b57cec5SDimitry Andric 173*0b57cec5SDimitry Andrictemplate<class T, class U=T> 174*0b57cec5SDimitry Andric T exchange(T& obj, U&& new_value); 175*0b57cec5SDimitry Andric 176*0b57cec5SDimitry Andric// 20.2.7, in-place construction // C++17 177*0b57cec5SDimitry Andricstruct in_place_t { 178*0b57cec5SDimitry Andric explicit in_place_t() = default; 179*0b57cec5SDimitry Andric}; 180*0b57cec5SDimitry Andricinline constexpr in_place_t in_place{}; 181*0b57cec5SDimitry Andrictemplate <class T> 182*0b57cec5SDimitry Andric struct in_place_type_t { 183*0b57cec5SDimitry Andric explicit in_place_type_t() = default; 184*0b57cec5SDimitry Andric }; 185*0b57cec5SDimitry Andrictemplate <class T> 186*0b57cec5SDimitry Andric inline constexpr in_place_type_t<T> in_place_type{}; 187*0b57cec5SDimitry Andrictemplate <size_t I> 188*0b57cec5SDimitry Andric struct in_place_index_t { 189*0b57cec5SDimitry Andric explicit in_place_index_t() = default; 190*0b57cec5SDimitry Andric }; 191*0b57cec5SDimitry Andrictemplate <size_t I> 192*0b57cec5SDimitry Andric inline constexpr in_place_index_t<I> in_place_index{}; 193*0b57cec5SDimitry Andric 194*0b57cec5SDimitry Andric} // std 195*0b57cec5SDimitry Andric 196*0b57cec5SDimitry Andric*/ 197*0b57cec5SDimitry Andric 198*0b57cec5SDimitry Andric#include <__config> 199*0b57cec5SDimitry Andric#include <__tuple> 200*0b57cec5SDimitry Andric#include <type_traits> 201*0b57cec5SDimitry Andric#include <initializer_list> 202*0b57cec5SDimitry Andric#include <cstddef> 203*0b57cec5SDimitry Andric#include <cstring> 204*0b57cec5SDimitry Andric#include <cstdint> 205*0b57cec5SDimitry Andric#include <version> 206*0b57cec5SDimitry Andric#include <__debug> 207*0b57cec5SDimitry Andric 208*0b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 209*0b57cec5SDimitry Andric#pragma GCC system_header 210*0b57cec5SDimitry Andric#endif 211*0b57cec5SDimitry Andric 212*0b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 213*0b57cec5SDimitry Andric 214*0b57cec5SDimitry Andricnamespace rel_ops 215*0b57cec5SDimitry Andric{ 216*0b57cec5SDimitry Andric 217*0b57cec5SDimitry Andrictemplate<class _Tp> 218*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 219*0b57cec5SDimitry Andricbool 220*0b57cec5SDimitry Andricoperator!=(const _Tp& __x, const _Tp& __y) 221*0b57cec5SDimitry Andric{ 222*0b57cec5SDimitry Andric return !(__x == __y); 223*0b57cec5SDimitry Andric} 224*0b57cec5SDimitry Andric 225*0b57cec5SDimitry Andrictemplate<class _Tp> 226*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 227*0b57cec5SDimitry Andricbool 228*0b57cec5SDimitry Andricoperator> (const _Tp& __x, const _Tp& __y) 229*0b57cec5SDimitry Andric{ 230*0b57cec5SDimitry Andric return __y < __x; 231*0b57cec5SDimitry Andric} 232*0b57cec5SDimitry Andric 233*0b57cec5SDimitry Andrictemplate<class _Tp> 234*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 235*0b57cec5SDimitry Andricbool 236*0b57cec5SDimitry Andricoperator<=(const _Tp& __x, const _Tp& __y) 237*0b57cec5SDimitry Andric{ 238*0b57cec5SDimitry Andric return !(__y < __x); 239*0b57cec5SDimitry Andric} 240*0b57cec5SDimitry Andric 241*0b57cec5SDimitry Andrictemplate<class _Tp> 242*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 243*0b57cec5SDimitry Andricbool 244*0b57cec5SDimitry Andricoperator>=(const _Tp& __x, const _Tp& __y) 245*0b57cec5SDimitry Andric{ 246*0b57cec5SDimitry Andric return !(__x < __y); 247*0b57cec5SDimitry Andric} 248*0b57cec5SDimitry Andric 249*0b57cec5SDimitry Andric} // rel_ops 250*0b57cec5SDimitry Andric 251*0b57cec5SDimitry Andric// swap_ranges 252*0b57cec5SDimitry Andric 253*0b57cec5SDimitry Andric 254*0b57cec5SDimitry Andrictemplate <class _ForwardIterator1, class _ForwardIterator2> 255*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 256*0b57cec5SDimitry Andric_ForwardIterator2 257*0b57cec5SDimitry Andricswap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) 258*0b57cec5SDimitry Andric{ 259*0b57cec5SDimitry Andric for(; __first1 != __last1; ++__first1, (void) ++__first2) 260*0b57cec5SDimitry Andric swap(*__first1, *__first2); 261*0b57cec5SDimitry Andric return __first2; 262*0b57cec5SDimitry Andric} 263*0b57cec5SDimitry Andric 264*0b57cec5SDimitry Andric// forward declared in <type_traits> 265*0b57cec5SDimitry Andrictemplate<class _Tp, size_t _Np> 266*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 267*0b57cec5SDimitry Andrictypename enable_if< 268*0b57cec5SDimitry Andric __is_swappable<_Tp>::value 269*0b57cec5SDimitry Andric>::type 270*0b57cec5SDimitry Andricswap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) 271*0b57cec5SDimitry Andric{ 272*0b57cec5SDimitry Andric _VSTD::swap_ranges(__a, __a + _Np, __b); 273*0b57cec5SDimitry Andric} 274*0b57cec5SDimitry Andric 275*0b57cec5SDimitry Andrictemplate <class _Tp> 276*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 277*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 278*0b57cec5SDimitry Andrictypename conditional 279*0b57cec5SDimitry Andric< 280*0b57cec5SDimitry Andric !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, 281*0b57cec5SDimitry Andric const _Tp&, 282*0b57cec5SDimitry Andric _Tp&& 283*0b57cec5SDimitry Andric>::type 284*0b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG 285*0b57cec5SDimitry Andricconst _Tp& 286*0b57cec5SDimitry Andric#endif 287*0b57cec5SDimitry Andricmove_if_noexcept(_Tp& __x) _NOEXCEPT 288*0b57cec5SDimitry Andric{ 289*0b57cec5SDimitry Andric return _VSTD::move(__x); 290*0b57cec5SDimitry Andric} 291*0b57cec5SDimitry Andric 292*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 293*0b57cec5SDimitry Andrictemplate <class _Tp> constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; } 294*0b57cec5SDimitry Andrictemplate <class _Tp> void as_const(const _Tp&&) = delete; 295*0b57cec5SDimitry Andric#endif 296*0b57cec5SDimitry Andric 297*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { }; 298*0b57cec5SDimitry Andric#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) 299*0b57cec5SDimitry Andricextern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); 300*0b57cec5SDimitry Andric#else 301*0b57cec5SDimitry Andric/* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); 302*0b57cec5SDimitry Andric#endif 303*0b57cec5SDimitry Andric 304*0b57cec5SDimitry Andric#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) 305*0b57cec5SDimitry Andrictemplate <class, class> 306*0b57cec5SDimitry Andricstruct __non_trivially_copyable_base { 307*0b57cec5SDimitry Andric _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY 308*0b57cec5SDimitry Andric __non_trivially_copyable_base() _NOEXCEPT {} 309*0b57cec5SDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 310*0b57cec5SDimitry Andric __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {} 311*0b57cec5SDimitry Andric}; 312*0b57cec5SDimitry Andric#endif 313*0b57cec5SDimitry Andric 314*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 315*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS pair 316*0b57cec5SDimitry Andric#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) 317*0b57cec5SDimitry Andric: private __non_trivially_copyable_base<_T1, _T2> 318*0b57cec5SDimitry Andric#endif 319*0b57cec5SDimitry Andric{ 320*0b57cec5SDimitry Andric typedef _T1 first_type; 321*0b57cec5SDimitry Andric typedef _T2 second_type; 322*0b57cec5SDimitry Andric 323*0b57cec5SDimitry Andric _T1 first; 324*0b57cec5SDimitry Andric _T2 second; 325*0b57cec5SDimitry Andric 326*0b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) 327*0b57cec5SDimitry Andric pair(pair const&) = default; 328*0b57cec5SDimitry Andric pair(pair&&) = default; 329*0b57cec5SDimitry Andric#else 330*0b57cec5SDimitry Andric // Use the implicitly declared copy constructor in C++03 331*0b57cec5SDimitry Andric#endif 332*0b57cec5SDimitry Andric 333*0b57cec5SDimitry Andric#ifdef _LIBCPP_CXX03_LANG 334*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 335*0b57cec5SDimitry Andric pair() : first(), second() {} 336*0b57cec5SDimitry Andric 337*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 338*0b57cec5SDimitry Andric pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {} 339*0b57cec5SDimitry Andric 340*0b57cec5SDimitry Andric template <class _U1, class _U2> 341*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 342*0b57cec5SDimitry Andric pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} 343*0b57cec5SDimitry Andric 344*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 345*0b57cec5SDimitry Andric pair& operator=(pair const& __p) { 346*0b57cec5SDimitry Andric first = __p.first; 347*0b57cec5SDimitry Andric second = __p.second; 348*0b57cec5SDimitry Andric return *this; 349*0b57cec5SDimitry Andric } 350*0b57cec5SDimitry Andric#else 351*0b57cec5SDimitry Andric template <bool _Val> 352*0b57cec5SDimitry Andric using _EnableB _LIBCPP_NODEBUG_TYPE = typename enable_if<_Val, bool>::type; 353*0b57cec5SDimitry Andric 354*0b57cec5SDimitry Andric struct _CheckArgs { 355*0b57cec5SDimitry Andric template <class _U1, class _U2> 356*0b57cec5SDimitry Andric static constexpr bool __enable_default() { 357*0b57cec5SDimitry Andric return is_default_constructible<_U1>::value 358*0b57cec5SDimitry Andric && is_default_constructible<_U2>::value; 359*0b57cec5SDimitry Andric } 360*0b57cec5SDimitry Andric 361*0b57cec5SDimitry Andric template <class _U1, class _U2> 362*0b57cec5SDimitry Andric static constexpr bool __enable_explicit() { 363*0b57cec5SDimitry Andric return is_constructible<first_type, _U1>::value 364*0b57cec5SDimitry Andric && is_constructible<second_type, _U2>::value 365*0b57cec5SDimitry Andric && (!is_convertible<_U1, first_type>::value 366*0b57cec5SDimitry Andric || !is_convertible<_U2, second_type>::value); 367*0b57cec5SDimitry Andric } 368*0b57cec5SDimitry Andric 369*0b57cec5SDimitry Andric template <class _U1, class _U2> 370*0b57cec5SDimitry Andric static constexpr bool __enable_implicit() { 371*0b57cec5SDimitry Andric return is_constructible<first_type, _U1>::value 372*0b57cec5SDimitry Andric && is_constructible<second_type, _U2>::value 373*0b57cec5SDimitry Andric && is_convertible<_U1, first_type>::value 374*0b57cec5SDimitry Andric && is_convertible<_U2, second_type>::value; 375*0b57cec5SDimitry Andric } 376*0b57cec5SDimitry Andric }; 377*0b57cec5SDimitry Andric 378*0b57cec5SDimitry Andric template <bool _MaybeEnable> 379*0b57cec5SDimitry Andric using _CheckArgsDep _LIBCPP_NODEBUG_TYPE = typename conditional< 380*0b57cec5SDimitry Andric _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; 381*0b57cec5SDimitry Andric 382*0b57cec5SDimitry Andric struct _CheckTupleLikeConstructor { 383*0b57cec5SDimitry Andric template <class _Tuple> 384*0b57cec5SDimitry Andric static constexpr bool __enable_implicit() { 385*0b57cec5SDimitry Andric return __tuple_convertible<_Tuple, pair>::value; 386*0b57cec5SDimitry Andric } 387*0b57cec5SDimitry Andric 388*0b57cec5SDimitry Andric template <class _Tuple> 389*0b57cec5SDimitry Andric static constexpr bool __enable_explicit() { 390*0b57cec5SDimitry Andric return __tuple_constructible<_Tuple, pair>::value 391*0b57cec5SDimitry Andric && !__tuple_convertible<_Tuple, pair>::value; 392*0b57cec5SDimitry Andric } 393*0b57cec5SDimitry Andric 394*0b57cec5SDimitry Andric template <class _Tuple> 395*0b57cec5SDimitry Andric static constexpr bool __enable_assign() { 396*0b57cec5SDimitry Andric return __tuple_assignable<_Tuple, pair>::value; 397*0b57cec5SDimitry Andric } 398*0b57cec5SDimitry Andric }; 399*0b57cec5SDimitry Andric 400*0b57cec5SDimitry Andric template <class _Tuple> 401*0b57cec5SDimitry Andric using _CheckTLC _LIBCPP_NODEBUG_TYPE = typename conditional< 402*0b57cec5SDimitry Andric __tuple_like_with_size<_Tuple, 2>::value 403*0b57cec5SDimitry Andric && !is_same<typename decay<_Tuple>::type, pair>::value, 404*0b57cec5SDimitry Andric _CheckTupleLikeConstructor, 405*0b57cec5SDimitry Andric __check_tuple_constructor_fail 406*0b57cec5SDimitry Andric >::type; 407*0b57cec5SDimitry Andric 408*0b57cec5SDimitry Andric template<bool _Dummy = true, _EnableB< 409*0b57cec5SDimitry Andric _CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>() 410*0b57cec5SDimitry Andric > = false> 411*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR 412*0b57cec5SDimitry Andric pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && 413*0b57cec5SDimitry Andric is_nothrow_default_constructible<second_type>::value) 414*0b57cec5SDimitry Andric : first(), second() {} 415*0b57cec5SDimitry Andric 416*0b57cec5SDimitry Andric template <bool _Dummy = true, _EnableB< 417*0b57cec5SDimitry Andric _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>() 418*0b57cec5SDimitry Andric > = false> 419*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 420*0b57cec5SDimitry Andric explicit pair(_T1 const& __t1, _T2 const& __t2) 421*0b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && 422*0b57cec5SDimitry Andric is_nothrow_copy_constructible<second_type>::value) 423*0b57cec5SDimitry Andric : first(__t1), second(__t2) {} 424*0b57cec5SDimitry Andric 425*0b57cec5SDimitry Andric template<bool _Dummy = true, _EnableB< 426*0b57cec5SDimitry Andric _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>() 427*0b57cec5SDimitry Andric > = false> 428*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 429*0b57cec5SDimitry Andric pair(_T1 const& __t1, _T2 const& __t2) 430*0b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && 431*0b57cec5SDimitry Andric is_nothrow_copy_constructible<second_type>::value) 432*0b57cec5SDimitry Andric : first(__t1), second(__t2) {} 433*0b57cec5SDimitry Andric 434*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 435*0b57cec5SDimitry Andric _CheckArgs::template __enable_explicit<_U1, _U2>() 436*0b57cec5SDimitry Andric > = false> 437*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 438*0b57cec5SDimitry Andric explicit pair(_U1&& __u1, _U2&& __u2) 439*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && 440*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2>::value)) 441*0b57cec5SDimitry Andric : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} 442*0b57cec5SDimitry Andric 443*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 444*0b57cec5SDimitry Andric _CheckArgs::template __enable_implicit<_U1, _U2>() 445*0b57cec5SDimitry Andric > = false> 446*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 447*0b57cec5SDimitry Andric pair(_U1&& __u1, _U2&& __u2) 448*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && 449*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2>::value)) 450*0b57cec5SDimitry Andric : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} 451*0b57cec5SDimitry Andric 452*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 453*0b57cec5SDimitry Andric _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>() 454*0b57cec5SDimitry Andric > = false> 455*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 456*0b57cec5SDimitry Andric explicit pair(pair<_U1, _U2> const& __p) 457*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && 458*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2 const&>::value)) 459*0b57cec5SDimitry Andric : first(__p.first), second(__p.second) {} 460*0b57cec5SDimitry Andric 461*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 462*0b57cec5SDimitry Andric _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>() 463*0b57cec5SDimitry Andric > = false> 464*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 465*0b57cec5SDimitry Andric pair(pair<_U1, _U2> const& __p) 466*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && 467*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2 const&>::value)) 468*0b57cec5SDimitry Andric : first(__p.first), second(__p.second) {} 469*0b57cec5SDimitry Andric 470*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 471*0b57cec5SDimitry Andric _CheckArgs::template __enable_explicit<_U1, _U2>() 472*0b57cec5SDimitry Andric > = false> 473*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 474*0b57cec5SDimitry Andric explicit pair(pair<_U1, _U2>&&__p) 475*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && 476*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2&&>::value)) 477*0b57cec5SDimitry Andric : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} 478*0b57cec5SDimitry Andric 479*0b57cec5SDimitry Andric template<class _U1, class _U2, _EnableB< 480*0b57cec5SDimitry Andric _CheckArgs::template __enable_implicit<_U1, _U2>() 481*0b57cec5SDimitry Andric > = false> 482*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 483*0b57cec5SDimitry Andric pair(pair<_U1, _U2>&& __p) 484*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && 485*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _U2&&>::value)) 486*0b57cec5SDimitry Andric : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} 487*0b57cec5SDimitry Andric 488*0b57cec5SDimitry Andric template<class _Tuple, _EnableB< 489*0b57cec5SDimitry Andric _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>() 490*0b57cec5SDimitry Andric > = false> 491*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 492*0b57cec5SDimitry Andric explicit pair(_Tuple&& __p) 493*0b57cec5SDimitry Andric : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), 494*0b57cec5SDimitry Andric second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} 495*0b57cec5SDimitry Andric 496*0b57cec5SDimitry Andric template<class _Tuple, _EnableB< 497*0b57cec5SDimitry Andric _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>() 498*0b57cec5SDimitry Andric > = false> 499*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 500*0b57cec5SDimitry Andric pair(_Tuple&& __p) 501*0b57cec5SDimitry Andric : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), 502*0b57cec5SDimitry Andric second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} 503*0b57cec5SDimitry Andric 504*0b57cec5SDimitry Andric template <class... _Args1, class... _Args2> 505*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 506*0b57cec5SDimitry Andric pair(piecewise_construct_t __pc, 507*0b57cec5SDimitry Andric tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) 508*0b57cec5SDimitry Andric _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value && 509*0b57cec5SDimitry Andric is_nothrow_constructible<second_type, _Args2...>::value)) 510*0b57cec5SDimitry Andric : pair(__pc, __first_args, __second_args, 511*0b57cec5SDimitry Andric typename __make_tuple_indices<sizeof...(_Args1)>::type(), 512*0b57cec5SDimitry Andric typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} 513*0b57cec5SDimitry Andric 514*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 515*0b57cec5SDimitry Andric pair& operator=(typename conditional< 516*0b57cec5SDimitry Andric is_copy_assignable<first_type>::value && 517*0b57cec5SDimitry Andric is_copy_assignable<second_type>::value, 518*0b57cec5SDimitry Andric pair, __nat>::type const& __p) 519*0b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value && 520*0b57cec5SDimitry Andric is_nothrow_copy_assignable<second_type>::value) 521*0b57cec5SDimitry Andric { 522*0b57cec5SDimitry Andric first = __p.first; 523*0b57cec5SDimitry Andric second = __p.second; 524*0b57cec5SDimitry Andric return *this; 525*0b57cec5SDimitry Andric } 526*0b57cec5SDimitry Andric 527*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 528*0b57cec5SDimitry Andric pair& operator=(typename conditional< 529*0b57cec5SDimitry Andric is_move_assignable<first_type>::value && 530*0b57cec5SDimitry Andric is_move_assignable<second_type>::value, 531*0b57cec5SDimitry Andric pair, __nat>::type&& __p) 532*0b57cec5SDimitry Andric _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value && 533*0b57cec5SDimitry Andric is_nothrow_move_assignable<second_type>::value) 534*0b57cec5SDimitry Andric { 535*0b57cec5SDimitry Andric first = _VSTD::forward<first_type>(__p.first); 536*0b57cec5SDimitry Andric second = _VSTD::forward<second_type>(__p.second); 537*0b57cec5SDimitry Andric return *this; 538*0b57cec5SDimitry Andric } 539*0b57cec5SDimitry Andric 540*0b57cec5SDimitry Andric template <class _Tuple, _EnableB< 541*0b57cec5SDimitry Andric _CheckTLC<_Tuple>::template __enable_assign<_Tuple>() 542*0b57cec5SDimitry Andric > = false> 543*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 544*0b57cec5SDimitry Andric pair& operator=(_Tuple&& __p) { 545*0b57cec5SDimitry Andric first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p)); 546*0b57cec5SDimitry Andric second = _VSTD::get<1>(_VSTD::forward<_Tuple>(__p)); 547*0b57cec5SDimitry Andric return *this; 548*0b57cec5SDimitry Andric } 549*0b57cec5SDimitry Andric#endif 550*0b57cec5SDimitry Andric 551*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 552*0b57cec5SDimitry Andric void 553*0b57cec5SDimitry Andric swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value && 554*0b57cec5SDimitry Andric __is_nothrow_swappable<second_type>::value) 555*0b57cec5SDimitry Andric { 556*0b57cec5SDimitry Andric using _VSTD::swap; 557*0b57cec5SDimitry Andric swap(first, __p.first); 558*0b57cec5SDimitry Andric swap(second, __p.second); 559*0b57cec5SDimitry Andric } 560*0b57cec5SDimitry Andricprivate: 561*0b57cec5SDimitry Andric 562*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 563*0b57cec5SDimitry Andric template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> 564*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 565*0b57cec5SDimitry Andric pair(piecewise_construct_t, 566*0b57cec5SDimitry Andric tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args, 567*0b57cec5SDimitry Andric __tuple_indices<_I1...>, __tuple_indices<_I2...>); 568*0b57cec5SDimitry Andric#endif 569*0b57cec5SDimitry Andric}; 570*0b57cec5SDimitry Andric 571*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 572*0b57cec5SDimitry Andrictemplate<class _T1, class _T2> 573*0b57cec5SDimitry Andricpair(_T1, _T2) -> pair<_T1, _T2>; 574*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES 575*0b57cec5SDimitry Andric 576*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 577*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 578*0b57cec5SDimitry Andricbool 579*0b57cec5SDimitry Andricoperator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 580*0b57cec5SDimitry Andric{ 581*0b57cec5SDimitry Andric return __x.first == __y.first && __x.second == __y.second; 582*0b57cec5SDimitry Andric} 583*0b57cec5SDimitry Andric 584*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 585*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 586*0b57cec5SDimitry Andricbool 587*0b57cec5SDimitry Andricoperator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 588*0b57cec5SDimitry Andric{ 589*0b57cec5SDimitry Andric return !(__x == __y); 590*0b57cec5SDimitry Andric} 591*0b57cec5SDimitry Andric 592*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 593*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 594*0b57cec5SDimitry Andricbool 595*0b57cec5SDimitry Andricoperator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 596*0b57cec5SDimitry Andric{ 597*0b57cec5SDimitry Andric return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second); 598*0b57cec5SDimitry Andric} 599*0b57cec5SDimitry Andric 600*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 601*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 602*0b57cec5SDimitry Andricbool 603*0b57cec5SDimitry Andricoperator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 604*0b57cec5SDimitry Andric{ 605*0b57cec5SDimitry Andric return __y < __x; 606*0b57cec5SDimitry Andric} 607*0b57cec5SDimitry Andric 608*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 609*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 610*0b57cec5SDimitry Andricbool 611*0b57cec5SDimitry Andricoperator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 612*0b57cec5SDimitry Andric{ 613*0b57cec5SDimitry Andric return !(__x < __y); 614*0b57cec5SDimitry Andric} 615*0b57cec5SDimitry Andric 616*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 617*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 618*0b57cec5SDimitry Andricbool 619*0b57cec5SDimitry Andricoperator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) 620*0b57cec5SDimitry Andric{ 621*0b57cec5SDimitry Andric return !(__y < __x); 622*0b57cec5SDimitry Andric} 623*0b57cec5SDimitry Andric 624*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 625*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 626*0b57cec5SDimitry Andrictypename enable_if 627*0b57cec5SDimitry Andric< 628*0b57cec5SDimitry Andric __is_swappable<_T1>::value && 629*0b57cec5SDimitry Andric __is_swappable<_T2>::value, 630*0b57cec5SDimitry Andric void 631*0b57cec5SDimitry Andric>::type 632*0b57cec5SDimitry Andricswap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) 633*0b57cec5SDimitry Andric _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && 634*0b57cec5SDimitry Andric __is_nothrow_swappable<_T2>::value)) 635*0b57cec5SDimitry Andric{ 636*0b57cec5SDimitry Andric __x.swap(__y); 637*0b57cec5SDimitry Andric} 638*0b57cec5SDimitry Andric 639*0b57cec5SDimitry Andrictemplate <class _Tp> 640*0b57cec5SDimitry Andricstruct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; 641*0b57cec5SDimitry Andric 642*0b57cec5SDimitry Andrictemplate <class _Tp> 643*0b57cec5SDimitry Andricstruct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; 644*0b57cec5SDimitry Andric 645*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 646*0b57cec5SDimitry Andrictemplate <class _Tp> 647*0b57cec5SDimitry Andricstruct unwrap_reference : __unwrap_reference<_Tp> { }; 648*0b57cec5SDimitry Andric 649*0b57cec5SDimitry Andrictemplate <class _Tp> 650*0b57cec5SDimitry Andricstruct unwrap_ref_decay : unwrap_reference<typename decay<_Tp>::type> { }; 651*0b57cec5SDimitry Andric#endif // > C++17 652*0b57cec5SDimitry Andric 653*0b57cec5SDimitry Andrictemplate <class _Tp> 654*0b57cec5SDimitry Andricstruct __unwrap_ref_decay 655*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 17 656*0b57cec5SDimitry Andric : unwrap_ref_decay<_Tp> 657*0b57cec5SDimitry Andric#else 658*0b57cec5SDimitry Andric : __unwrap_reference<typename decay<_Tp>::type> 659*0b57cec5SDimitry Andric#endif 660*0b57cec5SDimitry Andric{ }; 661*0b57cec5SDimitry Andric 662*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 663*0b57cec5SDimitry Andric 664*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 665*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 666*0b57cec5SDimitry Andricpair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> 667*0b57cec5SDimitry Andricmake_pair(_T1&& __t1, _T2&& __t2) 668*0b57cec5SDimitry Andric{ 669*0b57cec5SDimitry Andric return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> 670*0b57cec5SDimitry Andric (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2)); 671*0b57cec5SDimitry Andric} 672*0b57cec5SDimitry Andric 673*0b57cec5SDimitry Andric#else // _LIBCPP_CXX03_LANG 674*0b57cec5SDimitry Andric 675*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 676*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 677*0b57cec5SDimitry Andricpair<_T1,_T2> 678*0b57cec5SDimitry Andricmake_pair(_T1 __x, _T2 __y) 679*0b57cec5SDimitry Andric{ 680*0b57cec5SDimitry Andric return pair<_T1, _T2>(__x, __y); 681*0b57cec5SDimitry Andric} 682*0b57cec5SDimitry Andric 683*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 684*0b57cec5SDimitry Andric 685*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 686*0b57cec5SDimitry Andric struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> > 687*0b57cec5SDimitry Andric : public integral_constant<size_t, 2> {}; 688*0b57cec5SDimitry Andric 689*0b57cec5SDimitry Andrictemplate <size_t _Ip, class _T1, class _T2> 690*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > 691*0b57cec5SDimitry Andric{ 692*0b57cec5SDimitry Andric static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"); 693*0b57cec5SDimitry Andric}; 694*0b57cec5SDimitry Andric 695*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 696*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > 697*0b57cec5SDimitry Andric{ 698*0b57cec5SDimitry Andric typedef _LIBCPP_NODEBUG_TYPE _T1 type; 699*0b57cec5SDimitry Andric}; 700*0b57cec5SDimitry Andric 701*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 702*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > 703*0b57cec5SDimitry Andric{ 704*0b57cec5SDimitry Andric typedef _LIBCPP_NODEBUG_TYPE _T2 type; 705*0b57cec5SDimitry Andric}; 706*0b57cec5SDimitry Andric 707*0b57cec5SDimitry Andrictemplate <size_t _Ip> struct __get_pair; 708*0b57cec5SDimitry Andric 709*0b57cec5SDimitry Andrictemplate <> 710*0b57cec5SDimitry Andricstruct __get_pair<0> 711*0b57cec5SDimitry Andric{ 712*0b57cec5SDimitry Andric template <class _T1, class _T2> 713*0b57cec5SDimitry Andric static 714*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 715*0b57cec5SDimitry Andric _T1& 716*0b57cec5SDimitry Andric get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 717*0b57cec5SDimitry Andric 718*0b57cec5SDimitry Andric template <class _T1, class _T2> 719*0b57cec5SDimitry Andric static 720*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 721*0b57cec5SDimitry Andric const _T1& 722*0b57cec5SDimitry Andric get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;} 723*0b57cec5SDimitry Andric 724*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 725*0b57cec5SDimitry Andric template <class _T1, class _T2> 726*0b57cec5SDimitry Andric static 727*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 728*0b57cec5SDimitry Andric _T1&& 729*0b57cec5SDimitry Andric get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} 730*0b57cec5SDimitry Andric 731*0b57cec5SDimitry Andric template <class _T1, class _T2> 732*0b57cec5SDimitry Andric static 733*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 734*0b57cec5SDimitry Andric const _T1&& 735*0b57cec5SDimitry Andric get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T1>(__p.first);} 736*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 737*0b57cec5SDimitry Andric}; 738*0b57cec5SDimitry Andric 739*0b57cec5SDimitry Andrictemplate <> 740*0b57cec5SDimitry Andricstruct __get_pair<1> 741*0b57cec5SDimitry Andric{ 742*0b57cec5SDimitry Andric template <class _T1, class _T2> 743*0b57cec5SDimitry Andric static 744*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 745*0b57cec5SDimitry Andric _T2& 746*0b57cec5SDimitry Andric get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 747*0b57cec5SDimitry Andric 748*0b57cec5SDimitry Andric template <class _T1, class _T2> 749*0b57cec5SDimitry Andric static 750*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 751*0b57cec5SDimitry Andric const _T2& 752*0b57cec5SDimitry Andric get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;} 753*0b57cec5SDimitry Andric 754*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 755*0b57cec5SDimitry Andric template <class _T1, class _T2> 756*0b57cec5SDimitry Andric static 757*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 758*0b57cec5SDimitry Andric _T2&& 759*0b57cec5SDimitry Andric get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} 760*0b57cec5SDimitry Andric 761*0b57cec5SDimitry Andric template <class _T1, class _T2> 762*0b57cec5SDimitry Andric static 763*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 764*0b57cec5SDimitry Andric const _T2&& 765*0b57cec5SDimitry Andric get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<const _T2>(__p.second);} 766*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 767*0b57cec5SDimitry Andric}; 768*0b57cec5SDimitry Andric 769*0b57cec5SDimitry Andrictemplate <size_t _Ip, class _T1, class _T2> 770*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 771*0b57cec5SDimitry Andrictypename tuple_element<_Ip, pair<_T1, _T2> >::type& 772*0b57cec5SDimitry Andricget(pair<_T1, _T2>& __p) _NOEXCEPT 773*0b57cec5SDimitry Andric{ 774*0b57cec5SDimitry Andric return __get_pair<_Ip>::get(__p); 775*0b57cec5SDimitry Andric} 776*0b57cec5SDimitry Andric 777*0b57cec5SDimitry Andrictemplate <size_t _Ip, class _T1, class _T2> 778*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 779*0b57cec5SDimitry Andricconst typename tuple_element<_Ip, pair<_T1, _T2> >::type& 780*0b57cec5SDimitry Andricget(const pair<_T1, _T2>& __p) _NOEXCEPT 781*0b57cec5SDimitry Andric{ 782*0b57cec5SDimitry Andric return __get_pair<_Ip>::get(__p); 783*0b57cec5SDimitry Andric} 784*0b57cec5SDimitry Andric 785*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 786*0b57cec5SDimitry Andrictemplate <size_t _Ip, class _T1, class _T2> 787*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 788*0b57cec5SDimitry Andrictypename tuple_element<_Ip, pair<_T1, _T2> >::type&& 789*0b57cec5SDimitry Andricget(pair<_T1, _T2>&& __p) _NOEXCEPT 790*0b57cec5SDimitry Andric{ 791*0b57cec5SDimitry Andric return __get_pair<_Ip>::get(_VSTD::move(__p)); 792*0b57cec5SDimitry Andric} 793*0b57cec5SDimitry Andric 794*0b57cec5SDimitry Andrictemplate <size_t _Ip, class _T1, class _T2> 795*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 796*0b57cec5SDimitry Andricconst typename tuple_element<_Ip, pair<_T1, _T2> >::type&& 797*0b57cec5SDimitry Andricget(const pair<_T1, _T2>&& __p) _NOEXCEPT 798*0b57cec5SDimitry Andric{ 799*0b57cec5SDimitry Andric return __get_pair<_Ip>::get(_VSTD::move(__p)); 800*0b57cec5SDimitry Andric} 801*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 802*0b57cec5SDimitry Andric 803*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 804*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 805*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 806*0b57cec5SDimitry Andricconstexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT 807*0b57cec5SDimitry Andric{ 808*0b57cec5SDimitry Andric return __get_pair<0>::get(__p); 809*0b57cec5SDimitry Andric} 810*0b57cec5SDimitry Andric 811*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 812*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 813*0b57cec5SDimitry Andricconstexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT 814*0b57cec5SDimitry Andric{ 815*0b57cec5SDimitry Andric return __get_pair<0>::get(__p); 816*0b57cec5SDimitry Andric} 817*0b57cec5SDimitry Andric 818*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 819*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 820*0b57cec5SDimitry Andricconstexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT 821*0b57cec5SDimitry Andric{ 822*0b57cec5SDimitry Andric return __get_pair<0>::get(_VSTD::move(__p)); 823*0b57cec5SDimitry Andric} 824*0b57cec5SDimitry Andric 825*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 826*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 827*0b57cec5SDimitry Andricconstexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT 828*0b57cec5SDimitry Andric{ 829*0b57cec5SDimitry Andric return __get_pair<0>::get(_VSTD::move(__p)); 830*0b57cec5SDimitry Andric} 831*0b57cec5SDimitry Andric 832*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 833*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 834*0b57cec5SDimitry Andricconstexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT 835*0b57cec5SDimitry Andric{ 836*0b57cec5SDimitry Andric return __get_pair<1>::get(__p); 837*0b57cec5SDimitry Andric} 838*0b57cec5SDimitry Andric 839*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 840*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 841*0b57cec5SDimitry Andricconstexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT 842*0b57cec5SDimitry Andric{ 843*0b57cec5SDimitry Andric return __get_pair<1>::get(__p); 844*0b57cec5SDimitry Andric} 845*0b57cec5SDimitry Andric 846*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 847*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 848*0b57cec5SDimitry Andricconstexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT 849*0b57cec5SDimitry Andric{ 850*0b57cec5SDimitry Andric return __get_pair<1>::get(_VSTD::move(__p)); 851*0b57cec5SDimitry Andric} 852*0b57cec5SDimitry Andric 853*0b57cec5SDimitry Andrictemplate <class _T1, class _T2> 854*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 855*0b57cec5SDimitry Andricconstexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT 856*0b57cec5SDimitry Andric{ 857*0b57cec5SDimitry Andric return __get_pair<1>::get(_VSTD::move(__p)); 858*0b57cec5SDimitry Andric} 859*0b57cec5SDimitry Andric 860*0b57cec5SDimitry Andric#endif 861*0b57cec5SDimitry Andric 862*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 863*0b57cec5SDimitry Andric 864*0b57cec5SDimitry Andrictemplate<class _Tp, _Tp... _Ip> 865*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS integer_sequence 866*0b57cec5SDimitry Andric{ 867*0b57cec5SDimitry Andric typedef _Tp value_type; 868*0b57cec5SDimitry Andric static_assert( is_integral<_Tp>::value, 869*0b57cec5SDimitry Andric "std::integer_sequence can only be instantiated with an integral type" ); 870*0b57cec5SDimitry Andric static 871*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 872*0b57cec5SDimitry Andric constexpr 873*0b57cec5SDimitry Andric size_t 874*0b57cec5SDimitry Andric size() noexcept { return sizeof...(_Ip); } 875*0b57cec5SDimitry Andric}; 876*0b57cec5SDimitry Andric 877*0b57cec5SDimitry Andrictemplate<size_t... _Ip> 878*0b57cec5SDimitry Andric using index_sequence = integer_sequence<size_t, _Ip...>; 879*0b57cec5SDimitry Andric 880*0b57cec5SDimitry Andric#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) 881*0b57cec5SDimitry Andric 882*0b57cec5SDimitry Andrictemplate <class _Tp, _Tp _Ep> 883*0b57cec5SDimitry Andricusing __make_integer_sequence _LIBCPP_NODEBUG_TYPE = __make_integer_seq<integer_sequence, _Tp, _Ep>; 884*0b57cec5SDimitry Andric 885*0b57cec5SDimitry Andric#else 886*0b57cec5SDimitry Andric 887*0b57cec5SDimitry Andrictemplate<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG_TYPE = 888*0b57cec5SDimitry Andric typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>; 889*0b57cec5SDimitry Andric 890*0b57cec5SDimitry Andrictemplate <class _Tp, _Tp _Ep> 891*0b57cec5SDimitry Andricstruct __make_integer_sequence_checked 892*0b57cec5SDimitry Andric{ 893*0b57cec5SDimitry Andric static_assert(is_integral<_Tp>::value, 894*0b57cec5SDimitry Andric "std::make_integer_sequence can only be instantiated with an integral type" ); 895*0b57cec5SDimitry Andric static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length"); 896*0b57cec5SDimitry Andric // Workaround GCC bug by preventing bad installations when 0 <= _Ep 897*0b57cec5SDimitry Andric // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929 898*0b57cec5SDimitry Andric typedef _LIBCPP_NODEBUG_TYPE __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; 899*0b57cec5SDimitry Andric}; 900*0b57cec5SDimitry Andric 901*0b57cec5SDimitry Andrictemplate <class _Tp, _Tp _Ep> 902*0b57cec5SDimitry Andricusing __make_integer_sequence _LIBCPP_NODEBUG_TYPE = typename __make_integer_sequence_checked<_Tp, _Ep>::type; 903*0b57cec5SDimitry Andric 904*0b57cec5SDimitry Andric#endif 905*0b57cec5SDimitry Andric 906*0b57cec5SDimitry Andrictemplate<class _Tp, _Tp _Np> 907*0b57cec5SDimitry Andric using make_integer_sequence = __make_integer_sequence<_Tp, _Np>; 908*0b57cec5SDimitry Andric 909*0b57cec5SDimitry Andrictemplate<size_t _Np> 910*0b57cec5SDimitry Andric using make_index_sequence = make_integer_sequence<size_t, _Np>; 911*0b57cec5SDimitry Andric 912*0b57cec5SDimitry Andrictemplate<class... _Tp> 913*0b57cec5SDimitry Andric using index_sequence_for = make_index_sequence<sizeof...(_Tp)>; 914*0b57cec5SDimitry Andric 915*0b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 11 916*0b57cec5SDimitry Andric 917*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 918*0b57cec5SDimitry Andrictemplate<class _T1, class _T2 = _T1> 919*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 920*0b57cec5SDimitry Andric_T1 exchange(_T1& __obj, _T2 && __new_value) 921*0b57cec5SDimitry Andric{ 922*0b57cec5SDimitry Andric _T1 __old_value = _VSTD::move(__obj); 923*0b57cec5SDimitry Andric __obj = _VSTD::forward<_T2>(__new_value); 924*0b57cec5SDimitry Andric return __old_value; 925*0b57cec5SDimitry Andric} 926*0b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 11 927*0b57cec5SDimitry Andric 928*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 929*0b57cec5SDimitry Andric 930*0b57cec5SDimitry Andricstruct _LIBCPP_TYPE_VIS in_place_t { 931*0b57cec5SDimitry Andric explicit in_place_t() = default; 932*0b57cec5SDimitry Andric}; 933*0b57cec5SDimitry Andric_LIBCPP_INLINE_VAR constexpr in_place_t in_place{}; 934*0b57cec5SDimitry Andric 935*0b57cec5SDimitry Andrictemplate <class _Tp> 936*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS in_place_type_t { 937*0b57cec5SDimitry Andric explicit in_place_type_t() = default; 938*0b57cec5SDimitry Andric}; 939*0b57cec5SDimitry Andrictemplate <class _Tp> 940*0b57cec5SDimitry Andric_LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{}; 941*0b57cec5SDimitry Andric 942*0b57cec5SDimitry Andrictemplate <size_t _Idx> 943*0b57cec5SDimitry Andricstruct _LIBCPP_TYPE_VIS in_place_index_t { 944*0b57cec5SDimitry Andric explicit in_place_index_t() = default; 945*0b57cec5SDimitry Andric}; 946*0b57cec5SDimitry Andrictemplate <size_t _Idx> 947*0b57cec5SDimitry Andric_LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{}; 948*0b57cec5SDimitry Andric 949*0b57cec5SDimitry Andrictemplate <class _Tp> struct __is_inplace_type_imp : false_type {}; 950*0b57cec5SDimitry Andrictemplate <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {}; 951*0b57cec5SDimitry Andric 952*0b57cec5SDimitry Andrictemplate <class _Tp> 953*0b57cec5SDimitry Andricusing __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>; 954*0b57cec5SDimitry Andric 955*0b57cec5SDimitry Andrictemplate <class _Tp> struct __is_inplace_index_imp : false_type {}; 956*0b57cec5SDimitry Andrictemplate <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {}; 957*0b57cec5SDimitry Andric 958*0b57cec5SDimitry Andrictemplate <class _Tp> 959*0b57cec5SDimitry Andricusing __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>; 960*0b57cec5SDimitry Andric 961*0b57cec5SDimitry Andric#endif // _LIBCPP_STD_VER > 14 962*0b57cec5SDimitry Andric 963*0b57cec5SDimitry Andrictemplate <class _Arg, class _Result> 964*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS unary_function 965*0b57cec5SDimitry Andric{ 966*0b57cec5SDimitry Andric typedef _Arg argument_type; 967*0b57cec5SDimitry Andric typedef _Result result_type; 968*0b57cec5SDimitry Andric}; 969*0b57cec5SDimitry Andric 970*0b57cec5SDimitry Andrictemplate <class _Size> 971*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 972*0b57cec5SDimitry Andric_Size 973*0b57cec5SDimitry Andric__loadword(const void* __p) 974*0b57cec5SDimitry Andric{ 975*0b57cec5SDimitry Andric _Size __r; 976*0b57cec5SDimitry Andric std::memcpy(&__r, __p, sizeof(__r)); 977*0b57cec5SDimitry Andric return __r; 978*0b57cec5SDimitry Andric} 979*0b57cec5SDimitry Andric 980*0b57cec5SDimitry Andric// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t 981*0b57cec5SDimitry Andric// is 64 bits. This is because cityhash64 uses 64bit x 64bit 982*0b57cec5SDimitry Andric// multiplication, which can be very slow on 32-bit systems. 983*0b57cec5SDimitry Andrictemplate <class _Size, size_t = sizeof(_Size)*__CHAR_BIT__> 984*0b57cec5SDimitry Andricstruct __murmur2_or_cityhash; 985*0b57cec5SDimitry Andric 986*0b57cec5SDimitry Andrictemplate <class _Size> 987*0b57cec5SDimitry Andricstruct __murmur2_or_cityhash<_Size, 32> 988*0b57cec5SDimitry Andric{ 989*0b57cec5SDimitry Andric inline _Size operator()(const void* __key, _Size __len) 990*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; 991*0b57cec5SDimitry Andric}; 992*0b57cec5SDimitry Andric 993*0b57cec5SDimitry Andric// murmur2 994*0b57cec5SDimitry Andrictemplate <class _Size> 995*0b57cec5SDimitry Andric_Size 996*0b57cec5SDimitry Andric__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) 997*0b57cec5SDimitry Andric{ 998*0b57cec5SDimitry Andric const _Size __m = 0x5bd1e995; 999*0b57cec5SDimitry Andric const _Size __r = 24; 1000*0b57cec5SDimitry Andric _Size __h = __len; 1001*0b57cec5SDimitry Andric const unsigned char* __data = static_cast<const unsigned char*>(__key); 1002*0b57cec5SDimitry Andric for (; __len >= 4; __data += 4, __len -= 4) 1003*0b57cec5SDimitry Andric { 1004*0b57cec5SDimitry Andric _Size __k = __loadword<_Size>(__data); 1005*0b57cec5SDimitry Andric __k *= __m; 1006*0b57cec5SDimitry Andric __k ^= __k >> __r; 1007*0b57cec5SDimitry Andric __k *= __m; 1008*0b57cec5SDimitry Andric __h *= __m; 1009*0b57cec5SDimitry Andric __h ^= __k; 1010*0b57cec5SDimitry Andric } 1011*0b57cec5SDimitry Andric switch (__len) 1012*0b57cec5SDimitry Andric { 1013*0b57cec5SDimitry Andric case 3: 1014*0b57cec5SDimitry Andric __h ^= __data[2] << 16; 1015*0b57cec5SDimitry Andric _LIBCPP_FALLTHROUGH(); 1016*0b57cec5SDimitry Andric case 2: 1017*0b57cec5SDimitry Andric __h ^= __data[1] << 8; 1018*0b57cec5SDimitry Andric _LIBCPP_FALLTHROUGH(); 1019*0b57cec5SDimitry Andric case 1: 1020*0b57cec5SDimitry Andric __h ^= __data[0]; 1021*0b57cec5SDimitry Andric __h *= __m; 1022*0b57cec5SDimitry Andric } 1023*0b57cec5SDimitry Andric __h ^= __h >> 13; 1024*0b57cec5SDimitry Andric __h *= __m; 1025*0b57cec5SDimitry Andric __h ^= __h >> 15; 1026*0b57cec5SDimitry Andric return __h; 1027*0b57cec5SDimitry Andric} 1028*0b57cec5SDimitry Andric 1029*0b57cec5SDimitry Andrictemplate <class _Size> 1030*0b57cec5SDimitry Andricstruct __murmur2_or_cityhash<_Size, 64> 1031*0b57cec5SDimitry Andric{ 1032*0b57cec5SDimitry Andric inline _Size operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; 1033*0b57cec5SDimitry Andric 1034*0b57cec5SDimitry Andric private: 1035*0b57cec5SDimitry Andric // Some primes between 2^63 and 2^64. 1036*0b57cec5SDimitry Andric static const _Size __k0 = 0xc3a5c85c97cb3127ULL; 1037*0b57cec5SDimitry Andric static const _Size __k1 = 0xb492b66fbe98f273ULL; 1038*0b57cec5SDimitry Andric static const _Size __k2 = 0x9ae16a3b2f90404fULL; 1039*0b57cec5SDimitry Andric static const _Size __k3 = 0xc949d7c7509e6557ULL; 1040*0b57cec5SDimitry Andric 1041*0b57cec5SDimitry Andric static _Size __rotate(_Size __val, int __shift) { 1042*0b57cec5SDimitry Andric return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); 1043*0b57cec5SDimitry Andric } 1044*0b57cec5SDimitry Andric 1045*0b57cec5SDimitry Andric static _Size __rotate_by_at_least_1(_Size __val, int __shift) { 1046*0b57cec5SDimitry Andric return (__val >> __shift) | (__val << (64 - __shift)); 1047*0b57cec5SDimitry Andric } 1048*0b57cec5SDimitry Andric 1049*0b57cec5SDimitry Andric static _Size __shift_mix(_Size __val) { 1050*0b57cec5SDimitry Andric return __val ^ (__val >> 47); 1051*0b57cec5SDimitry Andric } 1052*0b57cec5SDimitry Andric 1053*0b57cec5SDimitry Andric static _Size __hash_len_16(_Size __u, _Size __v) 1054*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1055*0b57cec5SDimitry Andric { 1056*0b57cec5SDimitry Andric const _Size __mul = 0x9ddfea08eb382d69ULL; 1057*0b57cec5SDimitry Andric _Size __a = (__u ^ __v) * __mul; 1058*0b57cec5SDimitry Andric __a ^= (__a >> 47); 1059*0b57cec5SDimitry Andric _Size __b = (__v ^ __a) * __mul; 1060*0b57cec5SDimitry Andric __b ^= (__b >> 47); 1061*0b57cec5SDimitry Andric __b *= __mul; 1062*0b57cec5SDimitry Andric return __b; 1063*0b57cec5SDimitry Andric } 1064*0b57cec5SDimitry Andric 1065*0b57cec5SDimitry Andric static _Size __hash_len_0_to_16(const char* __s, _Size __len) 1066*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1067*0b57cec5SDimitry Andric { 1068*0b57cec5SDimitry Andric if (__len > 8) { 1069*0b57cec5SDimitry Andric const _Size __a = __loadword<_Size>(__s); 1070*0b57cec5SDimitry Andric const _Size __b = __loadword<_Size>(__s + __len - 8); 1071*0b57cec5SDimitry Andric return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; 1072*0b57cec5SDimitry Andric } 1073*0b57cec5SDimitry Andric if (__len >= 4) { 1074*0b57cec5SDimitry Andric const uint32_t __a = __loadword<uint32_t>(__s); 1075*0b57cec5SDimitry Andric const uint32_t __b = __loadword<uint32_t>(__s + __len - 4); 1076*0b57cec5SDimitry Andric return __hash_len_16(__len + (__a << 3), __b); 1077*0b57cec5SDimitry Andric } 1078*0b57cec5SDimitry Andric if (__len > 0) { 1079*0b57cec5SDimitry Andric const unsigned char __a = __s[0]; 1080*0b57cec5SDimitry Andric const unsigned char __b = __s[__len >> 1]; 1081*0b57cec5SDimitry Andric const unsigned char __c = __s[__len - 1]; 1082*0b57cec5SDimitry Andric const uint32_t __y = static_cast<uint32_t>(__a) + 1083*0b57cec5SDimitry Andric (static_cast<uint32_t>(__b) << 8); 1084*0b57cec5SDimitry Andric const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2); 1085*0b57cec5SDimitry Andric return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; 1086*0b57cec5SDimitry Andric } 1087*0b57cec5SDimitry Andric return __k2; 1088*0b57cec5SDimitry Andric } 1089*0b57cec5SDimitry Andric 1090*0b57cec5SDimitry Andric static _Size __hash_len_17_to_32(const char *__s, _Size __len) 1091*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1092*0b57cec5SDimitry Andric { 1093*0b57cec5SDimitry Andric const _Size __a = __loadword<_Size>(__s) * __k1; 1094*0b57cec5SDimitry Andric const _Size __b = __loadword<_Size>(__s + 8); 1095*0b57cec5SDimitry Andric const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; 1096*0b57cec5SDimitry Andric const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; 1097*0b57cec5SDimitry Andric return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, 1098*0b57cec5SDimitry Andric __a + __rotate(__b ^ __k3, 20) - __c + __len); 1099*0b57cec5SDimitry Andric } 1100*0b57cec5SDimitry Andric 1101*0b57cec5SDimitry Andric // Return a 16-byte hash for 48 bytes. Quick and dirty. 1102*0b57cec5SDimitry Andric // Callers do best to use "random-looking" values for a and b. 1103*0b57cec5SDimitry Andric static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 1104*0b57cec5SDimitry Andric _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) 1105*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1106*0b57cec5SDimitry Andric { 1107*0b57cec5SDimitry Andric __a += __w; 1108*0b57cec5SDimitry Andric __b = __rotate(__b + __a + __z, 21); 1109*0b57cec5SDimitry Andric const _Size __c = __a; 1110*0b57cec5SDimitry Andric __a += __x; 1111*0b57cec5SDimitry Andric __a += __y; 1112*0b57cec5SDimitry Andric __b += __rotate(__a, 44); 1113*0b57cec5SDimitry Andric return pair<_Size, _Size>(__a + __z, __b + __c); 1114*0b57cec5SDimitry Andric } 1115*0b57cec5SDimitry Andric 1116*0b57cec5SDimitry Andric // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. 1117*0b57cec5SDimitry Andric static pair<_Size, _Size> __weak_hash_len_32_with_seeds( 1118*0b57cec5SDimitry Andric const char* __s, _Size __a, _Size __b) 1119*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1120*0b57cec5SDimitry Andric { 1121*0b57cec5SDimitry Andric return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), 1122*0b57cec5SDimitry Andric __loadword<_Size>(__s + 8), 1123*0b57cec5SDimitry Andric __loadword<_Size>(__s + 16), 1124*0b57cec5SDimitry Andric __loadword<_Size>(__s + 24), 1125*0b57cec5SDimitry Andric __a, 1126*0b57cec5SDimitry Andric __b); 1127*0b57cec5SDimitry Andric } 1128*0b57cec5SDimitry Andric 1129*0b57cec5SDimitry Andric // Return an 8-byte hash for 33 to 64 bytes. 1130*0b57cec5SDimitry Andric static _Size __hash_len_33_to_64(const char *__s, size_t __len) 1131*0b57cec5SDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 1132*0b57cec5SDimitry Andric { 1133*0b57cec5SDimitry Andric _Size __z = __loadword<_Size>(__s + 24); 1134*0b57cec5SDimitry Andric _Size __a = __loadword<_Size>(__s) + 1135*0b57cec5SDimitry Andric (__len + __loadword<_Size>(__s + __len - 16)) * __k0; 1136*0b57cec5SDimitry Andric _Size __b = __rotate(__a + __z, 52); 1137*0b57cec5SDimitry Andric _Size __c = __rotate(__a, 37); 1138*0b57cec5SDimitry Andric __a += __loadword<_Size>(__s + 8); 1139*0b57cec5SDimitry Andric __c += __rotate(__a, 7); 1140*0b57cec5SDimitry Andric __a += __loadword<_Size>(__s + 16); 1141*0b57cec5SDimitry Andric _Size __vf = __a + __z; 1142*0b57cec5SDimitry Andric _Size __vs = __b + __rotate(__a, 31) + __c; 1143*0b57cec5SDimitry Andric __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); 1144*0b57cec5SDimitry Andric __z += __loadword<_Size>(__s + __len - 8); 1145*0b57cec5SDimitry Andric __b = __rotate(__a + __z, 52); 1146*0b57cec5SDimitry Andric __c = __rotate(__a, 37); 1147*0b57cec5SDimitry Andric __a += __loadword<_Size>(__s + __len - 24); 1148*0b57cec5SDimitry Andric __c += __rotate(__a, 7); 1149*0b57cec5SDimitry Andric __a += __loadword<_Size>(__s + __len - 16); 1150*0b57cec5SDimitry Andric _Size __wf = __a + __z; 1151*0b57cec5SDimitry Andric _Size __ws = __b + __rotate(__a, 31) + __c; 1152*0b57cec5SDimitry Andric _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); 1153*0b57cec5SDimitry Andric return __shift_mix(__r * __k0 + __vs) * __k2; 1154*0b57cec5SDimitry Andric } 1155*0b57cec5SDimitry Andric}; 1156*0b57cec5SDimitry Andric 1157*0b57cec5SDimitry Andric// cityhash64 1158*0b57cec5SDimitry Andrictemplate <class _Size> 1159*0b57cec5SDimitry Andric_Size 1160*0b57cec5SDimitry Andric__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) 1161*0b57cec5SDimitry Andric{ 1162*0b57cec5SDimitry Andric const char* __s = static_cast<const char*>(__key); 1163*0b57cec5SDimitry Andric if (__len <= 32) { 1164*0b57cec5SDimitry Andric if (__len <= 16) { 1165*0b57cec5SDimitry Andric return __hash_len_0_to_16(__s, __len); 1166*0b57cec5SDimitry Andric } else { 1167*0b57cec5SDimitry Andric return __hash_len_17_to_32(__s, __len); 1168*0b57cec5SDimitry Andric } 1169*0b57cec5SDimitry Andric } else if (__len <= 64) { 1170*0b57cec5SDimitry Andric return __hash_len_33_to_64(__s, __len); 1171*0b57cec5SDimitry Andric } 1172*0b57cec5SDimitry Andric 1173*0b57cec5SDimitry Andric // For strings over 64 bytes we hash the end first, and then as we 1174*0b57cec5SDimitry Andric // loop we keep 56 bytes of state: v, w, x, y, and z. 1175*0b57cec5SDimitry Andric _Size __x = __loadword<_Size>(__s + __len - 40); 1176*0b57cec5SDimitry Andric _Size __y = __loadword<_Size>(__s + __len - 16) + 1177*0b57cec5SDimitry Andric __loadword<_Size>(__s + __len - 56); 1178*0b57cec5SDimitry Andric _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, 1179*0b57cec5SDimitry Andric __loadword<_Size>(__s + __len - 24)); 1180*0b57cec5SDimitry Andric pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); 1181*0b57cec5SDimitry Andric pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); 1182*0b57cec5SDimitry Andric __x = __x * __k1 + __loadword<_Size>(__s); 1183*0b57cec5SDimitry Andric 1184*0b57cec5SDimitry Andric // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. 1185*0b57cec5SDimitry Andric __len = (__len - 1) & ~static_cast<_Size>(63); 1186*0b57cec5SDimitry Andric do { 1187*0b57cec5SDimitry Andric __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; 1188*0b57cec5SDimitry Andric __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; 1189*0b57cec5SDimitry Andric __x ^= __w.second; 1190*0b57cec5SDimitry Andric __y += __v.first + __loadword<_Size>(__s + 40); 1191*0b57cec5SDimitry Andric __z = __rotate(__z + __w.first, 33) * __k1; 1192*0b57cec5SDimitry Andric __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); 1193*0b57cec5SDimitry Andric __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, 1194*0b57cec5SDimitry Andric __y + __loadword<_Size>(__s + 16)); 1195*0b57cec5SDimitry Andric std::swap(__z, __x); 1196*0b57cec5SDimitry Andric __s += 64; 1197*0b57cec5SDimitry Andric __len -= 64; 1198*0b57cec5SDimitry Andric } while (__len != 0); 1199*0b57cec5SDimitry Andric return __hash_len_16( 1200*0b57cec5SDimitry Andric __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, 1201*0b57cec5SDimitry Andric __hash_len_16(__v.second, __w.second) + __x); 1202*0b57cec5SDimitry Andric} 1203*0b57cec5SDimitry Andric 1204*0b57cec5SDimitry Andrictemplate <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> 1205*0b57cec5SDimitry Andricstruct __scalar_hash; 1206*0b57cec5SDimitry Andric 1207*0b57cec5SDimitry Andrictemplate <class _Tp> 1208*0b57cec5SDimitry Andricstruct __scalar_hash<_Tp, 0> 1209*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1210*0b57cec5SDimitry Andric{ 1211*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1212*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1213*0b57cec5SDimitry Andric { 1214*0b57cec5SDimitry Andric union 1215*0b57cec5SDimitry Andric { 1216*0b57cec5SDimitry Andric _Tp __t; 1217*0b57cec5SDimitry Andric size_t __a; 1218*0b57cec5SDimitry Andric } __u; 1219*0b57cec5SDimitry Andric __u.__a = 0; 1220*0b57cec5SDimitry Andric __u.__t = __v; 1221*0b57cec5SDimitry Andric return __u.__a; 1222*0b57cec5SDimitry Andric } 1223*0b57cec5SDimitry Andric}; 1224*0b57cec5SDimitry Andric 1225*0b57cec5SDimitry Andrictemplate <class _Tp> 1226*0b57cec5SDimitry Andricstruct __scalar_hash<_Tp, 1> 1227*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1228*0b57cec5SDimitry Andric{ 1229*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1230*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1231*0b57cec5SDimitry Andric { 1232*0b57cec5SDimitry Andric union 1233*0b57cec5SDimitry Andric { 1234*0b57cec5SDimitry Andric _Tp __t; 1235*0b57cec5SDimitry Andric size_t __a; 1236*0b57cec5SDimitry Andric } __u; 1237*0b57cec5SDimitry Andric __u.__t = __v; 1238*0b57cec5SDimitry Andric return __u.__a; 1239*0b57cec5SDimitry Andric } 1240*0b57cec5SDimitry Andric}; 1241*0b57cec5SDimitry Andric 1242*0b57cec5SDimitry Andrictemplate <class _Tp> 1243*0b57cec5SDimitry Andricstruct __scalar_hash<_Tp, 2> 1244*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1245*0b57cec5SDimitry Andric{ 1246*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1247*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1248*0b57cec5SDimitry Andric { 1249*0b57cec5SDimitry Andric union 1250*0b57cec5SDimitry Andric { 1251*0b57cec5SDimitry Andric _Tp __t; 1252*0b57cec5SDimitry Andric struct 1253*0b57cec5SDimitry Andric { 1254*0b57cec5SDimitry Andric size_t __a; 1255*0b57cec5SDimitry Andric size_t __b; 1256*0b57cec5SDimitry Andric } __s; 1257*0b57cec5SDimitry Andric } __u; 1258*0b57cec5SDimitry Andric __u.__t = __v; 1259*0b57cec5SDimitry Andric return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 1260*0b57cec5SDimitry Andric } 1261*0b57cec5SDimitry Andric}; 1262*0b57cec5SDimitry Andric 1263*0b57cec5SDimitry Andrictemplate <class _Tp> 1264*0b57cec5SDimitry Andricstruct __scalar_hash<_Tp, 3> 1265*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1266*0b57cec5SDimitry Andric{ 1267*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1268*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1269*0b57cec5SDimitry Andric { 1270*0b57cec5SDimitry Andric union 1271*0b57cec5SDimitry Andric { 1272*0b57cec5SDimitry Andric _Tp __t; 1273*0b57cec5SDimitry Andric struct 1274*0b57cec5SDimitry Andric { 1275*0b57cec5SDimitry Andric size_t __a; 1276*0b57cec5SDimitry Andric size_t __b; 1277*0b57cec5SDimitry Andric size_t __c; 1278*0b57cec5SDimitry Andric } __s; 1279*0b57cec5SDimitry Andric } __u; 1280*0b57cec5SDimitry Andric __u.__t = __v; 1281*0b57cec5SDimitry Andric return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 1282*0b57cec5SDimitry Andric } 1283*0b57cec5SDimitry Andric}; 1284*0b57cec5SDimitry Andric 1285*0b57cec5SDimitry Andrictemplate <class _Tp> 1286*0b57cec5SDimitry Andricstruct __scalar_hash<_Tp, 4> 1287*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1288*0b57cec5SDimitry Andric{ 1289*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1290*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1291*0b57cec5SDimitry Andric { 1292*0b57cec5SDimitry Andric union 1293*0b57cec5SDimitry Andric { 1294*0b57cec5SDimitry Andric _Tp __t; 1295*0b57cec5SDimitry Andric struct 1296*0b57cec5SDimitry Andric { 1297*0b57cec5SDimitry Andric size_t __a; 1298*0b57cec5SDimitry Andric size_t __b; 1299*0b57cec5SDimitry Andric size_t __c; 1300*0b57cec5SDimitry Andric size_t __d; 1301*0b57cec5SDimitry Andric } __s; 1302*0b57cec5SDimitry Andric } __u; 1303*0b57cec5SDimitry Andric __u.__t = __v; 1304*0b57cec5SDimitry Andric return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 1305*0b57cec5SDimitry Andric } 1306*0b57cec5SDimitry Andric}; 1307*0b57cec5SDimitry Andric 1308*0b57cec5SDimitry Andricstruct _PairT { 1309*0b57cec5SDimitry Andric size_t first; 1310*0b57cec5SDimitry Andric size_t second; 1311*0b57cec5SDimitry Andric}; 1312*0b57cec5SDimitry Andric 1313*0b57cec5SDimitry Andric_LIBCPP_INLINE_VISIBILITY 1314*0b57cec5SDimitry Andricinline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { 1315*0b57cec5SDimitry Andric typedef __scalar_hash<_PairT> _HashT; 1316*0b57cec5SDimitry Andric const _PairT __p = {__lhs, __rhs}; 1317*0b57cec5SDimitry Andric return _HashT()(__p); 1318*0b57cec5SDimitry Andric} 1319*0b57cec5SDimitry Andric 1320*0b57cec5SDimitry Andrictemplate<class _Tp> 1321*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<_Tp*> 1322*0b57cec5SDimitry Andric : public unary_function<_Tp*, size_t> 1323*0b57cec5SDimitry Andric{ 1324*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1325*0b57cec5SDimitry Andric size_t operator()(_Tp* __v) const _NOEXCEPT 1326*0b57cec5SDimitry Andric { 1327*0b57cec5SDimitry Andric union 1328*0b57cec5SDimitry Andric { 1329*0b57cec5SDimitry Andric _Tp* __t; 1330*0b57cec5SDimitry Andric size_t __a; 1331*0b57cec5SDimitry Andric } __u; 1332*0b57cec5SDimitry Andric __u.__t = __v; 1333*0b57cec5SDimitry Andric return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u)); 1334*0b57cec5SDimitry Andric } 1335*0b57cec5SDimitry Andric}; 1336*0b57cec5SDimitry Andric 1337*0b57cec5SDimitry Andric 1338*0b57cec5SDimitry Andrictemplate <> 1339*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<bool> 1340*0b57cec5SDimitry Andric : public unary_function<bool, size_t> 1341*0b57cec5SDimitry Andric{ 1342*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1343*0b57cec5SDimitry Andric size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1344*0b57cec5SDimitry Andric}; 1345*0b57cec5SDimitry Andric 1346*0b57cec5SDimitry Andrictemplate <> 1347*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<char> 1348*0b57cec5SDimitry Andric : public unary_function<char, size_t> 1349*0b57cec5SDimitry Andric{ 1350*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1351*0b57cec5SDimitry Andric size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1352*0b57cec5SDimitry Andric}; 1353*0b57cec5SDimitry Andric 1354*0b57cec5SDimitry Andrictemplate <> 1355*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<signed char> 1356*0b57cec5SDimitry Andric : public unary_function<signed char, size_t> 1357*0b57cec5SDimitry Andric{ 1358*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1359*0b57cec5SDimitry Andric size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1360*0b57cec5SDimitry Andric}; 1361*0b57cec5SDimitry Andric 1362*0b57cec5SDimitry Andrictemplate <> 1363*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned char> 1364*0b57cec5SDimitry Andric : public unary_function<unsigned char, size_t> 1365*0b57cec5SDimitry Andric{ 1366*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1367*0b57cec5SDimitry Andric size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1368*0b57cec5SDimitry Andric}; 1369*0b57cec5SDimitry Andric 1370*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 1371*0b57cec5SDimitry Andric 1372*0b57cec5SDimitry Andrictemplate <> 1373*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<char16_t> 1374*0b57cec5SDimitry Andric : public unary_function<char16_t, size_t> 1375*0b57cec5SDimitry Andric{ 1376*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1377*0b57cec5SDimitry Andric size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1378*0b57cec5SDimitry Andric}; 1379*0b57cec5SDimitry Andric 1380*0b57cec5SDimitry Andrictemplate <> 1381*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<char32_t> 1382*0b57cec5SDimitry Andric : public unary_function<char32_t, size_t> 1383*0b57cec5SDimitry Andric{ 1384*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1385*0b57cec5SDimitry Andric size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1386*0b57cec5SDimitry Andric}; 1387*0b57cec5SDimitry Andric 1388*0b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 1389*0b57cec5SDimitry Andric 1390*0b57cec5SDimitry Andrictemplate <> 1391*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<wchar_t> 1392*0b57cec5SDimitry Andric : public unary_function<wchar_t, size_t> 1393*0b57cec5SDimitry Andric{ 1394*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1395*0b57cec5SDimitry Andric size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1396*0b57cec5SDimitry Andric}; 1397*0b57cec5SDimitry Andric 1398*0b57cec5SDimitry Andrictemplate <> 1399*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<short> 1400*0b57cec5SDimitry Andric : public unary_function<short, size_t> 1401*0b57cec5SDimitry Andric{ 1402*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1403*0b57cec5SDimitry Andric size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1404*0b57cec5SDimitry Andric}; 1405*0b57cec5SDimitry Andric 1406*0b57cec5SDimitry Andrictemplate <> 1407*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned short> 1408*0b57cec5SDimitry Andric : public unary_function<unsigned short, size_t> 1409*0b57cec5SDimitry Andric{ 1410*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1411*0b57cec5SDimitry Andric size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1412*0b57cec5SDimitry Andric}; 1413*0b57cec5SDimitry Andric 1414*0b57cec5SDimitry Andrictemplate <> 1415*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<int> 1416*0b57cec5SDimitry Andric : public unary_function<int, size_t> 1417*0b57cec5SDimitry Andric{ 1418*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1419*0b57cec5SDimitry Andric size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1420*0b57cec5SDimitry Andric}; 1421*0b57cec5SDimitry Andric 1422*0b57cec5SDimitry Andrictemplate <> 1423*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned int> 1424*0b57cec5SDimitry Andric : public unary_function<unsigned int, size_t> 1425*0b57cec5SDimitry Andric{ 1426*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1427*0b57cec5SDimitry Andric size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1428*0b57cec5SDimitry Andric}; 1429*0b57cec5SDimitry Andric 1430*0b57cec5SDimitry Andrictemplate <> 1431*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<long> 1432*0b57cec5SDimitry Andric : public unary_function<long, size_t> 1433*0b57cec5SDimitry Andric{ 1434*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1435*0b57cec5SDimitry Andric size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1436*0b57cec5SDimitry Andric}; 1437*0b57cec5SDimitry Andric 1438*0b57cec5SDimitry Andrictemplate <> 1439*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned long> 1440*0b57cec5SDimitry Andric : public unary_function<unsigned long, size_t> 1441*0b57cec5SDimitry Andric{ 1442*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1443*0b57cec5SDimitry Andric size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} 1444*0b57cec5SDimitry Andric}; 1445*0b57cec5SDimitry Andric 1446*0b57cec5SDimitry Andrictemplate <> 1447*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<long long> 1448*0b57cec5SDimitry Andric : public __scalar_hash<long long> 1449*0b57cec5SDimitry Andric{ 1450*0b57cec5SDimitry Andric}; 1451*0b57cec5SDimitry Andric 1452*0b57cec5SDimitry Andrictemplate <> 1453*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> 1454*0b57cec5SDimitry Andric : public __scalar_hash<unsigned long long> 1455*0b57cec5SDimitry Andric{ 1456*0b57cec5SDimitry Andric}; 1457*0b57cec5SDimitry Andric 1458*0b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_INT128 1459*0b57cec5SDimitry Andric 1460*0b57cec5SDimitry Andrictemplate <> 1461*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<__int128_t> 1462*0b57cec5SDimitry Andric : public __scalar_hash<__int128_t> 1463*0b57cec5SDimitry Andric{ 1464*0b57cec5SDimitry Andric}; 1465*0b57cec5SDimitry Andric 1466*0b57cec5SDimitry Andrictemplate <> 1467*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> 1468*0b57cec5SDimitry Andric : public __scalar_hash<__uint128_t> 1469*0b57cec5SDimitry Andric{ 1470*0b57cec5SDimitry Andric}; 1471*0b57cec5SDimitry Andric 1472*0b57cec5SDimitry Andric#endif 1473*0b57cec5SDimitry Andric 1474*0b57cec5SDimitry Andrictemplate <> 1475*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<float> 1476*0b57cec5SDimitry Andric : public __scalar_hash<float> 1477*0b57cec5SDimitry Andric{ 1478*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1479*0b57cec5SDimitry Andric size_t operator()(float __v) const _NOEXCEPT 1480*0b57cec5SDimitry Andric { 1481*0b57cec5SDimitry Andric // -0.0 and 0.0 should return same hash 1482*0b57cec5SDimitry Andric if (__v == 0.0f) 1483*0b57cec5SDimitry Andric return 0; 1484*0b57cec5SDimitry Andric return __scalar_hash<float>::operator()(__v); 1485*0b57cec5SDimitry Andric } 1486*0b57cec5SDimitry Andric}; 1487*0b57cec5SDimitry Andric 1488*0b57cec5SDimitry Andrictemplate <> 1489*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<double> 1490*0b57cec5SDimitry Andric : public __scalar_hash<double> 1491*0b57cec5SDimitry Andric{ 1492*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1493*0b57cec5SDimitry Andric size_t operator()(double __v) const _NOEXCEPT 1494*0b57cec5SDimitry Andric { 1495*0b57cec5SDimitry Andric // -0.0 and 0.0 should return same hash 1496*0b57cec5SDimitry Andric if (__v == 0.0) 1497*0b57cec5SDimitry Andric return 0; 1498*0b57cec5SDimitry Andric return __scalar_hash<double>::operator()(__v); 1499*0b57cec5SDimitry Andric } 1500*0b57cec5SDimitry Andric}; 1501*0b57cec5SDimitry Andric 1502*0b57cec5SDimitry Andrictemplate <> 1503*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<long double> 1504*0b57cec5SDimitry Andric : public __scalar_hash<long double> 1505*0b57cec5SDimitry Andric{ 1506*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1507*0b57cec5SDimitry Andric size_t operator()(long double __v) const _NOEXCEPT 1508*0b57cec5SDimitry Andric { 1509*0b57cec5SDimitry Andric // -0.0 and 0.0 should return same hash 1510*0b57cec5SDimitry Andric if (__v == 0.0L) 1511*0b57cec5SDimitry Andric return 0; 1512*0b57cec5SDimitry Andric#if defined(__i386__) 1513*0b57cec5SDimitry Andric // Zero out padding bits 1514*0b57cec5SDimitry Andric union 1515*0b57cec5SDimitry Andric { 1516*0b57cec5SDimitry Andric long double __t; 1517*0b57cec5SDimitry Andric struct 1518*0b57cec5SDimitry Andric { 1519*0b57cec5SDimitry Andric size_t __a; 1520*0b57cec5SDimitry Andric size_t __b; 1521*0b57cec5SDimitry Andric size_t __c; 1522*0b57cec5SDimitry Andric size_t __d; 1523*0b57cec5SDimitry Andric } __s; 1524*0b57cec5SDimitry Andric } __u; 1525*0b57cec5SDimitry Andric __u.__s.__a = 0; 1526*0b57cec5SDimitry Andric __u.__s.__b = 0; 1527*0b57cec5SDimitry Andric __u.__s.__c = 0; 1528*0b57cec5SDimitry Andric __u.__s.__d = 0; 1529*0b57cec5SDimitry Andric __u.__t = __v; 1530*0b57cec5SDimitry Andric return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; 1531*0b57cec5SDimitry Andric#elif defined(__x86_64__) 1532*0b57cec5SDimitry Andric // Zero out padding bits 1533*0b57cec5SDimitry Andric union 1534*0b57cec5SDimitry Andric { 1535*0b57cec5SDimitry Andric long double __t; 1536*0b57cec5SDimitry Andric struct 1537*0b57cec5SDimitry Andric { 1538*0b57cec5SDimitry Andric size_t __a; 1539*0b57cec5SDimitry Andric size_t __b; 1540*0b57cec5SDimitry Andric } __s; 1541*0b57cec5SDimitry Andric } __u; 1542*0b57cec5SDimitry Andric __u.__s.__a = 0; 1543*0b57cec5SDimitry Andric __u.__s.__b = 0; 1544*0b57cec5SDimitry Andric __u.__t = __v; 1545*0b57cec5SDimitry Andric return __u.__s.__a ^ __u.__s.__b; 1546*0b57cec5SDimitry Andric#else 1547*0b57cec5SDimitry Andric return __scalar_hash<long double>::operator()(__v); 1548*0b57cec5SDimitry Andric#endif 1549*0b57cec5SDimitry Andric } 1550*0b57cec5SDimitry Andric}; 1551*0b57cec5SDimitry Andric 1552*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 11 1553*0b57cec5SDimitry Andric 1554*0b57cec5SDimitry Andrictemplate <class _Tp, bool = is_enum<_Tp>::value> 1555*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS __enum_hash 1556*0b57cec5SDimitry Andric : public unary_function<_Tp, size_t> 1557*0b57cec5SDimitry Andric{ 1558*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1559*0b57cec5SDimitry Andric size_t operator()(_Tp __v) const _NOEXCEPT 1560*0b57cec5SDimitry Andric { 1561*0b57cec5SDimitry Andric typedef typename underlying_type<_Tp>::type type; 1562*0b57cec5SDimitry Andric return hash<type>{}(static_cast<type>(__v)); 1563*0b57cec5SDimitry Andric } 1564*0b57cec5SDimitry Andric}; 1565*0b57cec5SDimitry Andrictemplate <class _Tp> 1566*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> { 1567*0b57cec5SDimitry Andric __enum_hash() = delete; 1568*0b57cec5SDimitry Andric __enum_hash(__enum_hash const&) = delete; 1569*0b57cec5SDimitry Andric __enum_hash& operator=(__enum_hash const&) = delete; 1570*0b57cec5SDimitry Andric}; 1571*0b57cec5SDimitry Andric 1572*0b57cec5SDimitry Andrictemplate <class _Tp> 1573*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> 1574*0b57cec5SDimitry Andric{ 1575*0b57cec5SDimitry Andric}; 1576*0b57cec5SDimitry Andric#endif 1577*0b57cec5SDimitry Andric 1578*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 1579*0b57cec5SDimitry Andric 1580*0b57cec5SDimitry Andrictemplate <> 1581*0b57cec5SDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> 1582*0b57cec5SDimitry Andric : public unary_function<nullptr_t, size_t> 1583*0b57cec5SDimitry Andric{ 1584*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1585*0b57cec5SDimitry Andric size_t operator()(nullptr_t) const _NOEXCEPT { 1586*0b57cec5SDimitry Andric return 662607004ull; 1587*0b57cec5SDimitry Andric } 1588*0b57cec5SDimitry Andric}; 1589*0b57cec5SDimitry Andric#endif 1590*0b57cec5SDimitry Andric 1591*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1592*0b57cec5SDimitry Andrictemplate <class _Key, class _Hash> 1593*0b57cec5SDimitry Andricusing __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool, 1594*0b57cec5SDimitry Andric is_copy_constructible<_Hash>::value && 1595*0b57cec5SDimitry Andric is_move_constructible<_Hash>::value && 1596*0b57cec5SDimitry Andric __invokable_r<size_t, _Hash, _Key const&>::value 1597*0b57cec5SDimitry Andric>; 1598*0b57cec5SDimitry Andric 1599*0b57cec5SDimitry Andrictemplate <class _Key, class _Hash = std::hash<_Key> > 1600*0b57cec5SDimitry Andricusing __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool, 1601*0b57cec5SDimitry Andric __check_hash_requirements<_Key, _Hash>::value && 1602*0b57cec5SDimitry Andric is_default_constructible<_Hash>::value 1603*0b57cec5SDimitry Andric>; 1604*0b57cec5SDimitry Andric 1605*0b57cec5SDimitry Andric#if _LIBCPP_STD_VER > 14 1606*0b57cec5SDimitry Andrictemplate <class _Type, class> 1607*0b57cec5SDimitry Andricusing __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type; 1608*0b57cec5SDimitry Andric 1609*0b57cec5SDimitry Andrictemplate <class _Type, class ..._Keys> 1610*0b57cec5SDimitry Andricusing __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type, 1611*0b57cec5SDimitry Andric typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type 1612*0b57cec5SDimitry Andric>; 1613*0b57cec5SDimitry Andric#else 1614*0b57cec5SDimitry Andrictemplate <class _Type, class ...> 1615*0b57cec5SDimitry Andricusing __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type; 1616*0b57cec5SDimitry Andric#endif 1617*0b57cec5SDimitry Andric 1618*0b57cec5SDimitry Andric#endif // !_LIBCPP_CXX03_LANG 1619*0b57cec5SDimitry Andric 1620*0b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 1621*0b57cec5SDimitry Andric 1622*0b57cec5SDimitry Andric#endif // _LIBCPP_UTILITY 1623