2 //===-------------------------- utility -----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_UTILITY
12 #define _LIBCPP_UTILITY
26 template<class T> bool operator!=(const T&, const T&);
27 template<class T> bool operator> (const T&, const T&);
28 template<class T> bool operator<=(const T&, const T&);
29 template<class T> bool operator>=(const T&, const T&);
34 swap(T& a, T& b) noexcept(is_nothrow_move_constructible<T>::value &&
35 is_nothrow_move_assignable<T>::value);
37 template <class T, size_t N>
39 swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
41 template <class T> T&& forward(typename remove_reference<T>::type& t) noexcept; // constexpr in C++14
42 template <class T> T&& forward(typename remove_reference<T>::type&& t) noexcept; // constexpr in C++14
44 template <class T> typename remove_reference<T>::type&& move(T&&) noexcept; // constexpr in C++14
49 !is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
53 move_if_noexcept(T& x) noexcept; // constexpr in C++14
55 template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
57 template <class T1, class T2>
60 typedef T1 first_type;
61 typedef T2 second_type;
66 pair(const pair&) = default;
67 pair(pair&&) = default;
69 pair(const T1& x, const T2& y); // constexpr in C++14
70 template <class U, class V> pair(U&& x, V&& y); // constexpr in C++14
71 template <class U, class V> pair(const pair<U, V>& p); // constexpr in C++14
72 template <class U, class V> pair(pair<U, V>&& p); // constexpr in C++14
73 template <class... Args1, class... Args2>
74 pair(piecewise_construct_t, tuple<Args1...> first_args,
75 tuple<Args2...> second_args);
77 template <class U, class V> pair& operator=(const pair<U, V>& p);
78 pair& operator=(pair&& p) noexcept(is_nothrow_move_assignable<T1>::value &&
79 is_nothrow_move_assignable<T2>::value);
80 template <class U, class V> pair& operator=(pair<U, V>&& p);
82 void swap(pair& p) noexcept(noexcept(swap(first, p.first)) &&
83 noexcept(swap(second, p.second)));
86 template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
87 template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
88 template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
89 template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
90 template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
91 template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14
93 template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14
94 template <class T1, class T2>
96 swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
98 struct piecewise_construct_t { };
99 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
101 template <class T> class tuple_size;
102 template <size_t I, class T> class tuple_element;
104 template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
105 template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
106 template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
108 template<size_t I, class T1, class T2>
109 typename tuple_element<I, pair<T1, T2> >::type&
110 get(pair<T1, T2>&) noexcept; // constexpr in C++14
112 template<size_t I, class T1, class T2>
113 const typename const tuple_element<I, pair<T1, T2> >::type&
114 get(const pair<T1, T2>&) noexcept; // constexpr in C++14
116 template<size_t I, class T1, class T2>
117 typename tuple_element<I, pair<T1, T2> >::type&&
118 get(pair<T1, T2>&&) noexcept; // constexpr in C++14
120 template<class T1, class T2>
121 constexpr T1& get(pair<T1, T2>&) noexcept; // C++14
123 template<size_t I, class T1, class T2>
124 constexpr T1 const& get(pair<T1, T2> const &) noexcept; // C++14
126 template<size_t I, class T1, class T2>
127 constexpr T1&& get(pair<T1, T2>&&) noexcept; // C++14
131 template<class T, T... I>
132 struct integer_sequence
134 typedef T value_type;
136 static constexpr size_t size() noexcept;
139 template<size_t... I>
140 using index_sequence = integer_sequence<size_t, I...>;
142 template<class T, T N>
143 using make_integer_sequence = integer_sequence<T, 0, 1, ..., N-1>;
145 using make_index_sequence = make_integer_sequence<size_t, N>;
148 using index_sequence_for = make_index_sequence<sizeof...(T)>;
150 template<class T, class U=T>
151 T exchange(T& obj, U&& new_value);
158 #include <type_traits>
160 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
161 #pragma GCC system_header
164 _LIBCPP_BEGIN_NAMESPACE_STD
170 inline _LIBCPP_INLINE_VISIBILITY
172 operator!=(const _Tp& __x, const _Tp& __y)
174 return !(__x == __y);
178 inline _LIBCPP_INLINE_VISIBILITY
180 operator> (const _Tp& __x, const _Tp& __y)
186 inline _LIBCPP_INLINE_VISIBILITY
188 operator<=(const _Tp& __x, const _Tp& __y)
194 inline _LIBCPP_INLINE_VISIBILITY
196 operator>=(const _Tp& __x, const _Tp& __y)
206 template<class _Tp, size_t _Np>
207 inline _LIBCPP_INLINE_VISIBILITY
208 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
210 template <class _ForwardIterator1, class _ForwardIterator2>
211 inline _LIBCPP_INLINE_VISIBILITY
213 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
215 for(; __first1 != __last1; ++__first1, (void) ++__first2)
216 swap(*__first1, *__first2);
220 template<class _Tp, size_t _Np>
221 inline _LIBCPP_INLINE_VISIBILITY
223 swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
225 _VSTD::swap_ranges(__a, __a + _Np, __b);
229 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
230 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
233 !is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value,
237 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
240 move_if_noexcept(_Tp& __x) _NOEXCEPT
242 return _VSTD::move(__x);
245 struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { };
246 #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY)
247 extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
249 constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
252 template <class _T1, class _T2>
253 struct _LIBCPP_TYPE_VIS_ONLY pair
255 typedef _T1 first_type;
256 typedef _T2 second_type;
261 // pair(const pair&) = default;
262 // pair(pair&&) = default;
264 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {}
266 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
267 pair(const _T1& __x, const _T2& __y)
268 : first(__x), second(__y) {}
270 template<class _U1, class _U2>
271 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
272 pair(const pair<_U1, _U2>& __p
273 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
274 ,typename enable_if<is_convertible<const _U1&, _T1>::value &&
275 is_convertible<const _U2&, _T2>::value>::type* = 0
278 : first(__p.first), second(__p.second) {}
280 #if !defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
281 _LIBCPP_INLINE_VISIBILITY
282 pair(const pair& __p) = default;
283 #elif !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || !_LIBCPP_TRIVIAL_PAIR_COPY_CTOR
284 _LIBCPP_INLINE_VISIBILITY
285 pair(const pair& __p)
286 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
287 is_nothrow_copy_constructible<second_type>::value)
294 _LIBCPP_INLINE_VISIBILITY
295 pair& operator=(const pair& __p)
296 _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value &&
297 is_nothrow_copy_assignable<second_type>::value)
304 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
306 template <class _U1, class _U2,
307 class = typename enable_if<is_convertible<_U1, first_type>::value &&
308 is_convertible<_U2, second_type>::value>::type>
309 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
310 pair(_U1&& __u1, _U2&& __u2)
311 : first(_VSTD::forward<_U1>(__u1)),
312 second(_VSTD::forward<_U2>(__u2))
315 template<class _U1, class _U2>
316 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
317 pair(pair<_U1, _U2>&& __p,
318 typename enable_if<is_convertible<_U1, _T1>::value &&
319 is_convertible<_U2, _T2>::value>::type* = 0)
320 : first(_VSTD::forward<_U1>(__p.first)),
321 second(_VSTD::forward<_U2>(__p.second)) {}
323 #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
324 _LIBCPP_INLINE_VISIBILITY
325 pair(pair&& __p) = default;
327 _LIBCPP_INLINE_VISIBILITY
328 pair(pair&& __p) _NOEXCEPT_(is_nothrow_move_constructible<first_type>::value &&
329 is_nothrow_move_constructible<second_type>::value)
330 : first(_VSTD::forward<first_type>(__p.first)),
331 second(_VSTD::forward<second_type>(__p.second))
336 _LIBCPP_INLINE_VISIBILITY
338 operator=(pair&& __p) _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value &&
339 is_nothrow_move_assignable<second_type>::value)
341 first = _VSTD::forward<first_type>(__p.first);
342 second = _VSTD::forward<second_type>(__p.second);
346 #ifndef _LIBCPP_HAS_NO_VARIADICS
348 template<class _Tuple,
349 class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
350 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
352 : first(_VSTD::forward<typename tuple_element<0,
353 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<0>(__p))),
354 second(_VSTD::forward<typename tuple_element<1,
355 typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<1>(__p)))
360 template <class... _Args1, class... _Args2>
361 _LIBCPP_INLINE_VISIBILITY
362 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
363 tuple<_Args2...> __second_args)
364 : pair(__pc, __first_args, __second_args,
365 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
366 typename __make_tuple_indices<sizeof...(_Args2) >::type())
369 template <class _Tuple,
370 class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
371 _LIBCPP_INLINE_VISIBILITY
373 operator=(_Tuple&& __p)
375 typedef typename __make_tuple_types<_Tuple>::type _TupleRef;
376 typedef typename tuple_element<0, _TupleRef>::type _U0;
377 typedef typename tuple_element<1, _TupleRef>::type _U1;
378 first = _VSTD::forward<_U0>(_VSTD::get<0>(__p));
379 second = _VSTD::forward<_U1>(_VSTD::get<1>(__p));
383 #endif // _LIBCPP_HAS_NO_VARIADICS
385 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
386 _LIBCPP_INLINE_VISIBILITY
388 swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable<first_type>::value &&
389 __is_nothrow_swappable<second_type>::value)
392 swap(first, __p.first);
393 swap(second, __p.second);
397 #ifndef _LIBCPP_HAS_NO_VARIADICS
398 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
399 _LIBCPP_INLINE_VISIBILITY
400 pair(piecewise_construct_t,
401 tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
402 __tuple_indices<_I1...>, __tuple_indices<_I2...>);
403 #endif // _LIBCPP_HAS_NO_VARIADICS
406 template <class _T1, class _T2>
407 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
409 operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
411 return __x.first == __y.first && __x.second == __y.second;
414 template <class _T1, class _T2>
415 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
417 operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
419 return !(__x == __y);
422 template <class _T1, class _T2>
423 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
425 operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
427 return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
430 template <class _T1, class _T2>
431 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
433 operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
438 template <class _T1, class _T2>
439 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
441 operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
446 template <class _T1, class _T2>
447 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
449 operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
454 template <class _T1, class _T2>
455 inline _LIBCPP_INLINE_VISIBILITY
458 __is_swappable<_T1>::value &&
459 __is_swappable<_T2>::value,
462 swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
463 _NOEXCEPT_((__is_nothrow_swappable<_T1>::value &&
464 __is_nothrow_swappable<_T2>::value))
469 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
471 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
474 struct __make_pair_return_impl
480 struct __make_pair_return_impl<reference_wrapper<_Tp>>
486 struct __make_pair_return
488 typedef typename __make_pair_return_impl<typename decay<_Tp>::type>::type type;
491 template <class _T1, class _T2>
492 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
493 pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
494 make_pair(_T1&& __t1, _T2&& __t2)
496 return pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
497 (_VSTD::forward<_T1>(__t1), _VSTD::forward<_T2>(__t2));
500 #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
502 template <class _T1, class _T2>
503 inline _LIBCPP_INLINE_VISIBILITY
505 make_pair(_T1 __x, _T2 __y)
507 return pair<_T1, _T2>(__x, __y);
510 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
512 template <class _T1, class _T2>
513 class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> >
514 : public integral_constant<size_t, 2> {};
516 template <class _T1, class _T2>
517 class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> >
523 template <class _T1, class _T2>
524 class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> >
530 template <size_t _Ip> struct __get_pair;
535 template <class _T1, class _T2>
537 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
539 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
541 template <class _T1, class _T2>
543 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
545 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.first;}
547 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
549 template <class _T1, class _T2>
551 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
553 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);}
555 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
561 template <class _T1, class _T2>
563 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
565 get(pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
567 template <class _T1, class _T2>
569 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
571 get(const pair<_T1, _T2>& __p) _NOEXCEPT {return __p.second;}
573 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
575 template <class _T1, class _T2>
577 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
579 get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);}
581 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
584 template <size_t _Ip, class _T1, class _T2>
585 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
586 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
587 get(pair<_T1, _T2>& __p) _NOEXCEPT
589 return __get_pair<_Ip>::get(__p);
592 template <size_t _Ip, class _T1, class _T2>
593 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
594 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
595 get(const pair<_T1, _T2>& __p) _NOEXCEPT
597 return __get_pair<_Ip>::get(__p);
600 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
602 template <size_t _Ip, class _T1, class _T2>
603 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
604 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
605 get(pair<_T1, _T2>&& __p) _NOEXCEPT
607 return __get_pair<_Ip>::get(_VSTD::move(__p));
610 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
612 #if _LIBCPP_STD_VER > 11
613 template <class _T1, class _T2>
614 inline _LIBCPP_INLINE_VISIBILITY
615 constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT
617 return __get_pair<0>::get(__p);
620 template <class _T1, class _T2>
621 inline _LIBCPP_INLINE_VISIBILITY
622 constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT
624 return __get_pair<0>::get(__p);
627 template <class _T1, class _T2>
628 inline _LIBCPP_INLINE_VISIBILITY
629 constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT
631 return __get_pair<0>::get(_VSTD::move(__p));
634 template <class _T1, class _T2>
635 inline _LIBCPP_INLINE_VISIBILITY
636 constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT
638 return __get_pair<1>::get(__p);
641 template <class _T1, class _T2>
642 inline _LIBCPP_INLINE_VISIBILITY
643 constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT
645 return __get_pair<1>::get(__p);
648 template <class _T1, class _T2>
649 inline _LIBCPP_INLINE_VISIBILITY
650 constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT
652 return __get_pair<1>::get(_VSTD::move(__p));
657 #if _LIBCPP_STD_VER > 11
659 template<class _Tp, _Tp... _Ip>
660 struct _LIBCPP_TYPE_VIS_ONLY integer_sequence
662 typedef _Tp value_type;
663 static_assert( is_integral<_Tp>::value,
664 "std::integer_sequence can only be instantiated with an integral type" );
666 _LIBCPP_INLINE_VISIBILITY
669 size() noexcept { return sizeof...(_Ip); }
672 template<size_t... _Ip>
673 using index_sequence = integer_sequence<size_t, _Ip...>;
677 template<typename _Tp, size_t ..._Extra> struct __repeat;
678 template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<integer_sequence<_Tp, _Np...>, _Extra...> {
679 typedef integer_sequence<_Tp,
681 sizeof...(_Np) + _Np...,
682 2 * sizeof...(_Np) + _Np...,
683 3 * sizeof...(_Np) + _Np...,
684 4 * sizeof...(_Np) + _Np...,
685 5 * sizeof...(_Np) + _Np...,
686 6 * sizeof...(_Np) + _Np...,
687 7 * sizeof...(_Np) + _Np...,
691 template<size_t _Np> struct __parity;
692 template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
694 template<> struct __make<0> { typedef integer_sequence<size_t> type; };
695 template<> struct __make<1> { typedef integer_sequence<size_t, 0> type; };
696 template<> struct __make<2> { typedef integer_sequence<size_t, 0, 1> type; };
697 template<> struct __make<3> { typedef integer_sequence<size_t, 0, 1, 2> type; };
698 template<> struct __make<4> { typedef integer_sequence<size_t, 0, 1, 2, 3> type; };
699 template<> struct __make<5> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
700 template<> struct __make<6> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
701 template<> struct __make<7> { typedef integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
703 template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
704 template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
705 template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
706 template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
707 template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
708 template<> 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> {}; };
709 template<> 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> {}; };
710 template<> 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> {}; };
712 template<typename _Tp, typename _Up> struct __convert {
713 template<typename> struct __result;
714 template<_Tp ..._Np> struct __result<integer_sequence<_Tp, _Np...> > { typedef integer_sequence<_Up, _Np...> type; };
716 template<typename _Tp> struct __convert<_Tp, _Tp> { template<typename _Up> struct __result { typedef _Up type; }; };
720 template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked =
721 typename __detail::__convert<size_t, _Tp>::template __result<typename __detail::__make<_Np>::type>::type;
723 template <class _Tp, _Tp _Ep>
724 struct __make_integer_sequence
726 static_assert(is_integral<_Tp>::value,
727 "std::make_integer_sequence can only be instantiated with an integral type" );
728 static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative");
729 typedef __make_integer_sequence_unchecked<_Tp, _Ep> type;
732 template<class _Tp, _Tp _Np>
733 using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type;
736 using make_index_sequence = make_integer_sequence<size_t, _Np>;
738 template<class... _Tp>
739 using index_sequence_for = make_index_sequence<sizeof...(_Tp)>;
741 #endif // _LIBCPP_STD_VER > 11
743 #if _LIBCPP_STD_VER > 11
744 template<class _T1, class _T2 = _T1>
745 inline _LIBCPP_INLINE_VISIBILITY
746 _T1 exchange(_T1& __obj, _T2 && __new_value)
748 _T1 __old_value = _VSTD::move(__obj);
749 __obj = _VSTD::forward<_T2>(__new_value);
752 #endif // _LIBCPP_STD_VER > 11
754 _LIBCPP_END_NAMESPACE_STD
756 #endif // _LIBCPP_UTILITY