diff --git a/LICENSE.md b/LICENSE.md index 65eea30..c708511 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -121,9 +121,3 @@ to assume any extra rights that may not actually be granted) for it here: Popcorn's UEFI loader uses code from Intel's EFI Application toolkit. Relevant code includes license statements at the top of each file. - -# Vendored 'external' works - -The `external` directory has several libraries' built outputs vendored into it. -All the relevant licenses have been copied into the `external/licenses` -directory for reference. diff --git a/external/include/c++/v1/__bit_reference b/external/include/c++/v1/__bit_reference deleted file mode 100644 index c208af2..0000000 --- a/external/include/c++/v1/__bit_reference +++ /dev/null @@ -1,1281 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___BIT_REFERENCE -#define _LIBCPP___BIT_REFERENCE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class __bit_iterator; -template class __bit_const_reference; - -template -struct __has_storage_type -{ - static const bool value = false; -}; - -template ::value> -class __bit_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; - - __storage_pointer __seg_; - __storage_type __mask_; - - friend typename _Cp::__self; - - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, false>; -public: - _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT - {return static_cast(*__seg_ & __mask_);} - _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT - {return !static_cast(*this);} - - _LIBCPP_INLINE_VISIBILITY - __bit_reference& operator=(bool __x) _NOEXCEPT - { - if (__x) - *__seg_ |= __mask_; - else - *__seg_ &= ~__mask_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT - {return operator=(static_cast(__x));} - - _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;} - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, false>(__seg_, static_cast(__ctz(__mask_)));} -private: - _LIBCPP_INLINE_VISIBILITY - __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} -}; - -template -class __bit_reference<_Cp, false> -{ -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; -} - -template -class __bit_const_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__const_storage_pointer __storage_pointer; - - __storage_pointer __seg_; - __storage_type __mask_; - - friend typename _Cp::__self; - friend class __bit_iterator<_Cp, true>; -public: - _LIBCPP_INLINE_VISIBILITY - __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT - : __seg_(__x.__seg_), __mask_(__x.__mask_) {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT - {return static_cast(*__seg_ & __mask_);} - - _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, true>(__seg_, static_cast(__ctz(__mask_)));} -private: - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR - __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} - - __bit_const_reference& operator=(const __bit_const_reference& __x); -}; - -// find - -template -__bit_iterator<_Cp, _IsConst> -__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - if (*__first.__seg_) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(*__first.__seg_))); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - return _It(__first.__seg_, static_cast(__n)); -} - -template -__bit_iterator<_Cp, _IsConst> -__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - { - __storage_type __b = ~*__first.__seg_; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast(_VSTD::__ctz(__b))); - } - return _It(__first.__seg_, static_cast(__n)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, _IsConst> -find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) -{ - if (static_cast(__value_)) - return __find_bool_true(__first, static_cast(__last - __first)); - return __find_bool_false(__first, static_cast(__last - __first)); -} - -// count - -template -typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__popcount(*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__popcount(*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__popcount(*__first.__seg_ & __m); - } - return __r; -} - -template -typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__popcount(~*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__popcount(~*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__popcount(~*__first.__seg_ & __m); - } - return __r; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __bit_iterator<_Cp, _IsConst>::difference_type -count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) -{ - if (static_cast(__value_)) - return __count_bool_true(__first, static_cast(__last - __first)); - return __count_bool_false(__first, static_cast(__last - __first)); -} - -// fill_n - -template -void -__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ &= ~__m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), 0, __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ &= ~__m; - } -} - -template -void -__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ |= __m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memset(_VSTD::__to_raw_pointer(__first.__seg_), -1, __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ |= __m; - } -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) -{ - if (__n > 0) - { - if (__value_) - __fill_n_true(__first, __n); - else - __fill_n_false(__first, __n); - } -} - -// fill - -template -inline _LIBCPP_INLINE_VISIBILITY -void -fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_) -{ - _VSTD::fill_n(__first, static_cast(__last - __first), __value_); -} - -// copy - -template -__bit_iterator<_Cp, false> -__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __nw = __n / __bits_per_word; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__first.__seg_), - __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - __result.__seg_ += __nw; - // do last word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(__n); - } - } - return __result; -} - -template -__bit_iterator<_Cp, false> -__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - static const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); - else - *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); - __result.__ctz_ = static_cast(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b = *__first.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - ++__result.__seg_; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b >> __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __dn; - __result.__ctz_ = static_cast(__n); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__first.__ctz_ == __result.__ctz_) - return __copy_aligned(__first, __last, __result); - return __copy_unaligned(__first, __last, __result); -} - -// copy_backward - -template -__bit_iterator<_Cp, false> -__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); - __storage_type __b = *__last.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ == 0 || __n == 0 - // do middle words - __storage_type __nw = __n / __bits_per_word; - __result.__seg_ -= __nw; - __last.__seg_ -= __nw; - _VSTD::memmove(_VSTD::__to_raw_pointer(__result.__seg_), - _VSTD::__to_raw_pointer(__last.__seg_), - __nw * sizeof(__storage_type)); - __n -= __nw * __bits_per_word; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - *--__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); - } - } - return __result; -} - -template -__bit_iterator<_Cp, false> -__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz_l = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); - __storage_type __b = *__last.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min(__dn, static_cast(__result.__ctz_)); - if (__ddn > 0) - { - __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __last.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - else - *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); - __result.__ctz_ = static_cast(((-__ddn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - } - if (__dn > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast(-__dn & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - __last.__ctz_ -= __dn + __ddn; - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - } - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ != 0 || __n == 0 - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) >> __clz_r; - for (; __n >= __bits_per_word; __n -= __bits_per_word) - { - __storage_type __b = *--__last.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __clz_r; - *--__result.__seg_ &= __m; - *__result.__seg_ |= __b << __result.__ctz_; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __dn = _VSTD::min(__n, static_cast(__result.__ctz_)); - __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); - __result.__ctz_ = static_cast(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast(-__n & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__last.__ctz_ == __result.__ctz_) - return __copy_backward_aligned(__first, __last, __result); - return __copy_backward_unaligned(__first, __last, __result); -} - -// move - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy(__first, __last, __result); -} - -// move_backward - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy_backward(__first, __last, __result); -} - -// swap_ranges - -template -__bit_iterator<__C2, false> -__swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) -{ - typedef __bit_iterator<__C1, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) - swap(*__first.__seg_, *__result.__seg_); - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__ctz_ = static_cast(__n); - } - } - return __result; -} - -template -__bit_iterator<__C2, false> -__swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1, false> __last, - __bit_iterator<__C2, false> __result) -{ - typedef __bit_iterator<__C1, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - { - unsigned __s = __result.__ctz_ - __first.__ctz_; - *__result.__seg_ |= __b1 << __s; - *__first.__seg_ |= __b2 >> __s; - } - else - { - unsigned __s = __first.__ctz_ - __result.__ctz_; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - } - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - unsigned __s = __first.__ctz_ + __ddn; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - __result.__ctz_ = static_cast(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b1 = *__first.__seg_; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ = __b2 >> __result.__ctz_; - ++__result.__seg_; - __b2 = *__result.__seg_ & ~__m; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b1 >> __clz_r; - *__first.__seg_ |= __b2 << __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ |= __b2 >> __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 >> __dn; - *__first.__seg_ |= __b2 << __dn; - __result.__ctz_ = static_cast(__n); - } - } - } - return __result; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<__C2, false> -swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __last1, - __bit_iterator<__C2, false> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return __swap_ranges_aligned(__first1, __last1, __first2); - return __swap_ranges_unaligned(__first1, __last1, __first2); -} - -// rotate - -template -struct __bit_array -{ - typedef typename _Cp::difference_type difference_type; - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; - typedef typename _Cp::iterator iterator; - static const unsigned __bits_per_word = _Cp::__bits_per_word; - static const unsigned _Np = 4; - - difference_type __size_; - __storage_type __word_[_Np]; - - _LIBCPP_INLINE_VISIBILITY static difference_type capacity() - {return static_cast(_Np * __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} - _LIBCPP_INLINE_VISIBILITY iterator begin() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); - } - _LIBCPP_INLINE_VISIBILITY iterator end() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, - static_cast(__size_ % __bits_per_word)); - } -}; - -template -__bit_iterator<_Cp, false> -rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) -{ - typedef __bit_iterator<_Cp, false> _I1; - typedef typename _I1::difference_type difference_type; - difference_type __d1 = __middle - __first; - difference_type __d2 = __last - __middle; - _I1 __r = __first + __d2; - while (__d1 != 0 && __d2 != 0) - { - if (__d1 <= __d2) - { - if (__d1 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d1); - _VSTD::copy(__first, __middle, __b.begin()); - _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle); - __first = __middle; - __middle = __mp; - __d2 -= __d1; - } - } - else - { - if (__d2 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d2); - _VSTD::copy(__middle, __last, __b.begin()); - _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = __first + __d2; - _VSTD::swap_ranges(__first, __mp, __middle); - __first = __mp; - __d1 -= __d2; - } - } - } - return __r; -} - -// equal - -template -bool -__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first1.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - if (__first2.__ctz_ > __first1.__ctz_) - { - if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) - return false; - } - else - { - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) - return false; - } - __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast((__ddn + __first2.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) - return false; - __first2.__ctz_ = static_cast(__dn); - } - ++__first1.__seg_; - // __first1.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __m = ~__storage_type(0) << __first2.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) - { - __storage_type __b = *__first1.__seg_; - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - ++__first2.__seg_; - if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) - return false; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first1.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast(__clz_r)); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast((__dn + __first2.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (__b >> __dn)) - return false; - } - } - } - return true; -} - -template -bool -__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - static const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - ++__first2.__seg_; - ++__first1.__seg_; - // __first1.__ctz_ = 0; - // __first2.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // __first2.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) - if (*__first2.__seg_ != *__first1.__seg_) - return false; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - } - } - return true; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return __equal_aligned(__first1, __last1, __first2); - return __equal_unaligned(__first1, __last1, __first2); -} - -template -class __bit_iterator -{ -public: - typedef typename _Cp::difference_type difference_type; - typedef bool value_type; - typedef __bit_iterator pointer; - typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference; - typedef random_access_iterator_tag iterator_category; - -private: - typedef typename _Cp::__storage_type __storage_type; - typedef typename conditional<_IsConst, typename _Cp::__const_storage_pointer, - typename _Cp::__storage_pointer>::type __storage_pointer; - static const unsigned __bits_per_word = _Cp::__bits_per_word; - - __storage_pointer __seg_; - unsigned __ctz_; - -public: - _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __seg_(nullptr), __ctz_(0) -#endif - {} - - _LIBCPP_INLINE_VISIBILITY - __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT - : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT - {return reference(__seg_, __storage_type(1) << __ctz_);} - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++() - { - if (__ctz_ != __bits_per_word-1) - ++__ctz_; - else - { - __ctz_ = 0; - ++__seg_; - } - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int) - { - __bit_iterator __tmp = *this; - ++(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--() - { - if (__ctz_ != 0) - --__ctz_; - else - { - __ctz_ = __bits_per_word - 1; - --__seg_; - } - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int) - { - __bit_iterator __tmp = *this; - --(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n) - { - if (__n >= 0) - __seg_ += (__n + __ctz_) / __bits_per_word; - else - __seg_ += static_cast(__n - __bits_per_word + __ctz_ + 1) - / static_cast(__bits_per_word); - __n &= (__bits_per_word - 1); - __ctz_ = static_cast((__n + __ctz_) % __bits_per_word); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n) - { - return *this += -__n; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const - { - __bit_iterator __t(*this); - __t += __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const - { - __bit_iterator __t(*this); - __t -= __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;} - - _LIBCPP_INLINE_VISIBILITY - friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y) - {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x == __y);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) - {return __y < __x;} - - _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__y < __x);} - - _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x < __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT - : __seg_(__s), __ctz_(__ctz) {} - - friend typename _Cp::__self; - - friend class __bit_reference<_Cp>; - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, true>; - template friend struct __bit_array; - template friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - template friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> __swap_ranges_unaligned(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>, - __bit_iterator<__C1, false>, - __bit_iterator<__C2, false>); - template friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>); - template friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend bool equal(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); - template friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, - typename _Dp::size_type); - template friend typename __bit_iterator<_Dp, _IC>::difference_type - __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); - template friend typename __bit_iterator<_Dp, _IC>::difference_type - __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); -}; - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___BIT_REFERENCE diff --git a/external/include/c++/v1/__bsd_locale_defaults.h b/external/include/c++/v1/__bsd_locale_defaults.h deleted file mode 100644 index cbc407d..0000000 --- a/external/include/c++/v1/__bsd_locale_defaults.h +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -//===---------------------- __bsd_locale_defaults.h -----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// The BSDs have lots of *_l functions. We don't want to define those symbols -// on other platforms though, for fear of conflicts with user code. So here, -// we will define the mapping from an internal macro to the real BSD symbol. -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H -#define _LIBCPP_BSD_LOCALE_DEFAULTS_H - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc) -#define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc) -#define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc) -#define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc) -#define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc) -#define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc) -#define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l) -#define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l) -#define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l) -#define __libcpp_localeconv_l(l) localeconv_l(l) -#define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l) -#define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__) -#define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__) -#define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__) - -#endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H diff --git a/external/include/c++/v1/__bsd_locale_fallbacks.h b/external/include/c++/v1/__bsd_locale_fallbacks.h deleted file mode 100644 index 3097b01..0000000 --- a/external/include/c++/v1/__bsd_locale_fallbacks.h +++ /dev/null @@ -1,140 +0,0 @@ -// -*- C++ -*- -//===---------------------- __bsd_locale_fallbacks.h ----------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// The BSDs have lots of *_l functions. This file provides reimplementations -// of those functions for non-BSD platforms. -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H -#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H - -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -inline _LIBCPP_INLINE_VISIBILITY -decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return MB_CUR_MAX; -} - -inline _LIBCPP_INLINE_VISIBILITY -wint_t __libcpp_btowc_l(int __c, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return btowc(__c); -} - -inline _LIBCPP_INLINE_VISIBILITY -int __libcpp_wctob_l(wint_t __c, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wctob(__c); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, - size_t __len, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wcsnrtombs(__dest, __src, __nwc, __len, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return wcrtomb(__s, __wc, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, - size_t __len, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbsnrtowcs(__dest, __src, __nms, __len, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, - mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbrtowc(__pwc, __s, __n, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -int __libcpp_mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbtowc(__pwc, __pmb, __max); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbrlen(__s, __n, __ps); -} - -inline _LIBCPP_INLINE_VISIBILITY -lconv *__libcpp_localeconv_l(locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return localeconv(); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, - mbstate_t *__ps, locale_t __l) -{ - __libcpp_locale_guard __current(__l); - return mbsrtowcs(__dest, __src, __len, __ps); -} - -inline -int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vsnprintf(__s, __n, __format, __va); - va_end(__va); - return __res; -} - -inline -int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vasprintf(__s, __format, __va); - va_end(__va); - return __res; -} - -inline -int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { - va_list __va; - va_start(__va, __format); - __libcpp_locale_guard __current(__l); - int __res = vsscanf(__s, __format, __va); - va_end(__va); - return __res; -} - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H diff --git a/external/include/c++/v1/__config b/external/include/c++/v1/__config deleted file mode 100644 index b8c2c33..0000000 --- a/external/include/c++/v1/__config +++ /dev/null @@ -1,1373 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __config ---------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_CONFIG -#define _LIBCPP_CONFIG - -#if defined(_MSC_VER) && !defined(__clang__) -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -# endif -#endif - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -#ifdef __cplusplus - -#ifdef __GNUC__ -# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) -// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme -// introduced in GCC 5.0. -# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) -#else -# define _GNUC_VER 0 -# define _GNUC_VER_NEW 0 -#endif - -#define _LIBCPP_VERSION 8000 - -#ifndef _LIBCPP_ABI_VERSION -# ifdef __Fuchsia__ -# define _LIBCPP_ABI_VERSION 2 -# else -# define _LIBCPP_ABI_VERSION 1 -# endif -#endif - -#ifndef _LIBCPP_STD_VER -# if __cplusplus <= 201103L -# define _LIBCPP_STD_VER 11 -# elif __cplusplus <= 201402L -# define _LIBCPP_STD_VER 14 -# elif __cplusplus <= 201703L -# define _LIBCPP_STD_VER 17 -# else -# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification -# endif -#endif // _LIBCPP_STD_VER - -#if defined(__ELF__) -# define _LIBCPP_OBJECT_FORMAT_ELF 1 -#elif defined(__MACH__) -# define _LIBCPP_OBJECT_FORMAT_MACHO 1 -#elif defined(_WIN32) -# define _LIBCPP_OBJECT_FORMAT_COFF 1 -#elif defined(__wasm__) -# define _LIBCPP_OBJECT_FORMAT_WASM 1 -#else -# error Unknown object file format -#endif - -#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 -// Change short string representation so that string data starts at offset 0, -// improving its alignment in some cases. -# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -// Fix deque iterator type in order to support incomplete types. -# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE -// Fix undefined behavior in how std::list stores its linked nodes. -# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB -// Fix undefined behavior in how __tree stores its end and parent nodes. -# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB -// Fix undefined behavior in how __hash_table stores its pointer types. -# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB -# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB -# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE -// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr -// provided under the alternate keyword __nullptr, which changes the mangling -// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. -# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR -// Define the `pointer_safety` enum as a C++11 strongly typed enumeration -// instead of as a class simulating an enum. If this option is enabled -// `pointer_safety` and `get_pointer_safety()` will no longer be available -// in C++03. -# define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE -// Define a key function for `bad_function_call` in the library, to centralize -// its vtable and typeinfo to libc++ rather than having all other libraries -// using that class define their own copies. -# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION -// Enable optimized version of __do_get_(un)signed which avoids redundant copies. -# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET -// Use the smallest possible integer type to represent the index of the variant. -// Previously libc++ used "unsigned int" exclusivly. -# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION -#elif _LIBCPP_ABI_VERSION == 1 -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) -// Enable compiling copies of now inline methods into the dylib to support -// applications compiled against older libraries. This is unnecessary with -// COFF dllexport semantics, since dllexport forces a non-inline definition -// of inline functions to be emitted anyway. Our own non-inline copy would -// conflict with the dllexport-emitted copy, so we disable it. -# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS -# endif -// Feature macros for disabling pre ABI v1 features. All of these options -// are deprecated. -# if defined(__FreeBSD__) -# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR -# endif -#endif - -#ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR -#error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ - use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead -#endif - -#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y -#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) - -#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) - -#if __cplusplus < 201103L -#define _LIBCPP_CXX03_LANG -#endif - -#ifndef __has_attribute -#define __has_attribute(__x) 0 -#endif - -#ifndef __has_builtin -#define __has_builtin(__x) 0 -#endif - -#ifndef __has_extension -#define __has_extension(__x) 0 -#endif - -#ifndef __has_feature -#define __has_feature(__x) 0 -#endif - -#ifndef __has_cpp_attribute -#define __has_cpp_attribute(__x) 0 -#endif - -// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by -// the compiler and '1' otherwise. -#ifndef __is_identifier -#define __is_identifier(__x) 1 -#endif - -#ifndef __has_declspec_attribute -#define __has_declspec_attribute(__x) 0 -#endif - -#define __has_keyword(__x) !(__is_identifier(__x)) - -#ifndef __has_include -#define __has_include(...) 0 -#endif - -#if defined(__clang__) -# define _LIBCPP_COMPILER_CLANG -# ifndef __apple_build_version__ -# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) -# endif -#elif defined(__GNUC__) -# define _LIBCPP_COMPILER_GCC -#elif defined(_MSC_VER) -# define _LIBCPP_COMPILER_MSVC -#elif defined(__IBMCPP__) -# define _LIBCPP_COMPILER_IBM -#endif - -#ifndef _LIBCPP_CLANG_VER -#define _LIBCPP_CLANG_VER 0 -#endif - -// FIXME: ABI detection should be done via compiler builtin macros. This -// is just a placeholder until Clang implements such macros. For now assume -// that Windows compilers pretending to be MSVC++ target the Microsoft ABI, -// and allow the user to explicitly specify the ABI to handle cases where this -// heuristic falls short. -#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" -#elif defined(_LIBCPP_ABI_FORCE_ITANIUM) -# define _LIBCPP_ABI_ITANIUM -#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) -# define _LIBCPP_ABI_MICROSOFT -#else -# if defined(_WIN32) && defined(_MSC_VER) -# define _LIBCPP_ABI_MICROSOFT -# else -# define _LIBCPP_ABI_ITANIUM -# endif -#endif - -// Need to detect which libc we're using if we're on Linux. -#if defined(__linux__) -# include -# if defined(__GLIBC_PREREQ) -# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) -# else -# define _LIBCPP_GLIBC_PREREQ(a, b) 0 -# endif // defined(__GLIBC_PREREQ) -#endif // defined(__linux__) - -#ifdef __LITTLE_ENDIAN__ -# if __LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# endif // __LITTLE_ENDIAN__ -#endif // __LITTLE_ENDIAN__ - -#ifdef __BIG_ENDIAN__ -# if __BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BIG_ENDIAN__ -#endif // __BIG_ENDIAN__ - -#ifdef __BYTE_ORDER__ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#endif // __BYTE_ORDER__ - -#ifdef __FreeBSD__ -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# ifndef __LONG_LONG_SUPPORTED -# define _LIBCPP_HAS_NO_LONG_LONG -# endif // __LONG_LONG_SUPPORTED -#endif // __FreeBSD__ - -#ifdef __NetBSD__ -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_HAS_QUICK_EXIT -#endif // __NetBSD__ - -#if defined(_WIN32) -# define _LIBCPP_WIN32API -# define _LIBCPP_LITTLE_ENDIAN -# define _LIBCPP_SHORT_WCHAR 1 -// Both MinGW and native MSVC provide a "MSVC"-like enviroment -# define _LIBCPP_MSVCRT_LIKE -// If mingw not explicitly detected, assume using MS C runtime only if -// a MS compatibility version is specified. -# if defined(_MSC_VER) && !defined(__MINGW32__) -# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library -# endif -# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) -# define _LIBCPP_HAS_BITSCAN64 -# endif -# define _LIBCPP_HAS_OPEN_WITH_WCHAR -# if defined(_LIBCPP_MSVCRT) -# define _LIBCPP_HAS_QUICK_EXIT -# endif - -// Some CRT APIs are unavailable to store apps -# if defined(WINAPI_FAMILY) -# include -# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ - (!defined(WINAPI_PARTITION_SYSTEM) || \ - !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) -# define _LIBCPP_WINDOWS_STORE_APP -# endif -# endif -#endif // defined(_WIN32) - -#ifdef __sun__ -# include -# ifdef _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else -# define _LIBCPP_BIG_ENDIAN -# endif -#endif // __sun__ - -#if defined(__CloudABI__) - // Certain architectures provide arc4random(). Prefer using - // arc4random() over /dev/{u,}random to make it possible to obtain - // random data even when using sandboxing mechanisms such as chroots, - // Capsicum, etc. -# define _LIBCPP_USING_ARC4_RANDOM -#elif defined(__Fuchsia__) -# define _LIBCPP_USING_GETENTROPY -#elif defined(__native_client__) - // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, - // including accesses to the special files under /dev. C++11's - // std::random_device is instead exposed through a NaCl syscall. -# define _LIBCPP_USING_NACL_RANDOM -#elif defined(_LIBCPP_WIN32API) -# define _LIBCPP_USING_WIN32_RANDOM -#else -# define _LIBCPP_USING_DEV_RANDOM -#endif - -#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) -# include -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER == __BIG_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# else // __BYTE_ORDER == __BIG_ENDIAN -# error unable to determine endian -# endif -#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) - -#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) -#else -# define _LIBCPP_NO_CFI -#endif - -#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L -# if defined(__FreeBSD__) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_C11_FEATURES -# elif defined(__Fuchsia__) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_TIMESPEC_GET -# define _LIBCPP_HAS_C11_FEATURES -# elif defined(__linux__) -# if !defined(_LIBCPP_HAS_MUSL_LIBC) -# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) -# define _LIBCPP_HAS_QUICK_EXIT -# endif -# if _LIBCPP_GLIBC_PREREQ(2, 17) -# define _LIBCPP_HAS_C11_FEATURES -# define _LIBCPP_HAS_TIMESPEC_GET -# endif -# else // defined(_LIBCPP_HAS_MUSL_LIBC) -# define _LIBCPP_HAS_QUICK_EXIT -# define _LIBCPP_HAS_TIMESPEC_GET -# define _LIBCPP_HAS_C11_FEATURES -# endif -# endif // __linux__ -#endif - -#if defined(_LIBCPP_COMPILER_CLANG) - -// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for -// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. -#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \ - defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) -#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -#endif - -#if __has_feature(cxx_alignas) -# define _ALIGNAS_TYPE(x) alignas(x) -# define _ALIGNAS(x) alignas(x) -#else -# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) -# define _ALIGNAS(x) __attribute__((__aligned__(x))) -#endif - -#if __cplusplus < 201103L -typedef __char16_t char16_t; -typedef __char32_t char32_t; -#endif - -#if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) -#define _LIBCPP_NO_EXCEPTIONS -#endif - -#if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI) -#define _LIBCPP_NO_RTTI -#endif - -#if !(__has_feature(cxx_strong_enums)) -#define _LIBCPP_HAS_NO_STRONG_ENUMS -#endif - -#if !(__has_feature(cxx_decltype)) -#define _LIBCPP_HAS_NO_DECLTYPE -#endif - -#if __has_feature(cxx_attributes) -# define _LIBCPP_NORETURN [[noreturn]] -#else -# define _LIBCPP_NORETURN __attribute__ ((noreturn)) -#endif - -#if !(__has_feature(cxx_lambdas)) -#define _LIBCPP_HAS_NO_LAMBDAS -#endif - -#if !(__has_feature(cxx_nullptr)) -# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) -# define nullptr __nullptr -# else -# define _LIBCPP_HAS_NO_NULLPTR -# endif -#endif - -#if !(__has_feature(cxx_rvalue_references)) -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - -#if !(__has_feature(cxx_auto_type)) -#define _LIBCPP_HAS_NO_AUTO_TYPE -#endif - -#if !(__has_feature(cxx_variadic_templates)) -#define _LIBCPP_HAS_NO_VARIADICS -#endif - -#if !(__has_feature(cxx_generalized_initializers)) -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#endif - -#if __has_feature(is_base_of) -#define _LIBCPP_HAS_IS_BASE_OF -#endif - -#if __has_feature(is_final) -#define _LIBCPP_HAS_IS_FINAL -#endif - -// Objective-C++ features (opt-in) -#if __has_feature(objc_arc) -#define _LIBCPP_HAS_OBJC_ARC -#endif - -#if __has_feature(objc_arc_weak) -#define _LIBCPP_HAS_OBJC_ARC_WEAK -#endif - -#if !(__has_feature(cxx_constexpr)) -#define _LIBCPP_HAS_NO_CONSTEXPR -#endif - -#if !(__has_feature(cxx_relaxed_constexpr)) -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#endif - -#if !(__has_feature(cxx_variable_templates)) -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#endif - -#if !(__has_feature(cxx_noexcept)) -#define _LIBCPP_HAS_NO_NOEXCEPT -#endif - -#if __has_feature(underlying_type) -#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) -#endif - -#if __has_feature(is_literal) -#define _LIBCPP_IS_LITERAL(T) __is_literal(T) -#endif - -// Inline namespaces are available in Clang regardless of C++ dialect. -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { -#define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std::_LIBCPP_NAMESPACE - -namespace std { - inline namespace _LIBCPP_NAMESPACE { - } -} - -#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) -#define _LIBCPP_HAS_NO_ASAN -#endif - -// Allow for build-time disabling of unsigned integer sanitization -#if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) -#endif - -#if __has_builtin(__builtin_launder) -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#endif - -#if !__is_identifier(__has_unique_object_representations) -#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS -#endif - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#elif defined(_LIBCPP_COMPILER_GCC) - -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) - -#define _LIBCPP_NORETURN __attribute__((noreturn)) - -#if _GNUC_VER >= 407 -#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) -#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) -#define _LIBCPP_HAS_IS_FINAL -#endif - -#if defined(__GNUC__) && _GNUC_VER >= 403 -#define _LIBCPP_HAS_IS_BASE_OF -#endif - -#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS) -#define _LIBCPP_NO_EXCEPTIONS -#endif - -// constexpr was added to GCC in 4.6. -#if _GNUC_VER < 406 -# define _LIBCPP_HAS_NO_CONSTEXPR -// Can only use constexpr in c++11 mode. -#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L -# define _LIBCPP_HAS_NO_CONSTEXPR -#endif - -// Determine if GCC supports relaxed constexpr -#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#endif - -// GCC 5 will support variable templates -#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#endif - -#ifndef __GXX_EXPERIMENTAL_CXX0X__ - -#define _LIBCPP_HAS_NO_DECLTYPE -#define _LIBCPP_HAS_NO_NULLPTR -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_NO_VARIADICS -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#define _LIBCPP_HAS_NO_STRONG_ENUMS -#define _LIBCPP_HAS_NO_NOEXCEPT - -#else // __GXX_EXPERIMENTAL_CXX0X__ - -#if _GNUC_VER < 403 -#define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - - -#if _GNUC_VER < 404 -#define _LIBCPP_HAS_NO_DECLTYPE -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_NO_VARIADICS -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#endif // _GNUC_VER < 404 - -#if _GNUC_VER < 406 -#define _LIBCPP_HAS_NO_NOEXCEPT -#define _LIBCPP_HAS_NO_NULLPTR -#endif - -#endif // __GXX_EXPERIMENTAL_CXX0X__ - -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_NAMESPACE { -#define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std::_LIBCPP_NAMESPACE - -namespace std { - inline namespace _LIBCPP_NAMESPACE { - } -} - -#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) -#define _LIBCPP_HAS_NO_ASAN -#endif - -#if _GNUC_VER >= 700 -#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER -#endif - -#if _GNUC_VER >= 700 -#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS -#endif - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#elif defined(_LIBCPP_COMPILER_MSVC) - -#define _LIBCPP_TOSTRING2(x) #x -#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) -#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) - -#if _MSC_VER < 1900 -#error "MSVC versions prior to Visual Studio 2015 are not supported" -#endif - -#define _LIBCPP_HAS_IS_BASE_OF -#define _LIBCPP_HAS_NO_CONSTEXPR -#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES -#define _LIBCPP_HAS_NO_NOEXCEPT -#define __alignof__ __alignof -#define _LIBCPP_NORETURN __declspec(noreturn) -#define _ALIGNAS(x) __declspec(align(x)) -#define _ALIGNAS_TYPE(x) alignas(x) -#define _LIBCPP_HAS_NO_VARIADICS - -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { -#define _LIBCPP_END_NAMESPACE_STD } -#define _VSTD std - -namespace std { -} - -#define _LIBCPP_WEAK - -#define _LIBCPP_HAS_NO_ASAN - -#define _LIBCPP_ALWAYS_INLINE __forceinline - -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - -#elif defined(_LIBCPP_COMPILER_IBM) - -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) -#define _ATTRIBUTE(x) __attribute__((x)) -#define _LIBCPP_NORETURN __attribute__((noreturn)) - -#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#define _LIBCPP_HAS_NO_NOEXCEPT -#define _LIBCPP_HAS_NO_NULLPTR -#define _LIBCPP_HAS_NO_UNICODE_CHARS -#define _LIBCPP_HAS_IS_BASE_OF -#define _LIBCPP_HAS_IS_FINAL -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES - -#if defined(_AIX) -#define __MULTILOCALE_API -#endif - -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { -#define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std::_LIBCPP_NAMESPACE - -namespace std { - inline namespace _LIBCPP_NAMESPACE { - } -} - -#define _LIBCPP_HAS_NO_ASAN - -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) - -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION - -#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] - -#if _LIBCPP_STD_VER >= 17 -#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ - _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { -#else -#define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ - _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { -#endif - -#define _LIBCPP_END_NAMESPACE_FILESYSTEM \ - _LIBCPP_END_NAMESPACE_STD } } - -#define _VSTD_FS _VSTD::__fs::filesystem - - -#if defined(_LIBCPP_OBJECT_FORMAT_COFF) - -#ifdef _DLL -# define _LIBCPP_CRT_FUNC __declspec(dllimport) -#else -# define _LIBCPP_CRT_FUNC -#endif - -#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_DLL_VIS -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS -#elif defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_DLL_VIS __declspec(dllexport) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS -#else -# define _LIBCPP_DLL_VIS __declspec(dllimport) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS -#endif - -#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_EXTERN_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS -#define _LIBCPP_HIDDEN -#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -#define _LIBCPP_TEMPLATE_VIS -#define _LIBCPP_ENUM_VIS - -#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) - -#ifndef _LIBCPP_HIDDEN -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) -# else -# define _LIBCPP_HIDDEN -# endif -#endif - -#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -// The inline should be removed once PR32114 is resolved -# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN -# else -# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -# endif -#endif - -#ifndef _LIBCPP_FUNC_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_FUNC_VIS -# endif -#endif - -#ifndef _LIBCPP_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_TYPE_VIS -# endif -#endif - -#ifndef _LIBCPP_TEMPLATE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# if __has_attribute(__type_visibility__) -# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) -# else -# define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) -# endif -# else -# define _LIBCPP_TEMPLATE_VIS -# endif -#endif - -#ifndef _LIBCPP_EXTERN_VIS -#define _LIBCPP_EXTERN_VIS -#endif - -#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS -#define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS -#endif - -#ifndef _LIBCPP_EXCEPTION_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_EXCEPTION_ABI -# endif -#endif - -#ifndef _LIBCPP_ENUM_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) -# define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) -# else -# define _LIBCPP_ENUM_VIS -# endif -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# endif -#endif - -#ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -#endif - -#if __has_attribute(internal_linkage) -# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) -#else -# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE -#endif - -#ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU -# ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT -# define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 -# else -# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 -# endif -#endif - -#ifndef _LIBCPP_HIDE_FROM_ABI -# if _LIBCPP_HIDE_FROM_ABI_PER_TU -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE -# else -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_ALWAYS_INLINE -# endif -#endif - -#ifdef _LIBCPP_BUILDING_LIBRARY -# if _LIBCPP_ABI_VERSION > 1 -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI -# else -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 -# endif -#else -# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI -#endif - -// Just so we can migrate to the new macros gradually. -#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI -#define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI_AFTER_V1 - -#ifndef _LIBCPP_PREFERRED_OVERLOAD -# if __has_attribute(__enable_if__) -# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) -# endif -#endif - -#ifndef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT noexcept -# define _NOEXCEPT_(x) noexcept(x) -#else -# define _NOEXCEPT throw() -# define _NOEXCEPT_(x) -#endif - -#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) -# if !defined(_LIBCPP_DEBUG) -# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined -# endif -# ifdef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT_DEBUG -# define _NOEXCEPT_DEBUG_(x) -# else -# define _NOEXCEPT_DEBUG noexcept(false) -# define _NOEXCEPT_DEBUG_(x) noexcept(false) -# endif -#else -# define _NOEXCEPT_DEBUG _NOEXCEPT -# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x) -#endif - -#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef unsigned short char16_t; -typedef unsigned int char32_t; -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - -#ifndef __SIZEOF_INT128__ -#define _LIBCPP_HAS_NO_INT128 -#endif - -#ifdef _LIBCPP_CXX03_LANG -# if __has_extension(c_static_assert) -# define static_assert(__b, __m) _Static_assert(__b, __m) -# else -extern "C++" { -template struct __static_assert_test; -template <> struct __static_assert_test {}; -template struct __static_assert_check {}; -} -# define static_assert(__b, __m) \ - typedef __static_assert_check)> \ - _LIBCPP_CONCAT(__t, __LINE__) -# endif // __has_extension(c_static_assert) -#endif // _LIBCPP_CXX03_LANG - -#ifdef _LIBCPP_HAS_NO_DECLTYPE -// GCC 4.6 provides __decltype in all standard modes. -# if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406 -# define decltype(__x) __decltype(__x) -# else -# define decltype(__x) __typeof__(__x) -# endif -#endif - -#ifdef _LIBCPP_HAS_NO_CONSTEXPR -# define _LIBCPP_CONSTEXPR -#else -# define _LIBCPP_CONSTEXPR constexpr -#endif - -#ifdef _LIBCPP_CXX03_LANG -# define _LIBCPP_DEFAULT {} -#else -# define _LIBCPP_DEFAULT = default; -#endif - -#ifdef _LIBCPP_CXX03_LANG -# define _LIBCPP_EQUAL_DELETE -#else -# define _LIBCPP_EQUAL_DELETE = delete -#endif - -#ifdef __GNUC__ -# define _NOALIAS __attribute__((__malloc__)) -#else -# define _NOALIAS -#endif - -#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ - (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions -# define _LIBCPP_EXPLICIT explicit -#else -# define _LIBCPP_EXPLICIT -#endif - -#if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) -#define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE -#endif - -#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS -# define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx -# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ - __lx __v_; \ - _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ - _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ - _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ - }; -#else // _LIBCPP_HAS_NO_STRONG_ENUMS -# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x -# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) -#endif // _LIBCPP_HAS_NO_STRONG_ENUMS - -#ifdef _LIBCPP_DEBUG -# if _LIBCPP_DEBUG == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG are 0 and 1 -# endif -# if !defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_EXTERN_TEMPLATE(...) -# endif -#endif - -#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) -#define _LIBCPP_EXTERN_TEMPLATE2(...) -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; -#endif - -#ifndef _LIBCPP_EXTERN_TEMPLATE2 -#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; -#endif - -#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) -#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ - defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) -#define _LIBCPP_LOCALE__L_EXTENSIONS 1 -#endif - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) -// Most unix variants have catopen. These are the specific ones that don't. -# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_CATOPEN 1 -# endif -#endif - -#ifdef __FreeBSD__ -#define _DECLARE_C99_LDBL_MATH 1 -#endif - -// If we are getting operator new from the MSVC CRT, then allocation overloads -// for align_val_t were added in 19.12, aka VS 2017 version 15.3. -#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 -#define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif - -#if defined(__APPLE__) -# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ - defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) -# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ -# endif -# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -# if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -# endif -# endif -#endif // defined(__APPLE__) - -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ - !defined(_LIBCPP_BUILDING_LIBRARY) && \ - (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) -#define _LIBCPP_HAS_DEFAULTRUNELOCALE -#endif - -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) -#define _LIBCPP_WCTYPE_IS_MASK -#endif - -#if _LIBCPP_STD_VER > 11 -# define _LIBCPP_DEPRECATED [[deprecated]] -#else -# define _LIBCPP_DEPRECATED -#endif - -#if _LIBCPP_STD_VER <= 11 -# define _LIBCPP_EXPLICIT_AFTER_CXX11 -# define _LIBCPP_DEPRECATED_AFTER_CXX11 -#else -# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit -# define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] -#endif - -#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 -#endif - -#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 -#endif - -#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) -# define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]] -#else -# define _LIBCPP_NODISCARD_AFTER_CXX17 -#endif - -#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) -# define _LIBCPP_INLINE_VAR inline -#else -# define _LIBCPP_INLINE_VAR -#endif - -#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES -# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) -#else -# define _LIBCPP_EXPLICIT_MOVE(x) (x) -#endif - -#ifndef _LIBCPP_CONSTEXPR_IF_NODEBUG -#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) -#define _LIBCPP_CONSTEXPR_IF_NODEBUG -#else -#define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr -#endif -#endif - -#ifndef _LIBCPP_HAS_NO_ASAN -_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( - const void *, const void *, const void *, const void *); -#endif - -// Try to find out if RTTI is disabled. -// g++ and cl.exe have RTTI on by default and define a macro when it is. -// g++ only defines the macro in 4.3.2 and onwards. -#if !defined(_LIBCPP_NO_RTTI) -# if defined(__GNUC__) && \ - ((__GNUC__ >= 5) || \ - (__GNUC__ == 4 && (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && \ - !defined(__GXX_RTTI) -# define _LIBCPP_NO_RTTI -# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) -# define _LIBCPP_NO_RTTI -# endif -#endif - -#ifndef _LIBCPP_WEAK -#define _LIBCPP_WEAK __attribute__((__weak__)) -#endif - -// Thread API -#if !defined(_LIBCPP_HAS_NO_THREADS) && \ - !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ - !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ - !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -# if defined(__FreeBSD__) || \ - defined(__Fuchsia__) || \ - defined(__NetBSD__) || \ - defined(__linux__) || \ - defined(__APPLE__) || \ - defined(__CloudABI__) || \ - defined(__sun__) || \ - (defined(__MINGW32__) && __has_include()) -# define _LIBCPP_HAS_THREAD_API_PTHREAD -# elif defined(_LIBCPP_WIN32API) -# define _LIBCPP_HAS_THREAD_API_WIN32 -# else -# error "No thread API" -# endif // _LIBCPP_HAS_THREAD_API -#endif // _LIBCPP_HAS_NO_THREADS - -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ - _LIBCPP_HAS_NO_THREADS is not defined. -#endif - -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ - _LIBCPP_HAS_NO_THREADS is defined. -#endif - -#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) -#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ - _LIBCPP_HAS_NO_THREADS is defined. -#endif - -// Systems that use capability-based security (FreeBSD with Capsicum, -// Nuxi CloudABI) may only provide local filesystem access (using *at()). -// Functions like open(), rename(), unlink() and stat() should not be -// used, as they attempt to access the global filesystem namespace. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE -#endif - -// CloudABI is intended for running networked services. Processes do not -// have standard input and output channels. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_STDIN -#define _LIBCPP_HAS_NO_STDOUT -#endif - -#if defined(__BIONIC__) || defined(__CloudABI__) || \ - defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC) -#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE -#endif - -// Thread-unsafe functions such as strtok() and localtime() -// are not available. -#ifdef __CloudABI__ -#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS -#endif - -#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) -# define _LIBCPP_HAS_C_ATOMIC_IMP -#elif _GNUC_VER > 407 -# define _LIBCPP_HAS_GCC_ATOMIC_IMP -#endif - -#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ - || defined(_LIBCPP_HAS_NO_THREADS) -#define _LIBCPP_HAS_NO_ATOMIC_HEADER -#endif - -#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#endif - -#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) -# if defined(__clang__) && __has_attribute(acquire_capability) -// Work around the attribute handling in clang. When both __declspec and -// __attribute__ are present, the processing goes awry preventing the definition -// of the types. -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) -# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# endif -# endif -#endif - -#if __has_attribute(require_constant_initialization) -# define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) -#else -# define _LIBCPP_SAFE_STATIC -#endif - -#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 -#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF -#endif - -#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) -# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS -# endif -#endif - -#if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) -# define _LIBCPP_DIAGNOSE_WARNING(...) \ - __attribute__((diagnose_if(__VA_ARGS__, "warning"))) -# define _LIBCPP_DIAGNOSE_ERROR(...) \ - __attribute__((diagnose_if(__VA_ARGS__, "error"))) -#else -# define _LIBCPP_DIAGNOSE_WARNING(...) -# define _LIBCPP_DIAGNOSE_ERROR(...) -#endif - -#if __has_attribute(fallthough) || _GNUC_VER >= 700 -// Use a function like macro to imply that it must be followed by a semicolon -# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) -#else -# define _LIBCPP_FALLTHROUGH() ((void)0) -#endif - -#if defined(_LIBCPP_ABI_MICROSOFT) && \ - (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) -# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) -#else -# define _LIBCPP_DECLSPEC_EMPTY_BASES -#endif - -#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) -#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE -#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS -#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES - -#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 -#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES -#endif - -#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) -#define _LIBCPP_HAS_NO_IS_AGGREGATE -#endif - -#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L -#define _LIBCPP_HAS_NO_COROUTINES -#endif - -// FIXME: Correct this macro when either (A) a feature test macro for the -// spaceship operator is provided, or (B) a compiler provides a complete -// implementation. -#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR - -// Decide whether to use availability macros. -#if !defined(_LIBCPP_BUILDING_LIBRARY) && \ - !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ - __has_feature(attribute_availability_with_strict) && \ - __has_feature(attribute_availability_in_templates) -# ifdef __APPLE__ -# define _LIBCPP_USE_AVAILABILITY_APPLE -# endif -#endif - -// Define availability macros. -#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) -# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) -# define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable)) -# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable)) -# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ - __attribute__((availability(macosx,strict,introduced=10.12))) \ - __attribute__((availability(ios,strict,introduced=10.0))) \ - __attribute__((availability(tvos,strict,introduced=10.0))) \ - __attribute__((availability(watchos,strict,introduced=3.0))) -# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ - __attribute__((availability(ios,strict,introduced=6.0))) -# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ - __attribute__((availability(macosx,strict,introduced=10.9))) \ - __attribute__((availability(ios,strict,introduced=7.0))) -#else -# define _LIBCPP_AVAILABILITY_SHARED_MUTEX -# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS -# define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH -# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST -# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS -# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE -# define _LIBCPP_AVAILABILITY_FUTURE_ERROR -# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE -# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY -# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR -#endif - -// Define availability that depends on _LIBCPP_NO_EXCEPTIONS. -#ifdef _LIBCPP_NO_EXCEPTIONS -# define _LIBCPP_AVAILABILITY_DYNARRAY -# define _LIBCPP_AVAILABILITY_FUTURE -# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST -#else -# define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH -# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR -# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \ - _LIBCPP_AVAILABILITY_BAD_ANY_CAST -#endif - -// Availability of stream API in the dylib got dropped and re-added. The -// extern template should effectively be available at: -// availability(macosx,introduced=10.9) -// availability(ios,introduced=7.0) -#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \ - ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \ - (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)) -#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE -#endif - -#if defined(_LIBCPP_COMPILER_IBM) -#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO -#endif - -#if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) -# define _LIBCPP_PUSH_MACROS -# define _LIBCPP_POP_MACROS -#else - // Don't warn about macro conflicts when we can restore them at the - // end of the header. -# ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS -# define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS -# endif -# if defined(_LIBCPP_COMPILER_MSVC) -# define _LIBCPP_PUSH_MACROS \ - __pragma(push_macro("min")) \ - __pragma(push_macro("max")) -# define _LIBCPP_POP_MACROS \ - __pragma(pop_macro("min")) \ - __pragma(pop_macro("max")) -# else -# define _LIBCPP_PUSH_MACROS \ - _Pragma("push_macro(\"min\")") \ - _Pragma("push_macro(\"max\")") -# define _LIBCPP_POP_MACROS \ - _Pragma("pop_macro(\"min\")") \ - _Pragma("pop_macro(\"max\")") -# endif -#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) - -#ifndef _LIBCPP_NO_AUTO_LINK -# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) -# if defined(_DLL) -# pragma comment(lib, "c++.lib") -# else -# pragma comment(lib, "libc++.lib") -# endif -# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) -#endif // _LIBCPP_NO_AUTO_LINK - -#endif // __cplusplus - -#endif // _LIBCPP_CONFIG diff --git a/external/include/c++/v1/__cxxabi_config.h b/external/include/c++/v1/__cxxabi_config.h deleted file mode 100644 index 46f5914..0000000 --- a/external/include/c++/v1/__cxxabi_config.h +++ /dev/null @@ -1,73 +0,0 @@ -//===-------------------------- __cxxabi_config.h -------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef ____CXXABI_CONFIG_H -#define ____CXXABI_CONFIG_H - -#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ - !defined(__ARM_DWARF_EH__) -#define _LIBCXXABI_ARM_EHABI -#endif - -#if !defined(__has_attribute) -#define __has_attribute(_attribute_) 0 -#endif - -#if defined(_WIN32) - #if defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LIBCXXABI_TYPE_VIS - #elif defined(_LIBCXXABI_BUILDING_LIBRARY) - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS __declspec(dllexport) - #define _LIBCXXABI_FUNC_VIS __declspec(dllexport) - #define _LIBCXXABI_TYPE_VIS __declspec(dllexport) - #else - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS __declspec(dllimport) - #define _LIBCXXABI_FUNC_VIS __declspec(dllimport) - #define _LIBCXXABI_TYPE_VIS __declspec(dllimport) - #endif -#else - #if !defined(_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) - #define _LIBCXXABI_HIDDEN __attribute__((__visibility__("hidden"))) - #define _LIBCXXABI_DATA_VIS __attribute__((__visibility__("default"))) - #define _LIBCXXABI_FUNC_VIS __attribute__((__visibility__("default"))) - #if __has_attribute(__type_visibility__) - #define _LIBCXXABI_TYPE_VIS __attribute__((__type_visibility__("default"))) - #else - #define _LIBCXXABI_TYPE_VIS __attribute__((__visibility__("default"))) - #endif - #else - #define _LIBCXXABI_HIDDEN - #define _LIBCXXABI_DATA_VIS - #define _LIBCXXABI_FUNC_VIS - #define _LIBCXXABI_TYPE_VIS - #endif -#endif - -#if defined(_WIN32) -#define _LIBCXXABI_WEAK -#else -#define _LIBCXXABI_WEAK __attribute__((__weak__)) -#endif - -#if defined(__clang__) -#define _LIBCXXABI_COMPILER_CLANG -#endif - -#if __has_attribute(__no_sanitize__) && defined(_LIBCXXABI_COMPILER_CLANG) -#define _LIBCXXABI_NO_CFI __attribute__((__no_sanitize__("cfi"))) -#else -#define _LIBCXXABI_NO_CFI -#endif - -#endif // ____CXXABI_CONFIG_H diff --git a/external/include/c++/v1/__debug b/external/include/c++/v1/__debug deleted file mode 100644 index d01bacd..0000000 --- a/external/include/c++/v1/__debug +++ /dev/null @@ -1,302 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __debug ----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_DEBUG_H -#define _LIBCPP_DEBUG_H - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if defined(_LIBCPP_HAS_NO_NULLPTR) -# include -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -# include -# include -# include -# include -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT) -# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \ - _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 2 -#ifndef _LIBCPP_DEBUG_ASSERT -#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) -#endif -#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__ -#endif - -#ifndef _LIBCPP_ASSERT -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif -#ifndef _LIBCPP_DEBUG_ASSERT -# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) -#endif -#ifndef _LIBCPP_DEBUG_MODE -#define _LIBCPP_DEBUG_MODE(...) ((void)0) -#endif - -#if _LIBCPP_DEBUG_LEVEL < 1 -class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception; -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - __libcpp_debug_info() - : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m) - : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {} - const char* __file_; - int __line_; - const char* __pred_; - const char* __msg_; -}; - -/// __libcpp_debug_function_type - The type of the assertion failure handler. -typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&); - -/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT -/// fails. -extern _LIBCPP_EXTERN_VIS __libcpp_debug_function_type __libcpp_debug_function; - -/// __libcpp_abort_debug_function - A debug handler that aborts when called. -_LIBCPP_NORETURN _LIBCPP_FUNC_VIS -void __libcpp_abort_debug_function(__libcpp_debug_info const&); - -/// __libcpp_throw_debug_function - A debug handler that throws -/// an instance of __libcpp_debug_exception when called. - _LIBCPP_NORETURN _LIBCPP_FUNC_VIS -void __libcpp_throw_debug_function(__libcpp_debug_info const&); - -/// __libcpp_set_debug_function - Set the debug handler to the specified -/// function. -_LIBCPP_FUNC_VIS -bool __libcpp_set_debug_function(__libcpp_debug_function_type __func); - -// Setup the throwing debug handler during dynamic initialization. -#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) -# if defined(_LIBCPP_NO_EXCEPTIONS) -# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled. -# endif -static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function); -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception { -public: - __libcpp_debug_exception() _NOEXCEPT; - explicit __libcpp_debug_exception(__libcpp_debug_info const& __i); - __libcpp_debug_exception(__libcpp_debug_exception const&); - ~__libcpp_debug_exception() _NOEXCEPT; - const char* what() const _NOEXCEPT; -private: - struct __libcpp_debug_exception_imp; - __libcpp_debug_exception_imp *__imp_; -}; -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) - -struct _LIBCPP_TYPE_VIS __c_node; - -struct _LIBCPP_TYPE_VIS __i_node -{ - void* __i_; - __i_node* __next_; - __c_node* __c_; - -#ifndef _LIBCPP_CXX03_LANG - __i_node(const __i_node&) = delete; - __i_node& operator=(const __i_node&) = delete; -#else -private: - __i_node(const __i_node&); - __i_node& operator=(const __i_node&); -public: -#endif - _LIBCPP_INLINE_VISIBILITY - __i_node(void* __i, __i_node* __next, __c_node* __c) - : __i_(__i), __next_(__next), __c_(__c) {} - ~__i_node(); -}; - -struct _LIBCPP_TYPE_VIS __c_node -{ - void* __c_; - __c_node* __next_; - __i_node** beg_; - __i_node** end_; - __i_node** cap_; - -#ifndef _LIBCPP_CXX03_LANG - __c_node(const __c_node&) = delete; - __c_node& operator=(const __c_node&) = delete; -#else -private: - __c_node(const __c_node&); - __c_node& operator=(const __c_node&); -public: -#endif - _LIBCPP_INLINE_VISIBILITY - __c_node(void* __c, __c_node* __next) - : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} - virtual ~__c_node(); - - virtual bool __dereferenceable(const void*) const = 0; - virtual bool __decrementable(const void*) const = 0; - virtual bool __addable(const void*, ptrdiff_t) const = 0; - virtual bool __subscriptable(const void*, ptrdiff_t) const = 0; - - void __add(__i_node* __i); - _LIBCPP_HIDDEN void __remove(__i_node* __i); -}; - -template -struct _C_node - : public __c_node -{ - _C_node(void* __c, __c_node* __n) - : __c_node(__c, __n) {} - - virtual bool __dereferenceable(const void*) const; - virtual bool __decrementable(const void*) const; - virtual bool __addable(const void*, ptrdiff_t) const; - virtual bool __subscriptable(const void*, ptrdiff_t) const; -}; - -template -inline bool -_C_node<_Cont>::__dereferenceable(const void* __i) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__dereferenceable(__j); -} - -template -inline bool -_C_node<_Cont>::__decrementable(const void* __i) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__decrementable(__j); -} - -template -inline bool -_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__addable(__j, __n); -} - -template -inline bool -_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const -{ - typedef typename _Cont::const_iterator iterator; - const iterator* __j = static_cast(__i); - _Cont* _Cp = static_cast<_Cont*>(__c_); - return _Cp->__subscriptable(__j, __n); -} - -class _LIBCPP_TYPE_VIS __libcpp_db -{ - __c_node** __cbeg_; - __c_node** __cend_; - size_t __csz_; - __i_node** __ibeg_; - __i_node** __iend_; - size_t __isz_; - - __libcpp_db(); -public: -#ifndef _LIBCPP_CXX03_LANG - __libcpp_db(const __libcpp_db&) = delete; - __libcpp_db& operator=(const __libcpp_db&) = delete; -#else -private: - __libcpp_db(const __libcpp_db&); - __libcpp_db& operator=(const __libcpp_db&); -public: -#endif - ~__libcpp_db(); - - class __db_c_iterator; - class __db_c_const_iterator; - class __db_i_iterator; - class __db_i_const_iterator; - - __db_c_const_iterator __c_end() const; - __db_i_const_iterator __i_end() const; - - template - _LIBCPP_INLINE_VISIBILITY - void __insert_c(_Cont* __c) - { - __c_node* __n = __insert_c(static_cast(__c)); - ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_); - } - - void __insert_i(void* __i); - __c_node* __insert_c(void* __c); - void __erase_c(void* __c); - - void __insert_ic(void* __i, const void* __c); - void __iterator_copy(void* __i, const void* __i0); - void __erase_i(void* __i); - - void* __find_c_from_i(void* __i) const; - void __invalidate_all(void* __c); - __c_node* __find_c_and_lock(void* __c) const; - __c_node* __find_c(void* __c) const; - void unlock() const; - - void swap(void* __c1, void* __c2); - - - bool __dereferenceable(const void* __i) const; - bool __decrementable(const void* __i) const; - bool __addable(const void* __i, ptrdiff_t __n) const; - bool __subscriptable(const void* __i, ptrdiff_t __n) const; - bool __less_than_comparable(const void* __i, const void* __j) const; -private: - _LIBCPP_HIDDEN - __i_node* __insert_iterator(void* __i); - _LIBCPP_HIDDEN - __i_node* __find_iterator(const void* __i) const; - - friend _LIBCPP_FUNC_VIS __libcpp_db* __get_db(); -}; - -_LIBCPP_FUNC_VIS __libcpp_db* __get_db(); -_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); - - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_DEBUG_H - diff --git a/external/include/c++/v1/__errc b/external/include/c++/v1/__errc deleted file mode 100644 index d0f00b7..0000000 --- a/external/include/c++/v1/__errc +++ /dev/null @@ -1,218 +0,0 @@ -// -*- C++ -*- -//===---------------------------- __errc ----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ERRC -#define _LIBCPP___ERRC - -/* - system_error synopsis - -namespace std -{ - -enum class errc -{ - address_family_not_supported, // EAFNOSUPPORT - address_in_use, // EADDRINUSE - address_not_available, // EADDRNOTAVAIL - already_connected, // EISCONN - argument_list_too_long, // E2BIG - argument_out_of_domain, // EDOM - bad_address, // EFAULT - bad_file_descriptor, // EBADF - bad_message, // EBADMSG - broken_pipe, // EPIPE - connection_aborted, // ECONNABORTED - connection_already_in_progress, // EALREADY - connection_refused, // ECONNREFUSED - connection_reset, // ECONNRESET - cross_device_link, // EXDEV - destination_address_required, // EDESTADDRREQ - device_or_resource_busy, // EBUSY - directory_not_empty, // ENOTEMPTY - executable_format_error, // ENOEXEC - file_exists, // EEXIST - file_too_large, // EFBIG - filename_too_long, // ENAMETOOLONG - function_not_supported, // ENOSYS - host_unreachable, // EHOSTUNREACH - identifier_removed, // EIDRM - illegal_byte_sequence, // EILSEQ - inappropriate_io_control_operation, // ENOTTY - interrupted, // EINTR - invalid_argument, // EINVAL - invalid_seek, // ESPIPE - io_error, // EIO - is_a_directory, // EISDIR - message_size, // EMSGSIZE - network_down, // ENETDOWN - network_reset, // ENETRESET - network_unreachable, // ENETUNREACH - no_buffer_space, // ENOBUFS - no_child_process, // ECHILD - no_link, // ENOLINK - no_lock_available, // ENOLCK - no_message_available, // ENODATA - no_message, // ENOMSG - no_protocol_option, // ENOPROTOOPT - no_space_on_device, // ENOSPC - no_stream_resources, // ENOSR - no_such_device_or_address, // ENXIO - no_such_device, // ENODEV - no_such_file_or_directory, // ENOENT - no_such_process, // ESRCH - not_a_directory, // ENOTDIR - not_a_socket, // ENOTSOCK - not_a_stream, // ENOSTR - not_connected, // ENOTCONN - not_enough_memory, // ENOMEM - not_supported, // ENOTSUP - operation_canceled, // ECANCELED - operation_in_progress, // EINPROGRESS - operation_not_permitted, // EPERM - operation_not_supported, // EOPNOTSUPP - operation_would_block, // EWOULDBLOCK - owner_dead, // EOWNERDEAD - permission_denied, // EACCES - protocol_error, // EPROTO - protocol_not_supported, // EPROTONOSUPPORT - read_only_file_system, // EROFS - resource_deadlock_would_occur, // EDEADLK - resource_unavailable_try_again, // EAGAIN - result_out_of_range, // ERANGE - state_not_recoverable, // ENOTRECOVERABLE - stream_timeout, // ETIME - text_file_busy, // ETXTBSY - timed_out, // ETIMEDOUT - too_many_files_open_in_system, // ENFILE - too_many_files_open, // EMFILE - too_many_links, // EMLINK - too_many_symbolic_link_levels, // ELOOP - value_too_large, // EOVERFLOW - wrong_protocol_type // EPROTOTYPE -}; - -*/ - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -// Some error codes are not present on all platforms, so we provide equivalents -// for them: - -//enum class errc -_LIBCPP_DECLARE_STRONG_ENUM(errc) -{ - address_family_not_supported = EAFNOSUPPORT, - address_in_use = EADDRINUSE, - address_not_available = EADDRNOTAVAIL, - already_connected = EISCONN, - argument_list_too_long = E2BIG, - argument_out_of_domain = EDOM, - bad_address = EFAULT, - bad_file_descriptor = EBADF, - bad_message = EBADMSG, - broken_pipe = EPIPE, - connection_aborted = ECONNABORTED, - connection_already_in_progress = EALREADY, - connection_refused = ECONNREFUSED, - connection_reset = ECONNRESET, - cross_device_link = EXDEV, - destination_address_required = EDESTADDRREQ, - device_or_resource_busy = EBUSY, - directory_not_empty = ENOTEMPTY, - executable_format_error = ENOEXEC, - file_exists = EEXIST, - file_too_large = EFBIG, - filename_too_long = ENAMETOOLONG, - function_not_supported = ENOSYS, - host_unreachable = EHOSTUNREACH, - identifier_removed = EIDRM, - illegal_byte_sequence = EILSEQ, - inappropriate_io_control_operation = ENOTTY, - interrupted = EINTR, - invalid_argument = EINVAL, - invalid_seek = ESPIPE, - io_error = EIO, - is_a_directory = EISDIR, - message_size = EMSGSIZE, - network_down = ENETDOWN, - network_reset = ENETRESET, - network_unreachable = ENETUNREACH, - no_buffer_space = ENOBUFS, - no_child_process = ECHILD, - no_link = ENOLINK, - no_lock_available = ENOLCK, -#ifdef ENODATA - no_message_available = ENODATA, -#else - no_message_available = ENOMSG, -#endif - no_message = ENOMSG, - no_protocol_option = ENOPROTOOPT, - no_space_on_device = ENOSPC, -#ifdef ENOSR - no_stream_resources = ENOSR, -#else - no_stream_resources = ENOMEM, -#endif - no_such_device_or_address = ENXIO, - no_such_device = ENODEV, - no_such_file_or_directory = ENOENT, - no_such_process = ESRCH, - not_a_directory = ENOTDIR, - not_a_socket = ENOTSOCK, -#ifdef ENOSTR - not_a_stream = ENOSTR, -#else - not_a_stream = EINVAL, -#endif - not_connected = ENOTCONN, - not_enough_memory = ENOMEM, - not_supported = ENOTSUP, - operation_canceled = ECANCELED, - operation_in_progress = EINPROGRESS, - operation_not_permitted = EPERM, - operation_not_supported = EOPNOTSUPP, - operation_would_block = EWOULDBLOCK, - owner_dead = EOWNERDEAD, - permission_denied = EACCES, - protocol_error = EPROTO, - protocol_not_supported = EPROTONOSUPPORT, - read_only_file_system = EROFS, - resource_deadlock_would_occur = EDEADLK, - resource_unavailable_try_again = EAGAIN, - result_out_of_range = ERANGE, - state_not_recoverable = ENOTRECOVERABLE, -#ifdef ETIME - stream_timeout = ETIME, -#else - stream_timeout = ETIMEDOUT, -#endif - text_file_busy = ETXTBSY, - timed_out = ETIMEDOUT, - too_many_files_open_in_system = ENFILE, - too_many_files_open = EMFILE, - too_many_links = EMLINK, - too_many_symbolic_link_levels = ELOOP, - value_too_large = EOVERFLOW, - wrong_protocol_type = EPROTOTYPE -}; -_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ERRC diff --git a/external/include/c++/v1/__functional_03 b/external/include/c++/v1/__functional_03 deleted file mode 100644 index 0a3bfba..0000000 --- a/external/include/c++/v1/__functional_03 +++ /dev/null @@ -1,1592 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_03 -#define _LIBCPP_FUNCTIONAL_03 - -// manual variadic expansion for - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -namespace __function { - -template class __base; - -template -class __base<_Rp()> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()() = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0, _A1)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0, _A1) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template -class __base<_Rp(_A0, _A1, _A2)> -{ - __base(const __base&); - __base& operator=(const __base&); -public: - __base() {} - virtual ~__base() {} - virtual __base* __clone() const = 0; - virtual void __clone(__base*) const = 0; - virtual void destroy() = 0; - virtual void destroy_deallocate() = 0; - virtual _Rp operator()(_A0, _A1, _A2) = 0; -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const = 0; - virtual const std::type_info& target_type() const = 0; -#endif // _LIBCPP_NO_RTTI -}; - -template class __func; - -template -class __func<_Fp, _Alloc, _Rp()> - : public __base<_Rp()> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp()>* __clone() const; - virtual void __clone(__base<_Rp()>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp()>* -__func<_Fp, _Alloc, _Rp()>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp()>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp()>::operator()() -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first()); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp()>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0)> - : public __base<_Rp(_A0)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0)>* __clone() const; - virtual void __clone(__base<_Rp(_A0)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0)>* -__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0, _A1)> - : public __base<_Rp(_A0, _A1)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0, _A1)>* __clone() const; - virtual void __clone(__base<_Rp(_A0, _A1)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0, _A1); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0, _A1)>* -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0, __a1); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -template -class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> - : public __base<_Rp(_A0, _A1, _A2)> -{ - __compressed_pair<_Fp, _Alloc> __f_; -public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) - : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} - virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const; - virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const; - virtual void destroy(); - virtual void destroy_deallocate(); - virtual _Rp operator()(_A0, _A1, _A2); -#ifndef _LIBCPP_NO_RTTI - virtual const void* target(const type_info&) const; - virtual const std::type_info& target_type() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -__base<_Rp(_A0, _A1, _A2)>* -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); - return __hold.release(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const -{ - ::new (__p) __func(__f_.first(), __f_.second()); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy() -{ - __f_.~__compressed_pair<_Fp, _Alloc>(); -} - -template -void -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate() -{ - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; - _Ap __a(__f_.second()); - __f_.~__compressed_pair<_Fp, _Alloc>(); - __a.deallocate(this, 1); -} - -template -_Rp -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) -{ - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(__f_.first(), __a0, __a1, __a2); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const void* -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const -{ - if (__ti == typeid(_Fp)) - return &__f_.first(); - return (const void*)0; -} - -template -const std::type_info& -__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const -{ - return typeid(_Fp); -} - -#endif // _LIBCPP_NO_RTTI - -} // __function - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp()> -{ - typedef __function::__base<_Rp()> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2()>&) const;// = delete; - template - bool operator!=(const function<_R2()>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()() const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp()>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp()>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp()> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp()>& -function<_Rp()>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp()>& -function<_Rp()>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp()>& ->::type -function<_Rp()>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp()>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp()>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp()>::operator()() const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp()>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp()>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp()>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)> - : public unary_function<_A0, _Rp> -{ - typedef __function::__base<_Rp(_A0)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0)>& -function<_Rp(_A0)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0)>& -function<_Rp(_A0)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0)>& ->::type -function<_Rp(_A0)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0)>::operator()(_A0 __a0) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)> - : public binary_function<_A0, _A1, _Rp> -{ - typedef __function::__base<_Rp(_A0, _A1)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0, _A1) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0, _A1)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0, _A1)>& -function<_Rp(_A0, _A1)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0, _A1)>& -function<_Rp(_A0, _A1)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0, _A1)>& ->::type -function<_Rp(_A0, _A1)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0, _A1)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0, _A1)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0, __a1); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0, _A1)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0, _A1)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0, _A1)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)> -{ - typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; - aligned_storage<3*sizeof(void*)>::type __buf_; - __base* __f_; - -public: - typedef _Rp result_type; - - // 20.7.16.2.1, construct/copy/destroy: - _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} - _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} - function(const function&); - template - function(_Fp, - typename enable_if::value>::type* = 0); - - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&) : __f_(0) {} - template - _LIBCPP_INLINE_VISIBILITY - function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} - template - function(allocator_arg_t, const _Alloc&, const function&); - template - function(allocator_arg_t, const _Alloc& __a, _Fp __f, - typename enable_if::value>::type* = 0); - - function& operator=(const function&); - function& operator=(nullptr_t); - template - typename enable_if - < - !is_integral<_Fp>::value, - function& - >::type - operator=(_Fp); - - ~function(); - - // 20.7.16.2.2, function modifiers: - void swap(function&); - template - _LIBCPP_INLINE_VISIBILITY - void assign(_Fp __f, const _Alloc& __a) - {function(allocator_arg, __a, __f).swap(*this);} - - // 20.7.16.2.3, function capacity: - _LIBCPP_INLINE_VISIBILITY operator bool() const {return __f_;} - -private: - // deleted overloads close possible hole in the type system - template - bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; - template - bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; -public: - // 20.7.16.2.4, function invocation: - _Rp operator()(_A0, _A1, _A2) const; - -#ifndef _LIBCPP_NO_RTTI - // 20.7.16.2.5, function target access: - const std::type_info& target_type() const; - template _Tp* target(); - template const _Tp* target() const; -#endif // _LIBCPP_NO_RTTI -}; - -template -function<_Rp(_A0, _A1, _A2)>::function(const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&, - const function& __f) -{ - if (__f.__f_ == 0) - __f_ = 0; - else if (__f.__f_ == (const __base*)&__f.__buf_) - { - __f_ = (__base*)&__buf_; - __f.__f_->__clone(__f_); - } - else - __f_ = __f.__f_->__clone(); -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(_Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f); - } - else - { - typedef allocator<_FF> _Ap; - _Ap __a; - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, allocator<_Fp>(__a)); - __f_ = __hold.release(); - } - } -} - -template -template -function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, - typename enable_if::value>::type*) - : __f_(0) -{ - typedef allocator_traits<_Alloc> __alloc_traits; - if (__function::__not_null(__f)) - { - typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF; - if (sizeof(_FF) <= sizeof(__buf_)) - { - __f_ = (__base*)&__buf_; - ::new (__f_) _FF(__f, __a0); - } - else - { - typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; - _Ap __a(__a0); - typedef __allocator_destructor<_Ap> _Dp; - unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); - ::new (__hold.get()) _FF(__f, _Alloc(__a)); - __f_ = __hold.release(); - } - } -} - -template -function<_Rp(_A0, _A1, _A2)>& -function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f) -{ - if (__f) - function(__f).swap(*this); - else - *this = nullptr; - return *this; -} - -template -function<_Rp(_A0, _A1, _A2)>& -function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t) -{ - __base* __t = __f_; - __f_ = 0; - if (__t == (__base*)&__buf_) - __t->destroy(); - else if (__t) - __t->destroy_deallocate(); - return *this; -} - -template -template -typename enable_if -< - !is_integral<_Fp>::value, - function<_Rp(_A0, _A1, _A2)>& ->::type -function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f) -{ - function(_VSTD::move(__f)).swap(*this); - return *this; -} - -template -function<_Rp(_A0, _A1, _A2)>::~function() -{ - if (__f_ == (__base*)&__buf_) - __f_->destroy(); - else if (__f_) - __f_->destroy_deallocate(); -} - -template -void -function<_Rp(_A0, _A1, _A2)>::swap(function& __f) -{ - if (_VSTD::addressof(__f) == this) - return; - if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) - { - typename aligned_storage::type __tempbuf; - __base* __t = (__base*)&__tempbuf; - __f_->__clone(__t); - __f_->destroy(); - __f_ = 0; - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = 0; - __f_ = (__base*)&__buf_; - __t->__clone((__base*)&__f.__buf_); - __t->destroy(); - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f_ == (__base*)&__buf_) - { - __f_->__clone((__base*)&__f.__buf_); - __f_->destroy(); - __f_ = __f.__f_; - __f.__f_ = (__base*)&__f.__buf_; - } - else if (__f.__f_ == (__base*)&__f.__buf_) - { - __f.__f_->__clone((__base*)&__buf_); - __f.__f_->destroy(); - __f.__f_ = __f_; - __f_ = (__base*)&__buf_; - } - else - _VSTD::swap(__f_, __f.__f_); -} - -template -_Rp -function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const -{ - if (__f_ == 0) - __throw_bad_function_call(); - return (*__f_)(__a0, __a1, __a2); -} - -#ifndef _LIBCPP_NO_RTTI - -template -const std::type_info& -function<_Rp(_A0, _A1, _A2)>::target_type() const -{ - if (__f_ == 0) - return typeid(void); - return __f_->target_type(); -} - -template -template -_Tp* -function<_Rp(_A0, _A1, _A2)>::target() -{ - if (__f_ == 0) - return (_Tp*)0; - return (_Tp*) const_cast(__f_->target(typeid(_Tp))); -} - -template -template -const _Tp* -function<_Rp(_A0, _A1, _A2)>::target() const -{ - if (__f_ == 0) - return (const _Tp*)0; - return (const _Tp*)__f_->target(typeid(_Tp)); -} - -#endif // _LIBCPP_NO_RTTI - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const function<_Fp>& __f, nullptr_t) {return !__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(nullptr_t, const function<_Fp>& __f) {return !__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(function<_Fp>& __x, function<_Fp>& __y) -{return __x.swap(__y);} - -#endif // _LIBCPP_FUNCTIONAL_03 diff --git a/external/include/c++/v1/__functional_base b/external/include/c++/v1/__functional_base deleted file mode 100644 index 57fdf2b..0000000 --- a/external/include/c++/v1/__functional_base +++ /dev/null @@ -1,653 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_BASE -#define _LIBCPP_FUNCTIONAL_BASE - -#include <__config> -#include -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -struct _LIBCPP_TEMPLATE_VIS binary_function -{ - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; -}; - -template -struct __has_result_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::result_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -#if _LIBCPP_STD_VER > 11 -template -#else -template -#endif -struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> -{ - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Tp& __x, const _Tp& __y) const - {return __x < __y;} -}; - -#if _LIBCPP_STD_VER > 11 -template <> -struct _LIBCPP_TEMPLATE_VIS less -{ - template - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - auto operator()(_T1&& __t, _T2&& __u) const - _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) - -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } - typedef void is_transparent; -}; -#endif - -// __weak_result_type - -template -struct __derives_from_unary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static unary_function<_Ap, _Rp> - __test(const volatile unary_function<_Ap, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template -struct __derives_from_binary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static binary_function<_A1, _A2, _Rp> - __test(const volatile binary_function<_A1, _A2, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template ::value> -struct __maybe_derive_from_unary_function // bool is true - : public __derives_from_unary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_unary_function<_Tp, false> -{ -}; - -template ::value> -struct __maybe_derive_from_binary_function // bool is true - : public __derives_from_binary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_binary_function<_Tp, false> -{ -}; - -template ::value> -struct __weak_result_type_imp // bool is true - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ - typedef typename _Tp::result_type result_type; -}; - -template -struct __weak_result_type_imp<_Tp, false> - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ -}; - -template -struct __weak_result_type - : public __weak_result_type_imp<_Tp> -{ -}; - -// 0 argument case - -template -struct __weak_result_type<_Rp ()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)()> -{ - typedef _Rp result_type; -}; - -// 1 argument case - -template -struct __weak_result_type<_Rp (_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)()> - : public unary_function<_Cp*, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() volatile> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const volatile> - : public unary_function -{ -}; - -// 2 argument case - -template -struct __weak_result_type<_Rp (_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1)> - : public binary_function<_Cp*, _A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> - : public binary_function -{ -}; - - -#ifndef _LIBCPP_CXX03_LANG -// 3 or more arguments - -template -struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> -{ - typedef _Rp result_type; -}; - -template -struct __invoke_return -{ - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; -}; - -#else // defined(_LIBCPP_CXX03_LANG) - -#include <__functional_base_03> - -#endif // !defined(_LIBCPP_CXX03_LANG) - - -template -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static _Ret __call(_Args&&... __args) { - return __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static _Ret __call(_Fn __f) { - return __invoke(__f); - } - - template - static _Ret __call(_Fn __f, _A0& __a0) { - return __invoke(__f, __a0); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { - return __invoke(__f, __a0, __a1); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ - return __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template <> -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static void __call(_Args&&... __args) { - __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static void __call(_Fn __f) { - __invoke(__f); - } - - template - static void __call(_Fn __f, _A0& __a0) { - __invoke(__f, __a0); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1) { - __invoke(__f, __a0, __a1); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { - __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template -class _LIBCPP_TEMPLATE_VIS reference_wrapper - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type* __f_; - -public: - // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT - : __f_(_VSTD::addressof(__f)) {} -#ifndef _LIBCPP_CXX03_LANG - private: reference_wrapper(type&&); public: // = delete; // do not bind to temps -#endif - - // access - _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;} - _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;} - -#ifndef _LIBCPP_CXX03_LANG - // invoke - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } -#else - - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() () const { - return __invoke(get()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0 const& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } -#endif // _LIBCPP_CXX03_LANG -}; - - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(_Tp& __t) _NOEXCEPT -{ - return reference_wrapper<_Tp>(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return ref(__t.get()); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(const _Tp& __t) _NOEXCEPT -{ - return reference_wrapper(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return cref(__t.get()); -} - -#ifndef _LIBCPP_CXX03_LANG -template void ref(const _Tp&&) = delete; -template void cref(const _Tp&&) = delete; -#endif - -#if _LIBCPP_STD_VER > 11 -template -struct __is_transparent : false_type {}; - -template -struct __is_transparent<_Tp, _Up, - typename __void_t::type> - : true_type {}; -#endif - -// allocator_arg_t - -struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { }; - -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -extern const allocator_arg_t allocator_arg; -#else -/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template ::value> -struct __uses_allocator - : public integral_constant::value> -{ -}; - -template -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#if _LIBCPP_STD_VER > 14 -template -_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; -#endif - -#ifndef _LIBCPP_CXX03_LANG - -// allocator construction - -template -struct __uses_alloc_ctor_imp -{ - typedef typename __uncvref<_Alloc>::type _RawAlloc; - static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template -struct __uses_alloc_ctor - : integral_constant::value> - {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); -} - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_FUNCTIONAL_BASE diff --git a/external/include/c++/v1/__functional_base_03 b/external/include/c++/v1/__functional_base_03 deleted file mode 100644 index 8407dcf..0000000 --- a/external/include/c++/v1/__functional_base_03 +++ /dev/null @@ -1,224 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_FUNCTIONAL_BASE_03 -#define _LIBCPP_FUNCTIONAL_BASE_03 - -// manual variadic expansion for - -// __invoke - -template -struct __enable_invoke_imp; - -template -struct __enable_invoke_imp<_Ret, _T1, true, true> { - typedef _Ret _Bullet1; - typedef _Bullet1 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, true, false> { - typedef _Ret _Bullet2; - typedef _Bullet2 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, false, true> { - typedef typename add_lvalue_reference< - typename __apply_cv<_T1, _Ret>::type - >::type _Bullet3; - typedef _Bullet3 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1, false, false> { - typedef typename add_lvalue_reference< - typename __apply_cv()), _Ret>::type - >::type _Bullet4; - typedef _Bullet4 type; -}; - -template -struct __enable_invoke_imp<_Ret, _T1*, false, false> { - typedef typename add_lvalue_reference< - typename __apply_cv<_T1, _Ret>::type - >::type _Bullet4; - typedef _Bullet4 type; -}; - -template , - class _Ret = typename _Traits::_ReturnType, - class _Class = typename _Traits::_ClassType> -struct __enable_invoke : __enable_invoke_imp< - _Ret, _T1, - is_member_function_pointer<_Fn>::value, - is_base_of<_Class, typename remove_reference<_T1>::type>::value> -{ -}; - -__nat __invoke(__any, ...); - -// first bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1) { - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0) { - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet1 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1) { - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0) { - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet2 -__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet3 -__invoke(_Fn __f, _T1& __t1) { - return __t1.*__f; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __enable_invoke<_Fn, _T1>::_Bullet4 -__invoke(_Fn __f, _T1& __t1) { - return (*__t1).*__f; -} - -// fifth bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()()) -__invoke(_Fp& __f) -{ - return __f(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>())) -__invoke(_Fp& __f, _A0& __a0) -{ - return __f(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>())) -__invoke(_Fp& __f, _A0& __a0, _A1& __a1) -{ - return __f(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>())) -__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return __f(__a0, __a1, __a2); -} - -template >::value> -struct __invoke_return -{ - typedef typename __weak_result_type<_Fp>::result_type type; -}; - -template -struct __invoke_return<_Fp, false> -{ - typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type; -}; - -template -struct __invoke_return0 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type; -}; - -template -struct __invoke_return0<_Rp _Tp::*, _A0> -{ - typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; -}; - -template -struct __invoke_return1 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), - _VSTD::declval<_A1&>())) type; -}; - -template -struct __invoke_return1<_Rp _Class::*, _A0, _A1> { - typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; -}; - -template -struct __invoke_return2 -{ - typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), - _VSTD::declval<_A1&>(), - _VSTD::declval<_A2&>())) type; -}; - -template -struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { - typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; -}; -#endif // _LIBCPP_FUNCTIONAL_BASE_03 diff --git a/external/include/c++/v1/__hash_table b/external/include/c++/v1/__hash_table deleted file mode 100644 index c77de96..0000000 --- a/external/include/c++/v1/__hash_table +++ /dev/null @@ -1,2790 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP__HASH_TABLE -#define _LIBCPP__HASH_TABLE - -#include <__config> -#include -#include -#include -#include -#include -#include -#include - -#include <__debug> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -struct __hash_value_type; - -template ::value && !__libcpp_is_final<_Hash>::value> -class __unordered_map_hasher; - -template ::value && !__libcpp_is_final<_Pred>::value - > -class __unordered_map_equal; - -#ifndef _LIBCPP_CXX03_LANG -template -struct __is_hash_value_type_imp : false_type {}; - -template -struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {}; - -template -struct __is_hash_value_type : false_type {}; - -template -struct __is_hash_value_type<_One> : __is_hash_value_type_imp::type> {}; -#endif - -_LIBCPP_FUNC_VIS -size_t __next_prime(size_t __n); - -template -struct __hash_node_base -{ - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef __hash_node_base __first_node; - typedef typename __rebind_pointer<_NodePtr, __first_node>::type __node_base_pointer; - typedef _NodePtr __node_pointer; - -#if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB) - typedef __node_base_pointer __next_pointer; -#else - typedef typename conditional< - is_pointer<__node_pointer>::value, - __node_base_pointer, - __node_pointer>::type __next_pointer; -#endif - - __next_pointer __next_; - - _LIBCPP_INLINE_VISIBILITY - __next_pointer __ptr() _NOEXCEPT { - return static_cast<__next_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(*this)); - } - - _LIBCPP_INLINE_VISIBILITY - __node_pointer __upcast() _NOEXCEPT { - return static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(*this)); - } - - _LIBCPP_INLINE_VISIBILITY - size_t __hash() const _NOEXCEPT { - return static_cast<__node_type const&>(*this).__hash_; - } - - _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {} -}; - -template -struct __hash_node - : public __hash_node_base - < - typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type - > -{ - typedef _Tp __node_value_type; - - size_t __hash_; - __node_value_type __value_; -}; - -inline _LIBCPP_INLINE_VISIBILITY -bool -__is_hash_power2(size_t __bc) -{ - return __bc > 2 && !(__bc & (__bc - 1)); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -__constrain_hash(size_t __h, size_t __bc) -{ - return !(__bc & (__bc - 1)) ? __h & (__bc - 1) : - (__h < __bc ? __h : __h % __bc); -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -__next_hash_pow2(size_t __n) -{ - return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits - __clz(__n-1))); -} - - -template class __hash_table; - -template class _LIBCPP_TEMPLATE_VIS __hash_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_local_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; -template class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; - -template -struct __hash_key_value_types { - static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, ""); - typedef _Tp key_type; - typedef _Tp __node_value_type; - typedef _Tp __container_value_type; - static const bool __is_map = false; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(_Tp const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& __get_value(__node_value_type const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static __container_value_type&& __move(__node_value_type& __v) { - return _VSTD::move(__v); - } -#endif -}; - -template -struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { - typedef _Key key_type; - typedef _Tp mapped_type; - typedef __hash_value_type<_Key, _Tp> __node_value_type; - typedef pair __container_value_type; - typedef __container_value_type __map_value_type; - static const bool __is_map = true; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(__container_value_type const& __v) { - return __v.first; - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t.__get_value(); - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n.__get_value()); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static pair __move(__node_value_type& __v) { - return __v.__move(); - } -#endif - -}; - -template , - bool = _KVTypes::__is_map> -struct __hash_map_pointer_types {}; - -template -struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { - typedef typename _KVTypes::__map_value_type _Mv; - typedef typename __rebind_pointer<_AllocPtr, _Mv>::type - __map_value_type_pointer; - typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type - __const_map_value_type_pointer; -}; - -template ::element_type> -struct __hash_node_types; - -template -struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> > - : public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, _VoidPtr> - -{ - typedef __hash_key_value_types<_Tp> __base; - -public: - typedef ptrdiff_t difference_type; - typedef size_t size_type; - - typedef typename __rebind_pointer<_NodePtr, void>::type __void_pointer; - - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef _NodePtr __node_pointer; - - typedef __hash_node_base<__node_pointer> __node_base_type; - typedef typename __rebind_pointer<_NodePtr, __node_base_type>::type - __node_base_pointer; - - typedef typename __node_base_type::__next_pointer __next_pointer; - - typedef _Tp __node_value_type; - typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type - __node_value_type_pointer; - typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type - __const_node_value_type_pointer; - -private: - static_assert(!is_const<__node_type>::value, - "_NodePtr should never be a pointer to const"); - static_assert((is_same::element_type, void>::value), - "_VoidPtr does not point to unqualified void type"); - static_assert((is_same::type, - _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr."); -}; - -template -struct __hash_node_types_from_iterator; -template -struct __hash_node_types_from_iterator<__hash_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_const_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; -template -struct __hash_node_types_from_iterator<__hash_const_local_iterator<_NodePtr> > : __hash_node_types<_NodePtr> {}; - - -template -struct __make_hash_node_types { - typedef __hash_node<_NodeValueTp, _VoidPtr> _NodeTp; - typedef typename __rebind_pointer<_VoidPtr, _NodeTp>::type _NodePtr; - typedef __hash_node_types<_NodePtr> type; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_iterator -{ - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - -public: - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(const __hash_iterator& __i) - : __node_(__i.__node_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator& operator=(const __hash_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container iterator"); - __node_ = __node_->__next_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_iterator operator++(int) - { - __hash_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_iterator& __x, const __hash_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_iterator& __x, const __hash_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT - : __node_(__node) - { - __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_const_iterator -{ - static_assert(!is_const::element_type>::value, ""); - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - -public: - typedef __hash_iterator<_NodePtr> __non_const_iterator; - - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - - _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT - : __node_(__x.__node_) - { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(const __hash_const_iterator& __i) - : __node_(__i.__node_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_const_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator& operator=(const __hash_const_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_iterator"); - return __node_->__upcast()->__value_; - } - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_iterator"); - __node_ = __node_->__next_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator operator++(int) - { - __hash_const_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_const_iterator& __x, const __hash_const_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT - : __node_(__node) - { - __get_db()->__insert_ic(this, __c); - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_const_iterator(__next_pointer __node) _NOEXCEPT - : __node_(__node) - {} -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_local_iterator -{ - typedef __hash_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - size_t __bucket_; - size_t __bucket_count_; - -public: - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(const __hash_local_iterator& __i) - : __node_(__i.__node_), - __bucket_(__i.__bucket_), - __bucket_count_(__i.__bucket_count_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_local_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator& operator=(const __hash_local_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - __bucket_ = __i.__bucket_; - __bucket_count_ = __i.__bucket_count_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container local_iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container local_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container local_iterator"); - __node_ = __node_->__next_; - if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) - __node_ = nullptr; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator operator++(int) - { - __hash_local_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_local_iterator& __x, const __hash_local_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count, const void* __c) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - __get_db()->__insert_ic(this, __c); - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; -}; - -template -class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator -{ - typedef __hash_node_types<_ConstNodePtr> _NodeTypes; - typedef _ConstNodePtr __node_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - - __next_pointer __node_; - size_t __bucket_; - size_t __bucket_count_; - - typedef pointer_traits<__node_pointer> __pointer_traits; - typedef typename __pointer_traits::element_type __node; - typedef typename remove_const<__node>::type __non_const_node; - typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type - __non_const_node_pointer; -public: - typedef __hash_local_iterator<__non_const_node_pointer> - __non_const_iterator; - - typedef forward_iterator_tag iterator_category; - typedef typename _NodeTypes::__node_value_type value_type; - typedef typename _NodeTypes::difference_type difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - - _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(const __non_const_iterator& __x) _NOEXCEPT - : __node_(__x.__node_), - __bucket_(__x.__bucket_), - __bucket_count_(__x.__bucket_count_) - { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(const __hash_const_local_iterator& __i) - : __node_(__i.__node_), - __bucket_(__i.__bucket_), - __bucket_count_(__i.__bucket_count_) - { - __get_db()->__iterator_copy(this, &__i); - } - - _LIBCPP_INLINE_VISIBILITY - ~__hash_const_local_iterator() - { - __get_db()->__erase_i(this); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) - { - if (this != &__i) - { - __get_db()->__iterator_copy(this, &__i); - __node_ = __i.__node_; - __bucket_ = __i.__bucket_; - __bucket_count_ = __i.__bucket_count_; - } - return *this; - } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); - return __node_->__upcast()->__value_; - } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable unordered container const_local_iterator"); - return pointer_traits::pointer_to(__node_->__upcast()->__value_); - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator& operator++() { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_local_iterator"); - __node_ = __node_->__next_; - if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) - __node_ = nullptr; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator operator++(int) - { - __hash_const_local_iterator __t(*this); - ++(*this); - return __t; - } - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - { - return __x.__node_ == __y.__node_; - } - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __hash_const_local_iterator& __x, const __hash_const_local_iterator& __y) - {return !(__x == __y);} - -private: -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count, const void* __c) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - __get_db()->__insert_ic(this, __c); - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#else - _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, - size_t __bucket_count) _NOEXCEPT - : __node_(__node), - __bucket_(__bucket), - __bucket_count_(__bucket_count) - { - if (__node_ != nullptr) - __node_ = __node_->__next_; - } -#endif - template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; -}; - -template -class __bucket_list_deallocator -{ - typedef _Alloc allocator_type; - typedef allocator_traits __alloc_traits; - typedef typename __alloc_traits::size_type size_type; - - __compressed_pair __data_; -public: - typedef typename __alloc_traits::pointer pointer; - - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __data_(0) {} - - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator(const allocator_type& __a, size_type __size) - _NOEXCEPT_(is_nothrow_copy_constructible::value) - : __data_(__size, __a) {} - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - __bucket_list_deallocator(__bucket_list_deallocator&& __x) - _NOEXCEPT_(is_nothrow_move_constructible::value) - : __data_(_VSTD::move(__x.__data_)) - { - __x.size() = 0; - } -#endif - - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __data_.first();} - _LIBCPP_INLINE_VISIBILITY - size_type size() const _NOEXCEPT {return __data_.first();} - - _LIBCPP_INLINE_VISIBILITY - allocator_type& __alloc() _NOEXCEPT {return __data_.second();} - _LIBCPP_INLINE_VISIBILITY - const allocator_type& __alloc() const _NOEXCEPT {return __data_.second();} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - __alloc_traits::deallocate(__alloc(), __p, size()); - } -}; - -template class __hash_map_node_destructor; - -template -class __hash_node_destructor -{ - typedef _Alloc allocator_type; - typedef allocator_traits __alloc_traits; - -public: - typedef typename __alloc_traits::pointer pointer; -private: - typedef __hash_node_types _NodeTypes; - - allocator_type& __na_; - - __hash_node_destructor& operator=(const __hash_node_destructor&); - -public: - bool __value_constructed; - - _LIBCPP_INLINE_VISIBILITY - explicit __hash_node_destructor(allocator_type& __na, - bool __constructed = false) _NOEXCEPT - : __na_(__na), - __value_constructed(__constructed) - {} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - if (__value_constructed) - __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); - if (__p) - __alloc_traits::deallocate(__na_, __p, 1); - } - - template friend class __hash_map_node_destructor; -}; - -#if _LIBCPP_STD_VER > 14 -template -struct __generic_container_node_destructor; - -template -struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc> - : __hash_node_destructor<_Alloc> -{ - using __hash_node_destructor<_Alloc>::__hash_node_destructor; -}; -#endif - -#ifndef _LIBCPP_CXX03_LANG -template -struct __diagnose_hash_table_helper { - static constexpr bool __trigger_diagnostics() - _LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key, _Hash>::value - && !__invokable<_Hash const&, _Key const&>::value, - "the specified hash functor does not provide a const call operator") - _LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value - && !__invokable<_Equal const&, _Key const&, _Key const&>::value, - "the specified comparator type does not provide a const call operator") - { - static_assert(__check_hash_requirements<_Key, _Hash>::value, - "the specified hash does not meet the Hash requirements"); - static_assert(is_copy_constructible<_Equal>::value, - "the specified comparator is required to be copy constructible"); - return true; - } -}; - -template -struct __diagnose_hash_table_helper< - __hash_value_type<_Key, _Value>, - __unordered_map_hasher<_Key, __hash_value_type<_Key, _Value>, _Hash>, - __unordered_map_equal<_Key, __hash_value_type<_Key, _Value>, _Equal>, - _Alloc> -: __diagnose_hash_table_helper<_Key, _Hash, _Equal, _Alloc> -{ -}; -#endif // _LIBCPP_CXX03_LANG - -template -class __hash_table -{ -public: - typedef _Tp value_type; - typedef _Hash hasher; - typedef _Equal key_equal; - typedef _Alloc allocator_type; - -private: - typedef allocator_traits __alloc_traits; - typedef typename - __make_hash_node_types::type - _NodeTypes; -public: - - typedef typename _NodeTypes::__node_value_type __node_value_type; - typedef typename _NodeTypes::__container_value_type __container_value_type; - typedef typename _NodeTypes::key_type key_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; -#ifndef _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE - typedef typename __alloc_traits::size_type size_type; -#else - typedef typename _NodeTypes::size_type size_type; -#endif - typedef typename _NodeTypes::difference_type difference_type; -public: - // Create __node - - typedef typename _NodeTypes::__node_type __node; - typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; - typedef allocator_traits<__node_allocator> __node_traits; - typedef typename _NodeTypes::__void_pointer __void_pointer; - typedef typename _NodeTypes::__node_pointer __node_pointer; - typedef typename _NodeTypes::__node_pointer __node_const_pointer; - typedef typename _NodeTypes::__node_base_type __first_node; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__next_pointer __next_pointer; - -private: - // check for sane allocator pointer rebinding semantics. Rebinding the - // allocator for a new pointer type should be exactly the same as rebinding - // the pointer using 'pointer_traits'. - static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - typedef typename __rebind_alloc_helper<__node_traits, __first_node>::type - __node_base_allocator; - typedef allocator_traits<__node_base_allocator> __node_base_traits; - static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - -private: - - typedef typename __rebind_alloc_helper<__node_traits, __next_pointer>::type __pointer_allocator; - typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter; - typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list; - typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits; - typedef typename __bucket_list_deleter::pointer __node_pointer_pointer; - -#ifndef _LIBCPP_CXX03_LANG - static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), ""); -#endif - - // --- Member data begin --- - __bucket_list __bucket_list_; - __compressed_pair<__first_node, __node_allocator> __p1_; - __compressed_pair __p2_; - __compressed_pair __p3_; - // --- Member data end --- - - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __p2_.first();} -public: - _LIBCPP_INLINE_VISIBILITY - size_type size() const _NOEXCEPT {return __p2_.first();} - - _LIBCPP_INLINE_VISIBILITY - hasher& hash_function() _NOEXCEPT {return __p2_.second();} - _LIBCPP_INLINE_VISIBILITY - const hasher& hash_function() const _NOEXCEPT {return __p2_.second();} - - _LIBCPP_INLINE_VISIBILITY - float& max_load_factor() _NOEXCEPT {return __p3_.first();} - _LIBCPP_INLINE_VISIBILITY - float max_load_factor() const _NOEXCEPT {return __p3_.first();} - - _LIBCPP_INLINE_VISIBILITY - key_equal& key_eq() _NOEXCEPT {return __p3_.second();} - _LIBCPP_INLINE_VISIBILITY - const key_equal& key_eq() const _NOEXCEPT {return __p3_.second();} - - _LIBCPP_INLINE_VISIBILITY - __node_allocator& __node_alloc() _NOEXCEPT {return __p1_.second();} - _LIBCPP_INLINE_VISIBILITY - const __node_allocator& __node_alloc() const _NOEXCEPT - {return __p1_.second();} - -public: - typedef __hash_iterator<__node_pointer> iterator; - typedef __hash_const_iterator<__node_pointer> const_iterator; - typedef __hash_local_iterator<__node_pointer> local_iterator; - typedef __hash_const_local_iterator<__node_pointer> const_local_iterator; - - _LIBCPP_INLINE_VISIBILITY - __hash_table() - _NOEXCEPT_( - is_nothrow_default_constructible<__bucket_list>::value && - is_nothrow_default_constructible<__first_node>::value && - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY - __hash_table(const hasher& __hf, const key_equal& __eql); - __hash_table(const hasher& __hf, const key_equal& __eql, - const allocator_type& __a); - explicit __hash_table(const allocator_type& __a); - __hash_table(const __hash_table& __u); - __hash_table(const __hash_table& __u, const allocator_type& __a); -#ifndef _LIBCPP_CXX03_LANG - __hash_table(__hash_table&& __u) - _NOEXCEPT_( - is_nothrow_move_constructible<__bucket_list>::value && - is_nothrow_move_constructible<__first_node>::value && - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value); - __hash_table(__hash_table&& __u, const allocator_type& __a); -#endif // _LIBCPP_CXX03_LANG - ~__hash_table(); - - __hash_table& operator=(const __hash_table& __u); -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - __hash_table& operator=(__hash_table&& __u) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); -#endif - template - void __assign_unique(_InputIterator __first, _InputIterator __last); - template - void __assign_multi(_InputIterator __first, _InputIterator __last); - - _LIBCPP_INLINE_VISIBILITY - size_type max_size() const _NOEXCEPT - { - return std::min( - __node_traits::max_size(__node_alloc()), - numeric_limits::max() - ); - } - - pair __node_insert_unique(__node_pointer __nd); - iterator __node_insert_multi(__node_pointer __nd); - iterator __node_insert_multi(const_iterator __p, - __node_pointer __nd); - -#ifndef _LIBCPP_CXX03_LANG - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const& __k, _Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_impl(_Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Pp&& __x) { - return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { - return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Args&&... __args) { - return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { - return __emplace_unique_impl(_VSTD::forward<_Pp>(__x)); - } - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { - return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x)); - } - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { - return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_multi(_Args&&... __args); - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); - - - _LIBCPP_INLINE_VISIBILITY - pair - __insert_unique(__container_value_type&& __x) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x)); - } - - template ::value - >::type> - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(_Pp&& __x) { - return __emplace_unique(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(_Pp&& __x) { - return __emplace_multi(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, _Pp&& __x) { - return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x)); - } - -#else // !defined(_LIBCPP_CXX03_LANG) - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const&, _Args& __args); - - iterator __insert_multi(const __container_value_type& __x); - iterator __insert_multi(const_iterator __p, const __container_value_type& __x); -#endif - - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(const __container_value_type& __x) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x); - } - -#if _LIBCPP_STD_VER > 14 - template - _LIBCPP_INLINE_VISIBILITY - _InsertReturnType __node_handle_insert_unique(_NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_unique(const_iterator __hint, - _NodeHandle&& __nh); - - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(_NodeHandle&& __nh); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh); - - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(key_type const& __key); - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(const_iterator __it); -#endif - - void clear() _NOEXCEPT; - void rehash(size_type __n); - _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) - {rehash(static_cast(ceil(__n / max_load_factor())));} - - _LIBCPP_INLINE_VISIBILITY - size_type bucket_count() const _NOEXCEPT - { - return __bucket_list_.get_deleter().size(); - } - - _LIBCPP_INLINE_VISIBILITY - iterator begin() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - iterator end() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - const_iterator end() const _NOEXCEPT; - - template - _LIBCPP_INLINE_VISIBILITY - size_type bucket(const _Key& __k) const - { - _LIBCPP_ASSERT(bucket_count() > 0, - "unordered container::bucket(key) called when bucket_count() == 0"); - return __constrain_hash(hash_function()(__k), bucket_count()); - } - - template - iterator find(const _Key& __x); - template - const_iterator find(const _Key& __x) const; - - typedef __hash_node_destructor<__node_allocator> _Dp; - typedef unique_ptr<__node, _Dp> __node_holder; - - iterator erase(const_iterator __p); - iterator erase(const_iterator __first, const_iterator __last); - template - size_type __erase_unique(const _Key& __k); - template - size_type __erase_multi(const _Key& __k); - __node_holder remove(const_iterator __p) _NOEXCEPT; - - template - _LIBCPP_INLINE_VISIBILITY - size_type __count_unique(const _Key& __k) const; - template - size_type __count_multi(const _Key& __k) const; - - template - pair - __equal_range_unique(const _Key& __k); - template - pair - __equal_range_unique(const _Key& __k) const; - - template - pair - __equal_range_multi(const _Key& __k); - template - pair - __equal_range_multi(const _Key& __k) const; - - void swap(__hash_table& __u) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_DEBUG_( - __is_nothrow_swappable::value && __is_nothrow_swappable::value - && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value - || __is_nothrow_swappable<__pointer_allocator>::value) - && (!__node_traits::propagate_on_container_swap::value - || __is_nothrow_swappable<__node_allocator>::value) - ); -#else - _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && __is_nothrow_swappable::value); -#endif - - _LIBCPP_INLINE_VISIBILITY - size_type max_bucket_count() const _NOEXCEPT - {return max_size(); } - size_type bucket_size(size_type __n) const; - _LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT - { - size_type __bc = bucket_count(); - return __bc != 0 ? (float)size() / __bc : 0.f; - } - _LIBCPP_INLINE_VISIBILITY void max_load_factor(float __mlf) _NOEXCEPT - { - _LIBCPP_ASSERT(__mlf > 0, - "unordered container::max_load_factor(lf) called with lf <= 0"); - max_load_factor() = _VSTD::max(__mlf, load_factor()); - } - - _LIBCPP_INLINE_VISIBILITY - local_iterator - begin(size_type __n) - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::begin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - local_iterator - end(size_type __n) - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::end(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return local_iterator(nullptr, __n, bucket_count(), this); -#else - return local_iterator(nullptr, __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - const_local_iterator - cbegin(size_type __n) const - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::cbegin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); -#else - return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); -#endif - } - - _LIBCPP_INLINE_VISIBILITY - const_local_iterator - cend(size_type __n) const - { - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::cend(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_local_iterator(nullptr, __n, bucket_count(), this); -#else - return const_local_iterator(nullptr, __n, bucket_count()); -#endif - } - -#if _LIBCPP_DEBUG_LEVEL >= 2 - - bool __dereferenceable(const const_iterator* __i) const; - bool __decrementable(const const_iterator* __i) const; - bool __addable(const const_iterator* __i, ptrdiff_t __n) const; - bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - -private: - void __rehash(size_type __n); - -#ifndef _LIBCPP_CXX03_LANG - template - __node_holder __construct_node(_Args&& ...__args); - - template - __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest); -#else // _LIBCPP_CXX03_LANG - __node_holder __construct_node(const __container_value_type& __v); - __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v); -#endif - - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __hash_table& __u) - {__copy_assign_alloc(__u, integral_constant());} - void __copy_assign_alloc(const __hash_table& __u, true_type); - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __hash_table&, false_type) {} - -#ifndef _LIBCPP_CXX03_LANG - void __move_assign(__hash_table& __u, false_type); - void __move_assign(__hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value); - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table& __u) - _NOEXCEPT_( - !__node_traits::propagate_on_container_move_assignment::value || - (is_nothrow_move_assignable<__pointer_allocator>::value && - is_nothrow_move_assignable<__node_allocator>::value)) - {__move_assign_alloc(__u, integral_constant());} - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__pointer_allocator>::value && - is_nothrow_move_assignable<__node_allocator>::value) - { - __bucket_list_.get_deleter().__alloc() = - _VSTD::move(__u.__bucket_list_.get_deleter().__alloc()); - __node_alloc() = _VSTD::move(__u.__node_alloc()); - } - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} -#endif // _LIBCPP_CXX03_LANG - - void __deallocate_node(__next_pointer __np) _NOEXCEPT; - __next_pointer __detach() _NOEXCEPT; - - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; -}; - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() - _NOEXCEPT_( - is_nothrow_default_constructible<__bucket_list>::value && - is_nothrow_default_constructible<__first_node>::value && - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_default_constructible::value && - is_nothrow_default_constructible::value) - : __p2_(0), - __p3_(1.0f) -{ -} - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, - const key_equal& __eql) - : __bucket_list_(nullptr, __bucket_list_deleter()), - __p1_(), - __p2_(0, __hf), - __p3_(1.0f, __eql) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, - const key_equal& __eql, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, __hf), - __p3_(1.0f, __eql) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0), - __p3_(1.0f) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) - : __bucket_list_(nullptr, - __bucket_list_deleter(allocator_traits<__pointer_allocator>:: - select_on_container_copy_construction( - __u.__bucket_list_.get_deleter().__alloc()), 0)), - __p1_(__second_tag(), allocator_traits<__node_allocator>:: - select_on_container_copy_construction(__u.__node_alloc())), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) -{ -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, __u.hash_function()), - __p3_(__u.__p3_) -{ -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) - _NOEXCEPT_( - is_nothrow_move_constructible<__bucket_list>::value && - is_nothrow_move_constructible<__first_node>::value && - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value && - is_nothrow_move_constructible::value) - : __bucket_list_(_VSTD::move(__u.__bucket_list_)), - __p1_(_VSTD::move(__u.__p1_)), - __p2_(_VSTD::move(__u.__p2_)), - __p3_(_VSTD::move(__u.__p3_)) -{ - if (size() > 0) - { - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; - __u.size() = 0; - } -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, - const allocator_type& __a) - : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0, _VSTD::move(__u.hash_function())), - __p3_(_VSTD::move(__u.__p3_)) -{ - if (__a == allocator_type(__u.__node_alloc())) - { - __bucket_list_.reset(__u.__bucket_list_.release()); - __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); - __u.__bucket_list_.get_deleter().size() = 0; - if (__u.size() > 0) - { - __p1_.first().__next_ = __u.__p1_.first().__next_; - __u.__p1_.first().__next_ = nullptr; - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - size() = __u.size(); - __u.size() = 0; - } - } -} - -#endif // _LIBCPP_CXX03_LANG - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() -{ -#if defined(_LIBCPP_CXX03_LANG) - static_assert((is_copy_constructible::value), - "Predicate must be copy-constructible."); - static_assert((is_copy_constructible::value), - "Hasher must be copy-constructible."); -#endif - - __deallocate_node(__p1_.first().__next_); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__erase_c(this); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__copy_assign_alloc( - const __hash_table& __u, true_type) -{ - if (__node_alloc() != __u.__node_alloc()) - { - clear(); - __bucket_list_.reset(); - __bucket_list_.get_deleter().size() = 0; - } - __bucket_list_.get_deleter().__alloc() = __u.__bucket_list_.get_deleter().__alloc(); - __node_alloc() = __u.__node_alloc(); -} - -template -__hash_table<_Tp, _Hash, _Equal, _Alloc>& -__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) -{ - if (this != &__u) - { - __copy_assign_alloc(__u); - hash_function() = __u.hash_function(); - key_eq() = __u.key_eq(); - max_load_factor() = __u.max_load_factor(); - __assign_multi(__u.begin(), __u.end()); - } - return *this; -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) - _NOEXCEPT -{ - __node_allocator& __na = __node_alloc(); - while (__np != nullptr) - { - __next_pointer __next = __np->__next_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - __c_node* __c = __get_db()->__find_c_and_lock(this); - for (__i_node** __p = __c->end_; __p != __c->beg_; ) - { - --__p; - iterator* __i = static_cast((*__p)->__i_); - if (__i->__node_ == __np) - { - (*__p)->__c_ = nullptr; - if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); - } - } - __get_db()->unlock(); -#endif - __node_pointer __real_np = __np->__upcast(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__value_)); - __node_traits::deallocate(__na, __real_np, 1); - __np = __next; - } -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__next_pointer -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT -{ - size_type __bc = bucket_count(); - for (size_type __i = 0; __i < __bc; ++__i) - __bucket_list_[__i] = nullptr; - size() = 0; - __next_pointer __cache = __p1_.first().__next_; - __p1_.first().__next_ = nullptr; - return __cache; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( - __hash_table& __u, true_type) - _NOEXCEPT_( - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value) -{ - clear(); - __bucket_list_.reset(__u.__bucket_list_.release()); - __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); - __u.__bucket_list_.get_deleter().size() = 0; - __move_assign_alloc(__u); - size() = __u.size(); - hash_function() = _VSTD::move(__u.hash_function()); - max_load_factor() = __u.max_load_factor(); - key_eq() = _VSTD::move(__u.key_eq()); - __p1_.first().__next_ = __u.__p1_.first().__next_; - if (size() > 0) - { - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - __u.__p1_.first().__next_ = nullptr; - __u.size() = 0; - } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->swap(this, &__u); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( - __hash_table& __u, false_type) -{ - if (__node_alloc() == __u.__node_alloc()) - __move_assign(__u, true_type()); - else - { - hash_function() = _VSTD::move(__u.hash_function()); - key_eq() = _VSTD::move(__u.key_eq()); - max_load_factor() = __u.max_load_factor(); - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - const_iterator __i = __u.begin(); - while (__cache != nullptr && __u.size() != 0) - { - __cache->__upcast()->__value_ = - _VSTD::move(__u.remove(__i++)->__value_); - __next_pointer __next = __cache->__next_; - __node_insert_multi(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - const_iterator __i = __u.begin(); - while (__u.size() != 0) - { - __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_)); - __node_insert_multi(__h.get()); - __h.release(); - } - } -} - -template -inline -__hash_table<_Tp, _Hash, _Equal, _Alloc>& -__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable<__node_allocator>::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable::value) -{ - __move_assign(__u, integral_constant()); - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, - _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value), - "__assign_unique may only be called with the containers value type"); - - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__upcast()->__value_ = *__first; - __next_pointer __next = __cache->__next_; - __node_insert_unique(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - for (; __first != __last; ++__first) - __insert_unique(*__first); -} - -template -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, - _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value || - is_same<_ItValueType, __node_value_type>::value), - "__assign_multi may only be called with the containers value type" - " or the nodes value type"); - if (bucket_count() != 0) - { - __next_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__upcast()->__value_ = *__first; - __next_pointer __next = __cache->__next_; - __node_insert_multi(__cache->__upcast()); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - __deallocate_node(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - __deallocate_node(__cache); - } - for (; __first != __last; ++__first) - __insert_multi(_NodeTypes::__get_value(*__first)); -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__p1_.first().__next_, this); -#else - return iterator(__p1_.first().__next_); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(nullptr, this); -#else - return iterator(nullptr); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(__p1_.first().__next_, this); -#else - return const_iterator(__p1_.first().__next_); -#endif -} - -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(nullptr, this); -#else - return const_iterator(nullptr); -#endif -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT -{ - if (size() > 0) - { - __deallocate_node(__p1_.first().__next_); - __p1_.first().__next_ = nullptr; - size_type __bc = bucket_count(); - for (size_type __i = 0; __i < __bc; ++__i) - __bucket_list_[__i] = nullptr; - size() = 0; - } -} - -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd) -{ - __nd->__hash_ = hash_function()(__nd->__value_); - size_type __bc = bucket_count(); - bool __inserted = false; - __next_pointer __ndptr; - size_t __chash; - if (__bc != 0) - { - __chash = __constrain_hash(__nd->__hash_, __bc); - __ndptr = __bucket_list_[__chash]; - if (__ndptr != nullptr) - { - for (__ndptr = __ndptr->__next_; __ndptr != nullptr && - __constrain_hash(__ndptr->__hash(), __bc) == __chash; - __ndptr = __ndptr->__next_) - { - if (key_eq()(__ndptr->__upcast()->__value_, __nd->__value_)) - goto __done; - } - } - } - { - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - __chash = __constrain_hash(__nd->__hash_, __bc); - } - // insert_after __bucket_list_[__chash], or __first_node if bucket is null - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn == nullptr) - { - __pn =__p1_.first().__ptr(); - __nd->__next_ = __pn->__next_; - __pn->__next_ = __nd->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__nd->__next_ != nullptr) - __bucket_list_[__constrain_hash(__nd->__next_->__hash(), __bc)] = __nd->__ptr(); - } - else - { - __nd->__next_ = __pn->__next_; - __pn->__next_ = __nd->__ptr(); - } - __ndptr = __nd->__ptr(); - // increment size - ++size(); - __inserted = true; - } -__done: -#if _LIBCPP_DEBUG_LEVEL >= 2 - return pair(iterator(__ndptr, this), __inserted); -#else - return pair(iterator(__ndptr), __inserted); -#endif -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp) -{ - __cp->__hash_ = hash_function()(__cp->__value_); - size_type __bc = bucket_count(); - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - } - size_t __chash = __constrain_hash(__cp->__hash_, __bc); - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn == nullptr) - { - __pn =__p1_.first().__ptr(); - __cp->__next_ = __pn->__next_; - __pn->__next_ = __cp->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__cp->__next_ != nullptr) - __bucket_list_[__constrain_hash(__cp->__next_->__hash(), __bc)] - = __cp->__ptr(); - } - else - { - for (bool __found = false; __pn->__next_ != nullptr && - __constrain_hash(__pn->__next_->__hash(), __bc) == __chash; - __pn = __pn->__next_) - { - // __found key_eq() action - // false false loop - // true true loop - // false true set __found to true - // true false break - if (__found != (__pn->__next_->__hash() == __cp->__hash_ && - key_eq()(__pn->__next_->__upcast()->__value_, __cp->__value_))) - { - if (!__found) - __found = true; - else - break; - } - } - __cp->__next_ = __pn->__next_; - __pn->__next_ = __cp->__ptr(); - if (__cp->__next_ != nullptr) - { - size_t __nhash = __constrain_hash(__cp->__next_->__hash(), __bc); - if (__nhash != __chash) - __bucket_list_[__nhash] = __cp->__ptr(); - } - } - ++size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__cp->__ptr(), this); -#else - return iterator(__cp->__ptr()); -#endif -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( - const_iterator __p, __node_pointer __cp) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); -#endif - if (__p != end() && key_eq()(*__p, __cp->__value_)) - { - __next_pointer __np = __p.__node_; - __cp->__hash_ = __np->__hash(); - size_type __bc = bucket_count(); - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - } - size_t __chash = __constrain_hash(__cp->__hash_, __bc); - __next_pointer __pp = __bucket_list_[__chash]; - while (__pp->__next_ != __np) - __pp = __pp->__next_; - __cp->__next_ = __np; - __pp->__next_ = static_cast<__next_pointer>(__cp); - ++size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(static_cast<__next_pointer>(__cp), this); -#else - return iterator(static_cast<__next_pointer>(__cp)); -#endif - } - return __node_insert_multi(__cp); -} - - - -#ifndef _LIBCPP_CXX03_LANG -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) -#else -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args) -#endif -{ - - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - bool __inserted = false; - __next_pointer __nd; - size_t __chash; - if (__bc != 0) - { - __chash = __constrain_hash(__hash, __bc); - __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__nd->__hash() == __hash || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if (key_eq()(__nd->__upcast()->__value_, __k)) - goto __done; - } - } - } - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node_hash(__hash, __args); -#endif - if (size()+1 > __bc * max_load_factor() || __bc == 0) - { - rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), - size_type(ceil(float(size() + 1) / max_load_factor())))); - __bc = bucket_count(); - __chash = __constrain_hash(__hash, __bc); - } - // insert_after __bucket_list_[__chash], or __first_node if bucket is null - __next_pointer __pn = __bucket_list_[__chash]; - if (__pn == nullptr) - { - __pn = __p1_.first().__ptr(); - __h->__next_ = __pn->__next_; - __pn->__next_ = __h.get()->__ptr(); - // fix up __bucket_list_ - __bucket_list_[__chash] = __pn; - if (__h->__next_ != nullptr) - __bucket_list_[__constrain_hash(__h->__next_->__hash(), __bc)] - = __h.get()->__ptr(); - } - else - { - __h->__next_ = __pn->__next_; - __pn->__next_ = static_cast<__next_pointer>(__h.get()); - } - __nd = static_cast<__next_pointer>(__h.release()); - // increment size - ++size(); - __inserted = true; - } -__done: -#if _LIBCPP_DEBUG_LEVEL >= 2 - return pair(iterator(__nd, this), __inserted); -#else - return pair(iterator(__nd), __inserted); -#endif -} - -#ifndef _LIBCPP_CXX03_LANG - -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_impl(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - pair __r = __node_insert_unique(__h.get()); - if (__r.second) - __h.release(); - return __r; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_multi(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - iterator __r = __node_insert_multi(__h.get()); - __h.release(); - return __r; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( - const_iterator __p, _Args&&... __args) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); -#endif - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - iterator __r = __node_insert_multi(__p, __h.get()); - __h.release(); - return __r; -} - -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x) -{ - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__h.get()); - __h.release(); - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, - const __container_value_type& __x) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::insert(const_iterator, lvalue) called with an iterator not" - " referring to this unordered container"); -#endif - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__p, __h.get()); - __h.release(); - return __r; -} - -#endif // _LIBCPP_CXX03_LANG - -#if _LIBCPP_STD_VER > 14 -template -template -_LIBCPP_INLINE_VISIBILITY -_InsertReturnType -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return _InsertReturnType{end(), false, _NodeHandle()}; - pair __result = __node_insert_unique(__nh.__ptr_); - if (__result.second) - __nh.__release(); - return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)}; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique( - const_iterator, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - pair __result = __node_insert_unique(__nh.__ptr_); - if (__result.second) - __nh.__release(); - return __result.first; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract( - key_type const& __key) -{ - iterator __i = find(__key); - if (__i == end()) - return _NodeHandle(); - return __node_handle_extract<_NodeHandle>(__i); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_extract( - const_iterator __p) -{ - allocator_type __alloc(__node_alloc()); - return _NodeHandle(remove(__p).release(), __alloc); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - iterator __result = __node_insert_multi(__nh.__ptr_); - __nh.__release(); - return __result; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - iterator __result = __node_insert_multi(__hint, __nh.__ptr_); - __nh.__release(); - return __result; -} - -#endif // _LIBCPP_STD_VER > 14 - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) -{ - if (__n == 1) - __n = 2; - else if (__n & (__n - 1)) - __n = __next_prime(__n); - size_type __bc = bucket_count(); - if (__n > __bc) - __rehash(__n); - else if (__n < __bc) - { - __n = _VSTD::max - ( - __n, - __is_hash_power2(__bc) ? __next_hash_pow2(size_t(ceil(float(size()) / max_load_factor()))) : - __next_prime(size_t(ceil(float(size()) / max_load_factor()))) - ); - if (__n < __bc) - __rehash(__n); - } -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__invalidate_all(this); -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); - __bucket_list_.reset(__nbc > 0 ? - __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); - __bucket_list_.get_deleter().size() = __nbc; - if (__nbc > 0) - { - for (size_type __i = 0; __i < __nbc; ++__i) - __bucket_list_[__i] = nullptr; - __next_pointer __pp = __p1_.first().__ptr(); - __next_pointer __cp = __pp->__next_; - if (__cp != nullptr) - { - size_type __chash = __constrain_hash(__cp->__hash(), __nbc); - __bucket_list_[__chash] = __pp; - size_type __phash = __chash; - for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr; - __cp = __pp->__next_) - { - __chash = __constrain_hash(__cp->__hash(), __nbc); - if (__chash == __phash) - __pp = __cp; - else - { - if (__bucket_list_[__chash] == nullptr) - { - __bucket_list_[__chash] = __pp; - __pp = __cp; - __phash = __chash; - } - else - { - __next_pointer __np = __cp; - for (; __np->__next_ != nullptr && - key_eq()(__cp->__upcast()->__value_, - __np->__next_->__upcast()->__value_); - __np = __np->__next_) - ; - __pp->__next_ = __np->__next_; - __np->__next_ = __bucket_list_[__chash]->__next_; - __bucket_list_[__chash]->__next_ = __cp; - - } - } - } - } - } -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) -{ - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - if (__bc != 0) - { - size_t __chash = __constrain_hash(__hash, __bc); - __next_pointer __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__nd->__hash() == __hash - || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__nd, this); -#else - return iterator(__nd); -#endif - } - } - } - return end(); -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const -{ - size_t __hash = hash_function()(__k); - size_type __bc = bucket_count(); - if (__bc != 0) - { - size_t __chash = __constrain_hash(__hash, __bc); - __next_pointer __nd = __bucket_list_[__chash]; - if (__nd != nullptr) - { - for (__nd = __nd->__next_; __nd != nullptr && - (__hash == __nd->__hash() - || __constrain_hash(__nd->__hash(), __bc) == __chash); - __nd = __nd->__next_) - { - if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(__nd, this); -#else - return const_iterator(__nd); -#endif - } - } - - } - return end(); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args) -{ - static_assert(!__is_hash_value_type<_Args...>::value, - "Construct cannot be called with a hash value type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; - return __h; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash( - size_t __hash, _First&& __f, _Rest&& ...__rest) -{ - static_assert(!__is_hash_value_type<_First, _Rest...>::value, - "Construct cannot be called with a hash value type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), - _VSTD::forward<_First>(__f), - _VSTD::forward<_Rest>(__rest)...); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; - return __h; -} - -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, - const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -#endif // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) -{ - __next_pointer __np = __p.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container erase(iterator) called with an iterator not" - " referring to this container"); - _LIBCPP_ASSERT(__p != end(), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); - iterator __r(__np, this); -#else - iterator __r(__np); -#endif - ++__r; - remove(__p); - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, - const_iterator __last) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); -#endif - for (const_iterator __p = __first; __first != __last; __p = __first) - { - ++__first; - erase(__p); - } - __next_pointer __np = __last.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator (__np, this); -#else - return iterator (__np); -#endif -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_unique(const _Key& __k) -{ - iterator __i = find(__k); - if (__i == end()) - return 0; - erase(__i); - return 1; -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__erase_multi(const _Key& __k) -{ - size_type __r = 0; - iterator __i = find(__k); - if (__i != end()) - { - iterator __e = end(); - do - { - erase(__i++); - ++__r; - } while (__i != __e && key_eq()(*__i, __k)); - } - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT -{ - // current node - __next_pointer __cn = __p.__node_; - size_type __bc = bucket_count(); - size_t __chash = __constrain_hash(__cn->__hash(), __bc); - // find previous node - __next_pointer __pn = __bucket_list_[__chash]; - for (; __pn->__next_ != __cn; __pn = __pn->__next_) - ; - // Fix up __bucket_list_ - // if __pn is not in same bucket (before begin is not in same bucket) && - // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) - if (__pn == __p1_.first().__ptr() - || __constrain_hash(__pn->__hash(), __bc) != __chash) - { - if (__cn->__next_ == nullptr - || __constrain_hash(__cn->__next_->__hash(), __bc) != __chash) - __bucket_list_[__chash] = nullptr; - } - // if __cn->__next_ is not in same bucket (nullptr is in same bucket) - if (__cn->__next_ != nullptr) - { - size_t __nhash = __constrain_hash(__cn->__next_->__hash(), __bc); - if (__nhash != __chash) - __bucket_list_[__nhash] = __pn; - } - // remove __cn - __pn->__next_ = __cn->__next_; - __cn->__next_ = nullptr; - --size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __c_node* __c = __get_db()->__find_c_and_lock(this); - for (__i_node** __dp = __c->end_; __dp != __c->beg_; ) - { - --__dp; - iterator* __i = static_cast((*__dp)->__i_); - if (__i->__node_ == __cn) - { - (*__dp)->__c_ = nullptr; - if (--__c->end_ != __dp) - memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); - } - } - __get_db()->unlock(); -#endif - return __node_holder(__cn->__upcast(), _Dp(__node_alloc(), true)); -} - -template -template -inline -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const -{ - return static_cast(find(__k) != end()); -} - -template -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_multi(const _Key& __k) const -{ - size_type __r = 0; - const_iterator __i = find(__k); - if (__i != end()) - { - const_iterator __e = end(); - do - { - ++__i; - ++__r; - } while (__i != __e && key_eq()(*__i, __k)); - } - return __r; -} - -template -template -pair::iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( - const _Key& __k) -{ - iterator __i = find(__k); - iterator __j = __i; - if (__i != end()) - ++__j; - return pair(__i, __j); -} - -template -template -pair::const_iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_unique( - const _Key& __k) const -{ - const_iterator __i = find(__k); - const_iterator __j = __i; - if (__i != end()) - ++__j; - return pair(__i, __j); -} - -template -template -pair::iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( - const _Key& __k) -{ - iterator __i = find(__k); - iterator __j = __i; - if (__i != end()) - { - iterator __e = end(); - do - { - ++__j; - } while (__j != __e && key_eq()(*__j, __k)); - } - return pair(__i, __j); -} - -template -template -pair::const_iterator, - typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( - const _Key& __k) const -{ - const_iterator __i = find(__k); - const_iterator __j = __i; - if (__i != end()) - { - const_iterator __e = end(); - do - { - ++__j; - } while (__j != __e && key_eq()(*__j, __k)); - } - return pair(__i, __j); -} - -template -void -__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_DEBUG_( - __is_nothrow_swappable::value && __is_nothrow_swappable::value - && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value - || __is_nothrow_swappable<__pointer_allocator>::value) - && (!__node_traits::propagate_on_container_swap::value - || __is_nothrow_swappable<__node_allocator>::value) - ) -#else - _NOEXCEPT_DEBUG_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) -#endif -{ - _LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value || - this->__node_alloc() == __u.__node_alloc(), - "list::swap: Either propagate_on_container_swap must be true" - " or the allocators must compare equal"); - { - __node_pointer_pointer __npp = __bucket_list_.release(); - __bucket_list_.reset(__u.__bucket_list_.release()); - __u.__bucket_list_.reset(__npp); - } - _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); - __swap_allocator(__bucket_list_.get_deleter().__alloc(), - __u.__bucket_list_.get_deleter().__alloc()); - __swap_allocator(__node_alloc(), __u.__node_alloc()); - _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_); - __p2_.swap(__u.__p2_); - __p3_.swap(__u.__p3_); - if (size() > 0) - __bucket_list_[__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = - __p1_.first().__ptr(); - if (__u.size() > 0) - __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = - __u.__p1_.first().__ptr(); -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->swap(this, &__u); -#endif -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type -__hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const -{ - _LIBCPP_ASSERT(__n < bucket_count(), - "unordered container::bucket_size(n) called with n >= bucket_count()"); - __next_pointer __np = __bucket_list_[__n]; - size_type __bc = bucket_count(); - size_type __r = 0; - if (__np != nullptr) - { - for (__np = __np->__next_; __np != nullptr && - __constrain_hash(__np->__hash(), __bc) == __n; - __np = __np->__next_, ++__r) - ; - } - return __r; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, - __hash_table<_Tp, _Hash, _Equal, _Alloc>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -#if _LIBCPP_DEBUG_LEVEL >= 2 - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__dereferenceable(const const_iterator* __i) const -{ - return __i->__node_ != nullptr; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__decrementable(const const_iterator*) const -{ - return false; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const -{ - return false; -} - -template -bool -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const -{ - return false; -} - -#endif // _LIBCPP_DEBUG_LEVEL >= 2 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP__HASH_TABLE diff --git a/external/include/c++/v1/__libcpp_version b/external/include/c++/v1/__libcpp_version deleted file mode 100644 index e002b36..0000000 --- a/external/include/c++/v1/__libcpp_version +++ /dev/null @@ -1 +0,0 @@ -8000 diff --git a/external/include/c++/v1/__locale b/external/include/c++/v1/__locale deleted file mode 100644 index f43e7b4..0000000 --- a/external/include/c++/v1/__locale +++ /dev/null @@ -1,1523 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___LOCALE -#define _LIBCPP___LOCALE - -#include <__config> -#include -#include -#include -#include -#include -#include -#include -#if defined(_LIBCPP_MSVCRT_LIKE) -# include -#elif defined(_AIX) -# include -#elif defined(__ANDROID__) -# include -#elif defined(__sun__) -# include -# include -#elif defined(_NEWLIB_VERSION) -# include -#elif (defined(__APPLE__) || defined(__FreeBSD__) \ - || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) -# include -#elif defined(__Fuchsia__) -# include -#elif defined(_LIBCPP_HAS_MUSL_LIBC) -# include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS) -struct __libcpp_locale_guard { - _LIBCPP_INLINE_VISIBILITY - __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {} - - _LIBCPP_INLINE_VISIBILITY - ~__libcpp_locale_guard() { - if (__old_loc_) - uselocale(__old_loc_); - } - - locale_t __old_loc_; -private: - __libcpp_locale_guard(__libcpp_locale_guard const&); - __libcpp_locale_guard& operator=(__libcpp_locale_guard const&); -}; -#elif defined(_LIBCPP_MSVCRT_LIKE) -struct __libcpp_locale_guard { - __libcpp_locale_guard(locale_t __l) : - __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)), - __locale_collate(setlocale(LC_COLLATE, __l.__get_locale())), - __locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())), - __locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())), - __locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())), - __locale_time(setlocale(LC_TIME, __l.__get_locale())) - // LC_MESSAGES is not supported on Windows. - {} - ~__libcpp_locale_guard() { - setlocale(LC_COLLATE, __locale_collate); - setlocale(LC_CTYPE, __locale_ctype); - setlocale(LC_MONETARY, __locale_monetary); - setlocale(LC_NUMERIC, __locale_numeric); - setlocale(LC_TIME, __locale_time); - _configthreadlocale(__status); - } - int __status; - char* __locale_collate; - char* __locale_ctype; - char* __locale_monetary; - char* __locale_numeric; - char* __locale_time; -}; -#endif - - -class _LIBCPP_TYPE_VIS locale; - -template -_LIBCPP_INLINE_VISIBILITY -bool -has_facet(const locale&) _NOEXCEPT; - -template -_LIBCPP_INLINE_VISIBILITY -const _Facet& -use_facet(const locale&); - -class _LIBCPP_TYPE_VIS locale -{ -public: - // types: - class _LIBCPP_TYPE_VIS facet; - class _LIBCPP_TYPE_VIS id; - - typedef int category; - _LIBCPP_AVAILABILITY_LOCALE_CATEGORY - static const category // values assigned here are for exposition only - none = 0, - collate = LC_COLLATE_MASK, - ctype = LC_CTYPE_MASK, - monetary = LC_MONETARY_MASK, - numeric = LC_NUMERIC_MASK, - time = LC_TIME_MASK, - messages = LC_MESSAGES_MASK, - all = collate | ctype | monetary | numeric | time | messages; - - // construct/copy/destroy: - locale() _NOEXCEPT; - locale(const locale&) _NOEXCEPT; - explicit locale(const char*); - explicit locale(const string&); - locale(const locale&, const char*, category); - locale(const locale&, const string&, category); - template - _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*); - locale(const locale&, const locale&, category); - - ~locale(); - - const locale& operator=(const locale&) _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - locale combine(const locale&) const; - - // locale operations: - string name() const; - bool operator==(const locale&) const; - bool operator!=(const locale& __y) const {return !(*this == __y);} - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, - const basic_string<_CharT, _Traits, _Allocator>&) const; - - // global locale objects: - static locale global(const locale&); - static const locale& classic(); - -private: - class __imp; - __imp* __locale_; - - void __install_ctor(const locale&, facet*, long); - static locale& __global(); - bool has_facet(id&) const; - const facet* use_facet(id&) const; - - template friend bool has_facet(const locale&) _NOEXCEPT; - template friend const _Facet& use_facet(const locale&); -}; - -class _LIBCPP_TYPE_VIS locale::facet - : public __shared_count -{ -protected: - _LIBCPP_INLINE_VISIBILITY - explicit facet(size_t __refs = 0) - : __shared_count(static_cast(__refs)-1) {} - - virtual ~facet(); - -// facet(const facet&) = delete; // effectively done in __shared_count -// void operator=(const facet&) = delete; -private: - virtual void __on_zero_shared() _NOEXCEPT; -}; - -class _LIBCPP_TYPE_VIS locale::id -{ - once_flag __flag_; - int32_t __id_; - - static int32_t __next_id; -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} -private: - void __init(); - void operator=(const id&); // = delete; - id(const id&); // = delete; -public: // only needed for tests - long __get(); - - friend class locale; - friend class locale::__imp; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -locale::locale(const locale& __other, _Facet* __f) -{ - __install_ctor(__other, __f, __f ? __f->id.__get() : 0); -} - -template -locale -locale::combine(const locale& __other) const -{ - if (!_VSTD::has_facet<_Facet>(__other)) - __throw_runtime_error("locale::combine: locale missing facet"); - - return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -has_facet(const locale& __l) _NOEXCEPT -{ - return __l.has_facet(_Facet::id); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -const _Facet& -use_facet(const locale& __l) -{ - return static_cast(*__l.use_facet(_Facet::id)); -} - -// template class collate; - -template -class _LIBCPP_TEMPLATE_VIS collate - : public locale::facet -{ -public: - typedef _CharT char_type; - typedef basic_string string_type; - - _LIBCPP_INLINE_VISIBILITY - explicit collate(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - int compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const - { - return do_compare(__lo1, __hi1, __lo2, __hi2); - } - - _LIBCPP_INLINE_VISIBILITY - string_type transform(const char_type* __lo, const char_type* __hi) const - { - return do_transform(__lo, __hi); - } - - _LIBCPP_INLINE_VISIBILITY - long hash(const char_type* __lo, const char_type* __hi) const - { - return do_hash(__lo, __hi); - } - - static locale::id id; - -protected: - ~collate(); - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const - {return string_type(__lo, __hi);} - virtual long do_hash(const char_type* __lo, const char_type* __hi) const; -}; - -template locale::id collate<_CharT>::id; - -template -collate<_CharT>::~collate() -{ -} - -template -int -collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const -{ - for (; __lo2 != __hi2; ++__lo1, ++__lo2) - { - if (__lo1 == __hi1 || *__lo1 < *__lo2) - return -1; - if (*__lo2 < *__lo1) - return 1; - } - return __lo1 != __hi1; -} - -template -long -collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const -{ - size_t __h = 0; - const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; - const size_t __mask = size_t(0xF) << (__sr + 4); - for(const char_type* __p = __lo; __p != __hi; ++__p) - { - __h = (__h << 4) + static_cast(*__p); - size_t __g = __h & __mask; - __h ^= __g | (__g >> __sr); - } - return static_cast(__h); -} - -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) - -// template class collate_byname; - -template class _LIBCPP_TEMPLATE_VIS collate_byname; - -template <> -class _LIBCPP_TYPE_VIS collate_byname - : public collate -{ - locale_t __l; -public: - typedef char char_type; - typedef basic_string string_type; - - explicit collate_byname(const char* __n, size_t __refs = 0); - explicit collate_byname(const string& __n, size_t __refs = 0); - -protected: - ~collate_byname(); - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; -}; - -template <> -class _LIBCPP_TYPE_VIS collate_byname - : public collate -{ - locale_t __l; -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit collate_byname(const char* __n, size_t __refs = 0); - explicit collate_byname(const string& __n, size_t __refs = 0); - -protected: - ~collate_byname(); - - virtual int do_compare(const char_type* __lo1, const char_type* __hi1, - const char_type* __lo2, const char_type* __hi2) const; - virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; -}; - -template -bool -locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, - const basic_string<_CharT, _Traits, _Allocator>& __y) const -{ - return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare( - __x.data(), __x.data() + __x.size(), - __y.data(), __y.data() + __y.size()) < 0; -} - -// template class ctype - -class _LIBCPP_TYPE_VIS ctype_base -{ -public: -#if defined(__GLIBC__) - typedef unsigned short mask; - static const mask space = _ISspace; - static const mask print = _ISprint; - static const mask cntrl = _IScntrl; - static const mask upper = _ISupper; - static const mask lower = _ISlower; - static const mask alpha = _ISalpha; - static const mask digit = _ISdigit; - static const mask punct = _ISpunct; - static const mask xdigit = _ISxdigit; - static const mask blank = _ISblank; -#elif defined(_LIBCPP_MSVCRT_LIKE) - typedef unsigned short mask; - static const mask space = _SPACE; - static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; - static const mask cntrl = _CONTROL; - static const mask upper = _UPPER; - static const mask lower = _LOWER; - static const mask alpha = _ALPHA; - static const mask digit = _DIGIT; - static const mask punct = _PUNCT; - static const mask xdigit = _HEX; - static const mask blank = _BLANK; -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT -#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) -# ifdef __APPLE__ - typedef __uint32_t mask; -# elif defined(__FreeBSD__) - typedef unsigned long mask; -# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) - typedef unsigned short mask; -# endif - static const mask space = _CTYPE_S; - static const mask print = _CTYPE_R; - static const mask cntrl = _CTYPE_C; - static const mask upper = _CTYPE_U; - static const mask lower = _CTYPE_L; - static const mask alpha = _CTYPE_A; - static const mask digit = _CTYPE_D; - static const mask punct = _CTYPE_P; - static const mask xdigit = _CTYPE_X; - -# if defined(__NetBSD__) - static const mask blank = _CTYPE_BL; -# else - static const mask blank = _CTYPE_B; -# endif -#elif defined(__sun__) || defined(_AIX) - typedef unsigned int mask; - static const mask space = _ISSPACE; - static const mask print = _ISPRINT; - static const mask cntrl = _ISCNTRL; - static const mask upper = _ISUPPER; - static const mask lower = _ISLOWER; - static const mask alpha = _ISALPHA; - static const mask digit = _ISDIGIT; - static const mask punct = _ISPUNCT; - static const mask xdigit = _ISXDIGIT; - static const mask blank = _ISBLANK; -#elif defined(_NEWLIB_VERSION) - // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. - typedef char mask; - static const mask space = _S; - static const mask print = _P | _U | _L | _N | _B; - static const mask cntrl = _C; - static const mask upper = _U; - static const mask lower = _L; - static const mask alpha = _U | _L; - static const mask digit = _N; - static const mask punct = _P; - static const mask xdigit = _X | _N; - static const mask blank = _B; -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA -# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT -#else - typedef unsigned long mask; - static const mask space = 1<<0; - static const mask print = 1<<1; - static const mask cntrl = 1<<2; - static const mask upper = 1<<3; - static const mask lower = 1<<4; - static const mask alpha = 1<<5; - static const mask digit = 1<<6; - static const mask punct = 1<<7; - static const mask xdigit = 1<<8; - static const mask blank = 1<<9; -#endif - static const mask alnum = alpha | digit; - static const mask graph = alnum | punct; - - _LIBCPP_INLINE_VISIBILITY ctype_base() {} -}; - -template class _LIBCPP_TEMPLATE_VIS ctype; - -template <> -class _LIBCPP_TYPE_VIS ctype - : public locale::facet, - public ctype_base -{ -public: - typedef wchar_t char_type; - - _LIBCPP_INLINE_VISIBILITY - explicit ctype(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - bool is(mask __m, char_type __c) const - { - return do_is(__m, __c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const - { - return do_is(__low, __high, __vec); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const - { - return do_scan_is(__m, __low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const - { - return do_scan_not(__m, __low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type toupper(char_type __c) const - { - return do_toupper(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* toupper(char_type* __low, const char_type* __high) const - { - return do_toupper(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type tolower(char_type __c) const - { - return do_tolower(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* tolower(char_type* __low, const char_type* __high) const - { - return do_tolower(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type widen(char __c) const - { - return do_widen(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char* widen(const char* __low, const char* __high, char_type* __to) const - { - return do_widen(__low, __high, __to); - } - - _LIBCPP_INLINE_VISIBILITY - char narrow(char_type __c, char __dfault) const - { - return do_narrow(__c, __dfault); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const - { - return do_narrow(__low, __high, __dfault, __to); - } - - static locale::id id; - -protected: - ~ctype(); - virtual bool do_is(mask __m, char_type __c) const; - virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; - virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; - virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; - virtual char do_narrow(char_type, char __dfault) const; - virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; -}; - -template <> -class _LIBCPP_TYPE_VIS ctype - : public locale::facet, public ctype_base -{ - const mask* __tab_; - bool __del_; -public: - typedef char char_type; - - explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY - bool is(mask __m, char_type __c) const - { - return isascii(__c) ? (__tab_[static_cast(__c)] & __m) !=0 : false; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const - { - for (; __low != __high; ++__low, ++__vec) - *__vec = isascii(*__low) ? __tab_[static_cast(*__low)] : 0; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const - { - for (; __low != __high; ++__low) - if (isascii(*__low) && (__tab_[static_cast(*__low)] & __m)) - break; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const - { - for (; __low != __high; ++__low) - if (!(isascii(*__low) && (__tab_[static_cast(*__low)] & __m))) - break; - return __low; - } - - _LIBCPP_INLINE_VISIBILITY - char_type toupper(char_type __c) const - { - return do_toupper(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* toupper(char_type* __low, const char_type* __high) const - { - return do_toupper(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type tolower(char_type __c) const - { - return do_tolower(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char_type* tolower(char_type* __low, const char_type* __high) const - { - return do_tolower(__low, __high); - } - - _LIBCPP_INLINE_VISIBILITY - char_type widen(char __c) const - { - return do_widen(__c); - } - - _LIBCPP_INLINE_VISIBILITY - const char* widen(const char* __low, const char* __high, char_type* __to) const - { - return do_widen(__low, __high, __to); - } - - _LIBCPP_INLINE_VISIBILITY - char narrow(char_type __c, char __dfault) const - { - return do_narrow(__c, __dfault); - } - - _LIBCPP_INLINE_VISIBILITY - const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const - { - return do_narrow(__low, __high, __dfault, __to); - } - - static locale::id id; - -#ifdef _CACHED_RUNES - static const size_t table_size = _CACHED_RUNES; -#else - static const size_t table_size = 256; // FIXME: Don't hardcode this. -#endif - _LIBCPP_INLINE_VISIBILITY const mask* table() const _NOEXCEPT {return __tab_;} - static const mask* classic_table() _NOEXCEPT; -#if defined(__GLIBC__) || defined(__EMSCRIPTEN__) - static const int* __classic_upper_table() _NOEXCEPT; - static const int* __classic_lower_table() _NOEXCEPT; -#endif -#if defined(__NetBSD__) - static const short* __classic_upper_table() _NOEXCEPT; - static const short* __classic_lower_table() _NOEXCEPT; -#endif - -protected: - ~ctype(); - virtual char_type do_toupper(char_type __c) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type __c) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char __c) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const; - virtual char do_narrow(char_type __c, char __dfault) const; - virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const; -}; - -// template class ctype_byname; - -template class _LIBCPP_TEMPLATE_VIS ctype_byname; - -template <> -class _LIBCPP_TYPE_VIS ctype_byname - : public ctype -{ - locale_t __l; - -public: - explicit ctype_byname(const char*, size_t = 0); - explicit ctype_byname(const string&, size_t = 0); - -protected: - ~ctype_byname(); - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; -}; - -template <> -class _LIBCPP_TYPE_VIS ctype_byname - : public ctype -{ - locale_t __l; - -public: - explicit ctype_byname(const char*, size_t = 0); - explicit ctype_byname(const string&, size_t = 0); - -protected: - ~ctype_byname(); - virtual bool do_is(mask __m, char_type __c) const; - virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; - virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; - virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; - virtual char_type do_toupper(char_type) const; - virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; - virtual char_type do_tolower(char_type) const; - virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; - virtual char_type do_widen(char) const; - virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; - virtual char do_narrow(char_type, char __dfault) const; - virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isspace(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::space, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isprint(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::print, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -iscntrl(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::cntrl, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isupper(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::upper, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -islower(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::lower, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isalpha(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::alpha, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isdigit(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::digit, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -ispunct(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::punct, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isxdigit(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::xdigit, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isalnum(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::alnum, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -bool -isgraph(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).is(ctype_base::graph, __c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_CharT -toupper(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).toupper(__c); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_CharT -tolower(_CharT __c, const locale& __loc) -{ - return use_facet >(__loc).tolower(__c); -} - -// codecvt_base - -class _LIBCPP_TYPE_VIS codecvt_base -{ -public: - _LIBCPP_INLINE_VISIBILITY codecvt_base() {} - enum result {ok, partial, error, noconv}; -}; - -// template class codecvt; - -template class _LIBCPP_TEMPLATE_VIS codecvt; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ - locale_t __l; -public: - typedef wchar_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - explicit codecvt(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - explicit codecvt(const char*, size_t __refs = 0); - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char16_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template <> class codecvt - -template <> -class _LIBCPP_TYPE_VIS codecvt - : public locale::facet, - public codecvt_base -{ -public: - typedef char32_t intern_type; - typedef char extern_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(size_t __refs = 0) - : locale::facet(__refs) {} - - _LIBCPP_INLINE_VISIBILITY - result out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const - { - return do_unshift(__st, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - result in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const - { - return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); - } - - _LIBCPP_INLINE_VISIBILITY - int encoding() const _NOEXCEPT - { - return do_encoding(); - } - - _LIBCPP_INLINE_VISIBILITY - bool always_noconv() const _NOEXCEPT - { - return do_always_noconv(); - } - - _LIBCPP_INLINE_VISIBILITY - int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const - { - return do_length(__st, __frm, __end, __mx); - } - - _LIBCPP_INLINE_VISIBILITY - int max_length() const _NOEXCEPT - { - return do_max_length(); - } - - static locale::id id; - -protected: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt(const char*, size_t __refs = 0) - : locale::facet(__refs) {} - - ~codecvt(); - - virtual result do_out(state_type& __st, - const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual result do_in(state_type& __st, - const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, - intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; - virtual result do_unshift(state_type& __st, - extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; - virtual int do_encoding() const _NOEXCEPT; - virtual bool do_always_noconv() const _NOEXCEPT; - virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; - virtual int do_max_length() const _NOEXCEPT; -}; - -// template class codecvt_byname - -template -class _LIBCPP_TEMPLATE_VIS codecvt_byname - : public codecvt<_InternT, _ExternT, _StateT> -{ -public: - _LIBCPP_INLINE_VISIBILITY - explicit codecvt_byname(const char* __nm, size_t __refs = 0) - : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} - _LIBCPP_INLINE_VISIBILITY - explicit codecvt_byname(const string& __nm, size_t __refs = 0) - : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {} -protected: - ~codecvt_byname(); -}; - -template -codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() -{ -} - -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) - -_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); - -template -struct __narrow_to_utf8 -{ - template - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const; -}; - -template <> -struct __narrow_to_utf8<8> -{ - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - for (; __wb < __we; ++__wb, ++__s) - *__s = *__wb; - return __s; - } -}; - -template <> -struct __narrow_to_utf8<16> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __narrow_to_utf8() : codecvt(1) {} - - ~__narrow_to_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - result __r = ok; - mbstate_t __mb; - while (__wb < __we && __r != error) - { - const int __sz = 32; - char __buf[__sz]; - char* __bn; - const char16_t* __wn = (const char16_t*)__wb; - __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) - __throw_runtime_error("locale not supported"); - for (const char* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = *__p; - __wb = (const _CharT*)__wn; - } - return __s; - } -}; - -template <> -struct __narrow_to_utf8<32> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __narrow_to_utf8() : codecvt(1) {} - - ~__narrow_to_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const - { - result __r = ok; - mbstate_t __mb; - while (__wb < __we && __r != error) - { - const int __sz = 32; - char __buf[__sz]; - char* __bn; - const char32_t* __wn = (const char32_t*)__wb; - __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) - __throw_runtime_error("locale not supported"); - for (const char* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = *__p; - __wb = (const _CharT*)__wn; - } - return __s; - } -}; - -template -struct __widen_from_utf8 -{ - template - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const; -}; - -template <> -struct __widen_from_utf8<8> -{ - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - for (; __nb < __ne; ++__nb, ++__s) - *__s = *__nb; - return __s; - } -}; - -template <> -struct __widen_from_utf8<16> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __widen_from_utf8() : codecvt(1) {} - - ~__widen_from_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - result __r = ok; - mbstate_t __mb; - while (__nb < __ne && __r != error) - { - const int __sz = 32; - char16_t __buf[__sz]; - char16_t* __bn; - const char* __nn = __nb; - __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __nn == __nb) - __throw_runtime_error("locale not supported"); - for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = (wchar_t)*__p; - __nb = __nn; - } - return __s; - } -}; - -template <> -struct __widen_from_utf8<32> - : public codecvt -{ - _LIBCPP_INLINE_VISIBILITY - __widen_from_utf8() : codecvt(1) {} - - ~__widen_from_utf8(); - - template - _LIBCPP_INLINE_VISIBILITY - _OutputIterator - operator()(_OutputIterator __s, const char* __nb, const char* __ne) const - { - result __r = ok; - mbstate_t __mb; - while (__nb < __ne && __r != error) - { - const int __sz = 32; - char32_t __buf[__sz]; - char32_t* __bn; - const char* __nn = __nb; - __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, - __buf, __buf+__sz, __bn); - if (__r == codecvt_base::error || __nn == __nb) - __throw_runtime_error("locale not supported"); - for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) - *__s = (wchar_t)*__p; - __nb = __nn; - } - return __s; - } -}; - -// template class numpunct - -template class _LIBCPP_TEMPLATE_VIS numpunct; - -template <> -class _LIBCPP_TYPE_VIS numpunct - : public locale::facet -{ -public: - typedef char char_type; - typedef basic_string string_type; - - explicit numpunct(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} - _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} - _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} - _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} - _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} - - static locale::id id; - -protected: - ~numpunct(); - virtual char_type do_decimal_point() const; - virtual char_type do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_truename() const; - virtual string_type do_falsename() const; - - char_type __decimal_point_; - char_type __thousands_sep_; - string __grouping_; -}; - -template <> -class _LIBCPP_TYPE_VIS numpunct - : public locale::facet -{ -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit numpunct(size_t __refs = 0); - - _LIBCPP_INLINE_VISIBILITY char_type decimal_point() const {return do_decimal_point();} - _LIBCPP_INLINE_VISIBILITY char_type thousands_sep() const {return do_thousands_sep();} - _LIBCPP_INLINE_VISIBILITY string grouping() const {return do_grouping();} - _LIBCPP_INLINE_VISIBILITY string_type truename() const {return do_truename();} - _LIBCPP_INLINE_VISIBILITY string_type falsename() const {return do_falsename();} - - static locale::id id; - -protected: - ~numpunct(); - virtual char_type do_decimal_point() const; - virtual char_type do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_truename() const; - virtual string_type do_falsename() const; - - char_type __decimal_point_; - char_type __thousands_sep_; - string __grouping_; -}; - -// template class numpunct_byname - -template class _LIBCPP_TEMPLATE_VIS numpunct_byname; - -template <> -class _LIBCPP_TYPE_VIS numpunct_byname -: public numpunct -{ -public: - typedef char char_type; - typedef basic_string string_type; - - explicit numpunct_byname(const char* __nm, size_t __refs = 0); - explicit numpunct_byname(const string& __nm, size_t __refs = 0); - -protected: - ~numpunct_byname(); - -private: - void __init(const char*); -}; - -template <> -class _LIBCPP_TYPE_VIS numpunct_byname -: public numpunct -{ -public: - typedef wchar_t char_type; - typedef basic_string string_type; - - explicit numpunct_byname(const char* __nm, size_t __refs = 0); - explicit numpunct_byname(const string& __nm, size_t __refs = 0); - -protected: - ~numpunct_byname(); - -private: - void __init(const char*); -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___LOCALE diff --git a/external/include/c++/v1/__mutex_base b/external/include/c++/v1/__mutex_base deleted file mode 100644 index 4659ca9..0000000 --- a/external/include/c++/v1/__mutex_base +++ /dev/null @@ -1,440 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___MUTEX_BASE -#define _LIBCPP___MUTEX_BASE - -#include <__config> -#include -#include -#include <__threading_support> - - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -#ifndef _LIBCPP_HAS_NO_THREADS - -#ifndef _LIBCPP_THREAD_SAFETY_ANNOTATION -# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) -# else -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) -# endif -#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION - -class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex -{ -#ifndef _LIBCPP_CXX03_LANG - __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER; -#else - __libcpp_mutex_t __m_; -#endif - -public: - _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_CXX03_LANG - constexpr mutex() = default; -#else - mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} -#endif - ~mutex(); - -private: - mutex(const mutex&);// = delete; - mutex& operator=(const mutex&);// = delete; - -public: - void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability()); - bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true)); - void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()); - - typedef __libcpp_mutex_t* native_handle_type; - _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;} -}; - -static_assert(is_nothrow_default_constructible::value, - "the default constructor for std::mutex must be nothrow"); - -struct _LIBCPP_TYPE_VIS defer_lock_t {}; -struct _LIBCPP_TYPE_VIS try_to_lock_t {}; -struct _LIBCPP_TYPE_VIS adopt_lock_t {}; - -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) - -extern const defer_lock_t defer_lock; -extern const try_to_lock_t try_to_lock; -extern const adopt_lock_t adopt_lock; - -#else - -/* _LIBCPP_INLINE_VAR */ constexpr defer_lock_t defer_lock = defer_lock_t(); -/* _LIBCPP_INLINE_VAR */ constexpr try_to_lock_t try_to_lock = try_to_lock_t(); -/* _LIBCPP_INLINE_VAR */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); - -#endif - -template -class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) -lock_guard -{ -public: - typedef _Mutex mutex_type; - -private: - mutex_type& __m_; -public: - - _LIBCPP_INLINE_VISIBILITY - explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) - : __m_(__m) {__m_.lock();} - _LIBCPP_INLINE_VISIBILITY - lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) - : __m_(__m) {} - _LIBCPP_INLINE_VISIBILITY - ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();} - -private: - lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE; - lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE; -}; - -template -class _LIBCPP_TEMPLATE_VIS unique_lock -{ -public: - typedef _Mutex mutex_type; - -private: - mutex_type* __m_; - bool __owns_; - -public: - _LIBCPP_INLINE_VISIBILITY - unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} - _LIBCPP_INLINE_VISIBILITY - explicit unique_lock(mutex_type& __m) - : __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT - : __m_(_VSTD::addressof(__m)), __owns_(false) {} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, try_to_lock_t) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {} - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, adopt_lock_t) - : __m_(_VSTD::addressof(__m)), __owns_(true) {} - template - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} - template - _LIBCPP_INLINE_VISIBILITY - unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) - : __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} - _LIBCPP_INLINE_VISIBILITY - ~unique_lock() - { - if (__owns_) - __m_->unlock(); - } - -private: - unique_lock(unique_lock const&); // = delete; - unique_lock& operator=(unique_lock const&); // = delete; - -public: -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - unique_lock(unique_lock&& __u) _NOEXCEPT - : __m_(__u.__m_), __owns_(__u.__owns_) - {__u.__m_ = nullptr; __u.__owns_ = false;} - _LIBCPP_INLINE_VISIBILITY - unique_lock& operator=(unique_lock&& __u) _NOEXCEPT - { - if (__owns_) - __m_->unlock(); - __m_ = __u.__m_; - __owns_ = __u.__owns_; - __u.__m_ = nullptr; - __u.__owns_ = false; - return *this; - } - -#endif // _LIBCPP_CXX03_LANG - - void lock(); - bool try_lock(); - - template - bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); - template - bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); - - void unlock(); - - _LIBCPP_INLINE_VISIBILITY - void swap(unique_lock& __u) _NOEXCEPT - { - _VSTD::swap(__m_, __u.__m_); - _VSTD::swap(__owns_, __u.__owns_); - } - _LIBCPP_INLINE_VISIBILITY - mutex_type* release() _NOEXCEPT - { - mutex_type* __m = __m_; - __m_ = nullptr; - __owns_ = false; - return __m; - } - - _LIBCPP_INLINE_VISIBILITY - bool owns_lock() const _NOEXCEPT {return __owns_;} - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_EXPLICIT - operator bool () const _NOEXCEPT {return __owns_;} - _LIBCPP_INLINE_VISIBILITY - mutex_type* mutex() const _NOEXCEPT {return __m_;} -}; - -template -void -unique_lock<_Mutex>::lock() -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::lock: already locked"); - __m_->lock(); - __owns_ = true; -} - -template -bool -unique_lock<_Mutex>::try_lock() -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked"); - __owns_ = __m_->try_lock(); - return __owns_; -} - -template -template -bool -unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked"); - __owns_ = __m_->try_lock_for(__d); - return __owns_; -} - -template -template -bool -unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) -{ - if (__m_ == nullptr) - __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); - if (__owns_) - __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked"); - __owns_ = __m_->try_lock_until(__t); - return __owns_; -} - -template -void -unique_lock<_Mutex>::unlock() -{ - if (!__owns_) - __throw_system_error(EPERM, "unique_lock::unlock: not locked"); - __m_->unlock(); - __owns_ = false; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) _NOEXCEPT - {__x.swap(__y);} - -//enum class cv_status -_LIBCPP_DECLARE_STRONG_ENUM(cv_status) -{ - no_timeout, - timeout -}; -_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status) - -class _LIBCPP_TYPE_VIS condition_variable -{ -#ifndef _LIBCPP_CXX03_LANG - __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER; -#else - __libcpp_condvar_t __cv_; -#endif - -public: - _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_CXX03_LANG - constexpr condition_variable() _NOEXCEPT = default; -#else - condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} -#endif - ~condition_variable(); - -private: - condition_variable(const condition_variable&); // = delete; - condition_variable& operator=(const condition_variable&); // = delete; - -public: - void notify_one() _NOEXCEPT; - void notify_all() _NOEXCEPT; - - void wait(unique_lock& __lk) _NOEXCEPT; - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - void wait(unique_lock& __lk, _Predicate __pred); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - cv_status - wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - bool - wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t, - _Predicate __pred); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - cv_status - wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d); - - template - bool - _LIBCPP_INLINE_VISIBILITY - wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d, - _Predicate __pred); - - typedef __libcpp_condvar_t* native_handle_type; - _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__cv_;} - -private: - void __do_timed_wait(unique_lock& __lk, - chrono::time_point) _NOEXCEPT; -}; -#endif // !_LIBCPP_HAS_NO_THREADS - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - chrono::__is_duration<_To>::value, - _To ->::type -__ceil(chrono::duration<_Rep, _Period> __d) -{ - using namespace chrono; - _To __r = duration_cast<_To>(__d); - if (__r < __d) - ++__r; - return __r; -} - -#ifndef _LIBCPP_HAS_NO_THREADS -template -void -condition_variable::wait(unique_lock& __lk, _Predicate __pred) -{ - while (!__pred()) - wait(__lk); -} - -template -cv_status -condition_variable::wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t) -{ - using namespace chrono; - wait_for(__lk, __t - _Clock::now()); - return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout; -} - -template -bool -condition_variable::wait_until(unique_lock& __lk, - const chrono::time_point<_Clock, _Duration>& __t, - _Predicate __pred) -{ - while (!__pred()) - { - if (wait_until(__lk, __t) == cv_status::timeout) - return __pred(); - } - return true; -} - -template -cv_status -condition_variable::wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d) -{ - using namespace chrono; - if (__d <= __d.zero()) - return cv_status::timeout; - typedef time_point > __sys_tpf; - typedef time_point __sys_tpi; - __sys_tpf _Max = __sys_tpi::max(); - steady_clock::time_point __c_now = steady_clock::now(); - system_clock::time_point __s_now = system_clock::now(); - if (_Max - __d > __s_now) - __do_timed_wait(__lk, __s_now + __ceil(__d)); - else - __do_timed_wait(__lk, __sys_tpi::max()); - return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : - cv_status::timeout; -} - -template -inline -bool -condition_variable::wait_for(unique_lock& __lk, - const chrono::duration<_Rep, _Period>& __d, - _Predicate __pred) -{ - return wait_until(__lk, chrono::steady_clock::now() + __d, - _VSTD::move(__pred)); -} - -#endif // !_LIBCPP_HAS_NO_THREADS - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___MUTEX_BASE diff --git a/external/include/c++/v1/__node_handle b/external/include/c++/v1/__node_handle deleted file mode 100644 index 567f8b0..0000000 --- a/external/include/c++/v1/__node_handle +++ /dev/null @@ -1,213 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___NODE_HANDLE -#define _LIBCPP___NODE_HANDLE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 14 - -// FIXME: Uncomment this when we support the 'merge' functionality. -// #define __cpp_lib_node_extract 201606L - -// Specialized in __tree & __hash_table for their _NodeType. -template -struct __generic_container_node_destructor; - -template class _MapOrSetSpecifics> -class _LIBCPP_TEMPLATE_VIS __basic_node_handle - : public _MapOrSetSpecifics< - _NodeType, - __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> -{ - template - friend class __tree; - template - friend class __hash_table; - friend struct _MapOrSetSpecifics< - _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>>; - - typedef allocator_traits<_Alloc> __alloc_traits; - typedef typename __rebind_pointer::type - __node_pointer_type; - -public: - typedef _Alloc allocator_type; - -private: - __node_pointer_type __ptr_ = nullptr; - optional __alloc_; - - _LIBCPP_INLINE_VISIBILITY - void __release() - { - __ptr_ = nullptr; - __alloc_ = _VSTD::nullopt; - } - - _LIBCPP_INLINE_VISIBILITY - void __destroy_node_pointer() - { - if (__ptr_ != nullptr) - { - typedef typename __allocator_traits_rebind< - allocator_type, _NodeType>::type __node_alloc_type; - __node_alloc_type __alloc(*__alloc_); - __generic_container_node_destructor<_NodeType, __node_alloc_type>( - __alloc, true)(__ptr_); - __ptr_ = nullptr; - } - } - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle(__node_pointer_type __ptr, - allocator_type const& __alloc) - : __ptr_(__ptr), __alloc_(__alloc) - { - } - -public: - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle() = default; - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle(__basic_node_handle&& __other) noexcept - : __ptr_(__other.__ptr_), - __alloc_(_VSTD::move(__other.__alloc_)) - { - __other.__ptr_ = nullptr; - __other.__alloc_ = _VSTD::nullopt; - } - - _LIBCPP_INLINE_VISIBILITY - __basic_node_handle& operator=(__basic_node_handle&& __other) - { - _LIBCPP_ASSERT( - __alloc_ == _VSTD::nullopt || - __alloc_traits::propagate_on_container_move_assignment::value || - __alloc_ == __other.__alloc_, - "node_type with incompatible allocator passed to " - "node_type::operator=(node_type&&)"); - - __destroy_node_pointer(); - __ptr_ = __other.__ptr_; - - if (__alloc_traits::propagate_on_container_move_assignment::value || - __alloc_ == _VSTD::nullopt) - __alloc_ = _VSTD::move(__other.__alloc_); - - __other.__ptr_ = nullptr; - __other.__alloc_ = _VSTD::nullopt; - - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - allocator_type get_allocator() const { return *__alloc_; } - - _LIBCPP_INLINE_VISIBILITY - explicit operator bool() const { return __ptr_ != nullptr; } - - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY - bool empty() const { return __ptr_ == nullptr; } - - _LIBCPP_INLINE_VISIBILITY - void swap(__basic_node_handle& __other) noexcept( - __alloc_traits::propagate_on_container_swap::value || - __alloc_traits::is_always_equal::value) - { - using _VSTD::swap; - swap(__ptr_, __other.__ptr_); - if (__alloc_traits::propagate_on_container_swap::value || - __alloc_ == _VSTD::nullopt || __other.__alloc_ == _VSTD::nullopt) - swap(__alloc_, __other.__alloc_); - } - - _LIBCPP_INLINE_VISIBILITY - friend void swap(__basic_node_handle& __a, __basic_node_handle& __b) - noexcept(noexcept(__a.swap(__b))) { __a.swap(__b); } - - _LIBCPP_INLINE_VISIBILITY - ~__basic_node_handle() - { - __destroy_node_pointer(); - } -}; - -template -struct __set_node_handle_specifics -{ - typedef typename _NodeType::__node_value_type value_type; - - _LIBCPP_INLINE_VISIBILITY - value_type& value() const - { - return static_cast<_Derived const*>(this)->__ptr_->__value_; - } -}; - -template -struct __map_node_handle_specifics -{ - typedef typename _NodeType::__node_value_type::key_type key_type; - typedef typename _NodeType::__node_value_type::mapped_type mapped_type; - - _LIBCPP_INLINE_VISIBILITY - key_type& key() const - { - return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().first; - } - - _LIBCPP_INLINE_VISIBILITY - mapped_type& mapped() const - { - return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().second; - } -}; - -template -using __set_node_handle = - __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>; - -template -using __map_node_handle = - __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; - -template -_LIBCPP_TEMPLATE_VIS -struct __insert_return_type -{ - _Iterator position; - bool inserted; - _NodeType node; -}; - -#endif // _LIBCPP_STD_VER > 14 - -_LIBCPP_END_NAMESPACE_STD -_LIBCPP_POP_MACROS - -#endif diff --git a/external/include/c++/v1/__nullptr b/external/include/c++/v1/__nullptr deleted file mode 100644 index aa3b4d2..0000000 --- a/external/include/c++/v1/__nullptr +++ /dev/null @@ -1,62 +0,0 @@ -// -*- C++ -*- -//===--------------------------- __nullptr --------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_NULLPTR -#define _LIBCPP_NULLPTR - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#ifdef _LIBCPP_HAS_NO_NULLPTR - -_LIBCPP_BEGIN_NAMESPACE_STD - -struct _LIBCPP_TEMPLATE_VIS nullptr_t -{ - void* __lx; - - struct __nat {int __for_bool_;}; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - operator _Tp* () const {return 0;} - - template - _LIBCPP_INLINE_VISIBILITY - operator _Tp _Up::* () const {return 0;} - - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} -}; - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} - -#define nullptr _VSTD::__get_nullptr_t() - -_LIBCPP_END_NAMESPACE_STD - -#else // _LIBCPP_HAS_NO_NULLPTR - -namespace std -{ - typedef decltype(nullptr) nullptr_t; -} - -#endif // _LIBCPP_HAS_NO_NULLPTR - -#endif // _LIBCPP_NULLPTR diff --git a/external/include/c++/v1/__split_buffer b/external/include/c++/v1/__split_buffer deleted file mode 100644 index 1daa4e5..0000000 --- a/external/include/c++/v1/__split_buffer +++ /dev/null @@ -1,637 +0,0 @@ -// -*- C++ -*- -#ifndef _LIBCPP_SPLIT_BUFFER -#define _LIBCPP_SPLIT_BUFFER - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template -class __split_buffer_common -{ -protected: - void __throw_length_error() const; - void __throw_out_of_range() const; -}; - -template > -struct __split_buffer - : private __split_buffer_common -{ -private: - __split_buffer(const __split_buffer&); - __split_buffer& operator=(const __split_buffer&); -public: - typedef _Tp value_type; - typedef _Allocator allocator_type; - typedef typename remove_reference::type __alloc_rr; - typedef allocator_traits<__alloc_rr> __alloc_traits; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_type; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; - typedef pointer iterator; - typedef const_pointer const_iterator; - - pointer __first_; - pointer __begin_; - pointer __end_; - __compressed_pair __end_cap_; - - typedef typename add_lvalue_reference::type __alloc_ref; - typedef typename add_lvalue_reference::type __alloc_const_ref; - - _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} - - _LIBCPP_INLINE_VISIBILITY - __split_buffer() - _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY - explicit __split_buffer(__alloc_rr& __a); - _LIBCPP_INLINE_VISIBILITY - explicit __split_buffer(const __alloc_rr& __a); - __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); - ~__split_buffer(); - -#ifndef _LIBCPP_CXX03_LANG - __split_buffer(__split_buffer&& __c) - _NOEXCEPT_(is_nothrow_move_constructible::value); - __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); - __split_buffer& operator=(__split_buffer&& __c) - _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) || - !__alloc_traits::propagate_on_container_move_assignment::value); -#endif // _LIBCPP_CXX03_LANG - - _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} - - _LIBCPP_INLINE_VISIBILITY - void clear() _NOEXCEPT - {__destruct_at_end(__begin_);} - _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast(__end_ - __begin_);} - _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} - _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast(__end_cap() - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast(__begin_ - __first_);} - _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast(__end_cap() - __end_);} - - _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} - _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} - _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} - - void reserve(size_type __n); - void shrink_to_fit() _NOEXCEPT; - void push_front(const_reference __x); - _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); -#ifndef _LIBCPP_CXX03_LANG - void push_front(value_type&& __x); - void push_back(value_type&& __x); - template - void emplace_back(_Args&&... __args); -#endif // !defined(_LIBCPP_CXX03_LANG) - - _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} - _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} - - void __construct_at_end(size_type __n); - void __construct_at_end(size_type __n, const_reference __x); - template - typename enable_if - < - __is_input_iterator<_InputIter>::value && - !__is_forward_iterator<_InputIter>::value, - void - >::type - __construct_at_end(_InputIter __first, _InputIter __last); - template - typename enable_if - < - __is_forward_iterator<_ForwardIterator>::value, - void - >::type - __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); - - _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) - {__destruct_at_begin(__new_begin, is_trivially_destructible());} - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_begin(pointer __new_begin, false_type); - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_begin(pointer __new_begin, true_type); - - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last) _NOEXCEPT - {__destruct_at_end(__new_last, false_type());} - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; - - void swap(__split_buffer& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable<__alloc_rr>::value); - - bool __invariants() const; - -private: - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__split_buffer& __c, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value) - { - __alloc() = _VSTD::move(__c.__alloc()); - } - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT - {} -}; - -template -bool -__split_buffer<_Tp, _Allocator>::__invariants() const -{ - if (__first_ == nullptr) - { - if (__begin_ != nullptr) - return false; - if (__end_ != nullptr) - return false; - if (__end_cap() != nullptr) - return false; - } - else - { - if (__begin_ < __first_) - return false; - if (__end_ < __begin_) - return false; - if (__end_cap() < __end_) - return false; - } - return true; -} - -// Default constructs __n objects starting at __end_ -// throws if construction throws -// Precondition: __n > 0 -// Precondition: size() + __n <= capacity() -// Postcondition: size() == size() + __n -template -void -__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) -{ - __alloc_rr& __a = this->__alloc(); - do - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_)); - ++this->__end_; - --__n; - } while (__n > 0); -} - -// Copy constructs __n objects starting at __end_ from __x -// throws if construction throws -// Precondition: __n > 0 -// Precondition: size() + __n <= capacity() -// Postcondition: size() == old size() + __n -// Postcondition: [i] == __x for all i in [size() - __n, __n) -template -void -__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) -{ - __alloc_rr& __a = this->__alloc(); - do - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), __x); - ++this->__end_; - --__n; - } while (__n > 0); -} - -template -template -typename enable_if -< - __is_input_iterator<_InputIter>::value && - !__is_forward_iterator<_InputIter>::value, - void ->::type -__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) -{ - __alloc_rr& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - if (__end_ == __end_cap()) - { - size_type __old_cap = __end_cap() - __first_; - size_type __new_cap = _VSTD::max(2 * __old_cap, 8); - __split_buffer __buf(__new_cap, 0, __a); - for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_) - __alloc_traits::construct(__buf.__alloc(), - _VSTD::__to_raw_pointer(__buf.__end_), _VSTD::move(*__p)); - swap(__buf); - } - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - ++this->__end_; - } -} - -template -template -typename enable_if -< - __is_forward_iterator<_ForwardIterator>::value, - void ->::type -__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) -{ - __alloc_rr& __a = this->__alloc(); - for (; __first != __last; ++__first) - { - __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); - ++this->__end_; - } -} - -template -inline -void -__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) -{ - while (__begin_ != __new_begin) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(__begin_++)); -} - -template -inline -void -__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) -{ - __begin_ = __new_begin; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT -{ - while (__new_last != __end_) - __alloc_traits::destroy(__alloc(), __to_raw_pointer(--__end_)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT -{ - __end_ = __new_last; -} - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) - : __end_cap_(nullptr, __a) -{ - __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr; - __begin_ = __end_ = __first_ + __start; - __end_cap() = __first_ + __cap; -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) -{ -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) -{ -} - -template -inline -__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) -{ -} - -template -__split_buffer<_Tp, _Allocator>::~__split_buffer() -{ - clear(); - if (__first_) - __alloc_traits::deallocate(__alloc(), __first_, capacity()); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) - _NOEXCEPT_(is_nothrow_move_constructible::value) - : __first_(_VSTD::move(__c.__first_)), - __begin_(_VSTD::move(__c.__begin_)), - __end_(_VSTD::move(__c.__end_)), - __end_cap_(_VSTD::move(__c.__end_cap_)) -{ - __c.__first_ = nullptr; - __c.__begin_ = nullptr; - __c.__end_ = nullptr; - __c.__end_cap() = nullptr; -} - -template -__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) - : __end_cap_(__second_tag(), __a) -{ - if (__a == __c.__alloc()) - { - __first_ = __c.__first_; - __begin_ = __c.__begin_; - __end_ = __c.__end_; - __end_cap() = __c.__end_cap(); - __c.__first_ = nullptr; - __c.__begin_ = nullptr; - __c.__end_ = nullptr; - __c.__end_cap() = nullptr; - } - else - { - size_type __cap = __c.size(); - __first_ = __alloc_traits::allocate(__alloc(), __cap); - __begin_ = __end_ = __first_; - __end_cap() = __first_ + __cap; - typedef move_iterator _Ip; - __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); - } -} - -template -__split_buffer<_Tp, _Allocator>& -__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) - _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) || - !__alloc_traits::propagate_on_container_move_assignment::value) -{ - clear(); - shrink_to_fit(); - __first_ = __c.__first_; - __begin_ = __c.__begin_; - __end_ = __c.__end_; - __end_cap() = __c.__end_cap(); - __move_assign_alloc(__c, - integral_constant()); - __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| - __is_nothrow_swappable<__alloc_rr>::value) -{ - _VSTD::swap(__first_, __x.__first_); - _VSTD::swap(__begin_, __x.__begin_); - _VSTD::swap(__end_, __x.__end_); - _VSTD::swap(__end_cap(), __x.__end_cap()); - __swap_allocator(__alloc(), __x.__alloc()); -} - -template -void -__split_buffer<_Tp, _Allocator>::reserve(size_type __n) -{ - if (__n < capacity()) - { - __split_buffer __t(__n, 0, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } -} - -template -void -__split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT -{ - if (capacity() > size()) - { -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - __split_buffer __t(size(), 0, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - __t.__end_ = __t.__begin_ + (__end_ - __begin_); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_NO_EXCEPTIONS - } -} - -template -void -__split_buffer<_Tp, _Allocator>::push_front(const_reference __x) -{ - if (__begin_ == __first_) - { - if (__end_ < __end_cap()) - { - difference_type __d = __end_cap() - __end_; - __d = (__d + 1) / 2; - __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); - __end_ += __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, (__c + 3) / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), __x); - --__begin_; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) -{ - if (__begin_ == __first_) - { - if (__end_ < __end_cap()) - { - difference_type __d = __end_cap() - __end_; - __d = (__d + 1) / 2; - __begin_ = _VSTD::move_backward(__begin_, __end_, __end_ + __d); - __end_ += __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, (__c + 3) / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__begin_-1), - _VSTD::move(__x)); - --__begin_; -} - -#endif // _LIBCPP_CXX03_LANG - -template -inline _LIBCPP_INLINE_VISIBILITY -void -__split_buffer<_Tp, _Allocator>::push_back(const_reference __x) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), __x); - ++__end_; -} - -#ifndef _LIBCPP_CXX03_LANG - -template -void -__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), - _VSTD::move(__x)); - ++__end_; -} - -template -template -void -__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) -{ - if (__end_ == __end_cap()) - { - if (__begin_ > __first_) - { - difference_type __d = __begin_ - __first_; - __d = (__d + 1) / 2; - __end_ = _VSTD::move(__begin_, __end_, __begin_ - __d); - __begin_ -= __d; - } - else - { - size_type __c = max(2 * static_cast(__end_cap() - __first_), 1); - __split_buffer __t(__c, __c / 4, __alloc()); - __t.__construct_at_end(move_iterator(__begin_), - move_iterator(__end_)); - _VSTD::swap(__first_, __t.__first_); - _VSTD::swap(__begin_, __t.__begin_); - _VSTD::swap(__end_, __t.__end_); - _VSTD::swap(__end_cap(), __t.__end_cap()); - } - } - __alloc_traits::construct(__alloc(), _VSTD::__to_raw_pointer(__end_), - _VSTD::forward<_Args>(__args)...); - ++__end_; -} - -#endif // _LIBCPP_CXX03_LANG - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP_SPLIT_BUFFER diff --git a/external/include/c++/v1/__sso_allocator b/external/include/c++/v1/__sso_allocator deleted file mode 100644 index 4002736..0000000 --- a/external/include/c++/v1/__sso_allocator +++ /dev/null @@ -1,77 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___SSO_ALLOCATOR -#define _LIBCPP___SSO_ALLOCATOR - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class _LIBCPP_HIDDEN __sso_allocator; - -template -class _LIBCPP_HIDDEN __sso_allocator -{ -public: - typedef const void* const_pointer; - typedef void value_type; -}; - -template -class _LIBCPP_HIDDEN __sso_allocator -{ - typename aligned_storage::type buf_; - bool __allocated_; -public: - typedef size_t size_type; - typedef _Tp* pointer; - typedef _Tp value_type; - - _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} - _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} - template _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() - : __allocated_(false) {} -private: - __sso_allocator& operator=(const __sso_allocator&); -public: - _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator::const_pointer = 0) - { - if (!__allocated_ && __n <= _Np) - { - __allocated_ = true; - return (pointer)&buf_; - } - return static_cast(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), __alignof(_Tp))); - } - _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) - { - if (__p == (pointer)&buf_) - __allocated_ = false; - else - _VSTD::__libcpp_deallocate(__p, __alignof(_Tp)); - } - _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} - - _LIBCPP_INLINE_VISIBILITY - bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;} - _LIBCPP_INLINE_VISIBILITY - bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;} -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___SSO_ALLOCATOR diff --git a/external/include/c++/v1/__std_stream b/external/include/c++/v1/__std_stream deleted file mode 100644 index db90795..0000000 --- a/external/include/c++/v1/__std_stream +++ /dev/null @@ -1,362 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___STD_STREAM -#define _LIBCPP___STD_STREAM - -#include <__config> -#include -#include -#include <__locale> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -static const int __limit = 8; - -// __stdinbuf - -template -class _LIBCPP_HIDDEN __stdinbuf - : public basic_streambuf<_CharT, char_traits<_CharT> > -{ -public: - typedef _CharT char_type; - typedef char_traits traits_type; - typedef typename traits_type::int_type int_type; - typedef typename traits_type::pos_type pos_type; - typedef typename traits_type::off_type off_type; - typedef typename traits_type::state_type state_type; - - __stdinbuf(FILE* __fp, state_type* __st); - -protected: - virtual int_type underflow(); - virtual int_type uflow(); - virtual int_type pbackfail(int_type __c = traits_type::eof()); - virtual void imbue(const locale& __loc); - -private: - - FILE* __file_; - const codecvt* __cv_; - state_type* __st_; - int __encoding_; - int_type __last_consumed_; - bool __last_consumed_is_next_; - bool __always_noconv_; - - __stdinbuf(const __stdinbuf&); - __stdinbuf& operator=(const __stdinbuf&); - - int_type __getchar(bool __consume); -}; - -template -__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st) - : __file_(__fp), - __st_(__st), - __last_consumed_(traits_type::eof()), - __last_consumed_is_next_(false) -{ - imbue(this->getloc()); -} - -template -void -__stdinbuf<_CharT>::imbue(const locale& __loc) -{ - __cv_ = &use_facet >(__loc); - __encoding_ = __cv_->encoding(); - __always_noconv_ = __cv_->always_noconv(); - if (__encoding_ > __limit) - __throw_runtime_error("unsupported locale for standard input"); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::underflow() -{ - return __getchar(false); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::uflow() -{ - return __getchar(true); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::__getchar(bool __consume) -{ - if (__last_consumed_is_next_) - { - int_type __result = __last_consumed_; - if (__consume) - { - __last_consumed_ = traits_type::eof(); - __last_consumed_is_next_ = false; - } - return __result; - } - char __extbuf[__limit]; - int __nread = _VSTD::max(1, __encoding_); - for (int __i = 0; __i < __nread; ++__i) - { - int __c = getc(__file_); - if (__c == EOF) - return traits_type::eof(); - __extbuf[__i] = static_cast(__c); - } - char_type __1buf; - if (__always_noconv_) - __1buf = static_cast(__extbuf[0]); - else - { - const char* __enxt; - char_type* __inxt; - codecvt_base::result __r; - do - { - state_type __sv_st = *__st_; - __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt, - &__1buf, &__1buf + 1, __inxt); - switch (__r) - { - case _VSTD::codecvt_base::ok: - break; - case codecvt_base::partial: - *__st_ = __sv_st; - if (__nread == sizeof(__extbuf)) - return traits_type::eof(); - { - int __c = getc(__file_); - if (__c == EOF) - return traits_type::eof(); - __extbuf[__nread] = static_cast(__c); - } - ++__nread; - break; - case codecvt_base::error: - return traits_type::eof(); - case _VSTD::codecvt_base::noconv: - __1buf = static_cast(__extbuf[0]); - break; - } - } while (__r == _VSTD::codecvt_base::partial); - } - if (!__consume) - { - for (int __i = __nread; __i > 0;) - { - if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF) - return traits_type::eof(); - } - } - else - __last_consumed_ = traits_type::to_int_type(__1buf); - return traits_type::to_int_type(__1buf); -} - -template -typename __stdinbuf<_CharT>::int_type -__stdinbuf<_CharT>::pbackfail(int_type __c) -{ - if (traits_type::eq_int_type(__c, traits_type::eof())) - { - if (!__last_consumed_is_next_) - { - __c = __last_consumed_; - __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_, - traits_type::eof()); - } - return __c; - } - if (__last_consumed_is_next_) - { - char __extbuf[__limit]; - char* __enxt; - const char_type __ci = traits_type::to_char_type(__last_consumed_); - const char_type* __inxt; - switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt, - __extbuf, __extbuf + sizeof(__extbuf), __enxt)) - { - case _VSTD::codecvt_base::ok: - break; - case _VSTD::codecvt_base::noconv: - __extbuf[0] = static_cast(__last_consumed_); - __enxt = __extbuf + 1; - break; - case codecvt_base::partial: - case codecvt_base::error: - return traits_type::eof(); - } - while (__enxt > __extbuf) - if (ungetc(*--__enxt, __file_) == EOF) - return traits_type::eof(); - } - __last_consumed_ = __c; - __last_consumed_is_next_ = true; - return __c; -} - -// __stdoutbuf - -template -class _LIBCPP_HIDDEN __stdoutbuf - : public basic_streambuf<_CharT, char_traits<_CharT> > -{ -public: - typedef _CharT char_type; - typedef char_traits traits_type; - typedef typename traits_type::int_type int_type; - typedef typename traits_type::pos_type pos_type; - typedef typename traits_type::off_type off_type; - typedef typename traits_type::state_type state_type; - - __stdoutbuf(FILE* __fp, state_type* __st); - -protected: - virtual int_type overflow (int_type __c = traits_type::eof()); - virtual streamsize xsputn(const char_type* __s, streamsize __n); - virtual int sync(); - virtual void imbue(const locale& __loc); - -private: - FILE* __file_; - const codecvt* __cv_; - state_type* __st_; - bool __always_noconv_; - - __stdoutbuf(const __stdoutbuf&); - __stdoutbuf& operator=(const __stdoutbuf&); -}; - -template -__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st) - : __file_(__fp), - __cv_(&use_facet >(this->getloc())), - __st_(__st), - __always_noconv_(__cv_->always_noconv()) -{ -} - -template -typename __stdoutbuf<_CharT>::int_type -__stdoutbuf<_CharT>::overflow(int_type __c) -{ - char __extbuf[__limit]; - char_type __1buf; - if (!traits_type::eq_int_type(__c, traits_type::eof())) - { - __1buf = traits_type::to_char_type(__c); - if (__always_noconv_) - { - if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1) - return traits_type::eof(); - } - else - { - char* __extbe = __extbuf; - codecvt_base::result __r; - char_type* pbase = &__1buf; - char_type* pptr = pbase + 1; - do - { - const char_type* __e; - __r = __cv_->out(*__st_, pbase, pptr, __e, - __extbuf, - __extbuf + sizeof(__extbuf), - __extbe); - if (__e == pbase) - return traits_type::eof(); - if (__r == codecvt_base::noconv) - { - if (fwrite(pbase, 1, 1, __file_) != 1) - return traits_type::eof(); - } - else if (__r == codecvt_base::ok || __r == codecvt_base::partial) - { - size_t __nmemb = static_cast(__extbe - __extbuf); - if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb) - return traits_type::eof(); - if (__r == codecvt_base::partial) - { - pbase = const_cast(__e); - } - } - else - return traits_type::eof(); - } while (__r == codecvt_base::partial); - } - } - return traits_type::not_eof(__c); -} - -template -streamsize -__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n) -{ - if (__always_noconv_) - return fwrite(__s, sizeof(char_type), __n, __file_); - streamsize __i = 0; - for (; __i < __n; ++__i, ++__s) - if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof()) - break; - return __i; -} - -template -int -__stdoutbuf<_CharT>::sync() -{ - char __extbuf[__limit]; - codecvt_base::result __r; - do - { - char* __extbe; - __r = __cv_->unshift(*__st_, __extbuf, - __extbuf + sizeof(__extbuf), - __extbe); - size_t __nmemb = static_cast(__extbe - __extbuf); - if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb) - return -1; - } while (__r == codecvt_base::partial); - if (__r == codecvt_base::error) - return -1; - if (fflush(__file_)) - return -1; - return 0; -} - -template -void -__stdoutbuf<_CharT>::imbue(const locale& __loc) -{ - sync(); - __cv_ = &use_facet >(__loc); - __always_noconv_ = __cv_->always_noconv(); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___STD_STREAM diff --git a/external/include/c++/v1/__string b/external/include/c++/v1/__string deleted file mode 100644 index 44c5598..0000000 --- a/external/include/c++/v1/__string +++ /dev/null @@ -1,877 +0,0 @@ -// -*- C++ -*- -//===-------------------------- __string ----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___STRING -#define _LIBCPP___STRING - -/* - string synopsis - -namespace std -{ - -template -struct char_traits -{ - typedef charT char_type; - typedef ... int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static constexpr void assign(char_type& c1, const char_type& c2) noexcept; - static constexpr bool eq(char_type c1, char_type c2) noexcept; - static constexpr bool lt(char_type c1, char_type c2) noexcept; - - static constexpr int compare(const char_type* s1, const char_type* s2, size_t n); - static constexpr size_t length(const char_type* s); - static constexpr const char_type* - find(const char_type* s, size_t n, const char_type& a); - static char_type* move(char_type* s1, const char_type* s2, size_t n); - static char_type* copy(char_type* s1, const char_type* s2, size_t n); - static char_type* assign(char_type* s, size_t n, char_type a); - - static constexpr int_type not_eof(int_type c) noexcept; - static constexpr char_type to_char_type(int_type c) noexcept; - static constexpr int_type to_int_type(char_type c) noexcept; - static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; - static constexpr int_type eof() noexcept; -}; - -template <> struct char_traits; -template <> struct char_traits; - -} // std - -*/ - -#include <__config> -#include // for search and min -#include // For EOF. -#include // for __murmur2_or_cityhash - -#include <__debug> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -// char_traits - -template -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef _CharT char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14 - assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s); - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a); - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a); - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(EOF);} -}; - -template -_LIBCPP_CONSTEXPR_AFTER_CXX14 int -char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -template -inline -_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t -char_traits<_CharT>::length(const char_type* __s) -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -template -inline -_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT* -char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -template -_CharT* -char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -template -inline -_CharT* -char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -template -inline -_CharT* -char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -// char_traits - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return (unsigned char)__c1 < (unsigned char)__c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 - length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} - static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); - } - static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type((unsigned char)__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(EOF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) - return 0; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_memcmp(__s1, __s2, __n); -#elif _LIBCPP_STD_VER <= 14 - return memcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - if (__n == 0) - return nullptr; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_char_memchr(__s, to_int_type(__a), __n); -#elif _LIBCPP_STD_VER <= 14 - return (const char_type*) memchr(__s, to_int_type(__a), __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -// char_traits - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef wchar_t char_type; - typedef wint_t int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} - static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n); - } - static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);} - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(WEOF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) - return 0; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wmemcmp(__s1, __s2, __n); -#elif _LIBCPP_STD_VER <= 14 - return wmemcmp(__s1, __s2, __n); -#else - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wcslen(__s); -#elif _LIBCPP_STD_VER <= 14 - return wcslen(__s); -#else - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const wchar_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - if (__n == 0) - return nullptr; -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wmemchr(__s, __a, __n); -#elif _LIBCPP_STD_VER <= 14 - return wmemchr(__s, __a, __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char16_t char_type; - typedef uint_least16_t int_type; - typedef streamoff off_type; - typedef u16streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xFFFF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char16_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline -char16_t* -char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline -char16_t* -char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline -char16_t* -char_traits::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits -{ - typedef char32_t char_type; - typedef uint_least32_t int_type; - typedef streamoff off_type; - typedef u32streampos pos_type; - typedef mbstate_t state_type; - - static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 - void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} - static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT - {return __c1 < __c2;} - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - size_t length(const char_type* __s) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; - - static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT - {return char_type(__c);} - static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT - {return int_type(__c);} - static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT - {return __c1 == __c2;} - static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xFFFFFFFF);} -}; - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -int -char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -const char32_t* -char_traits::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline -char32_t* -char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline -char32_t* -char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline -char32_t* -char_traits::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - -// helper fns for basic_string and string_view - -// __str_find -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos >= __sz) - return __npos; - const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); - if (__r == 0) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT * -__search_substring(const _CharT *__first1, const _CharT *__last1, - const _CharT *__first2, const _CharT *__last2) { - // Take advantage of knowing source and pattern lengths. - // Stop short when source is smaller than pattern. - const ptrdiff_t __len2 = __last2 - __first2; - if (__len2 == 0) - return __first1; - - ptrdiff_t __len1 = __last1 - __first1; - if (__len1 < __len2) - return __last1; - - // First element of __first2 is loop invariant. - _CharT __f2 = *__first2; - while (true) { - __len1 = __last1 - __first1; - // Check whether __first1 still has at least __len2 bytes. - if (__len1 < __len2) - return __last1; - - // Find __f2 the first byte matching in __first1. - __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); - if (__first1 == 0) - return __last1; - - // It is faster to compare from the first byte of __first1 even if we - // already know that it matches the first byte of __first2: this is because - // __first2 is most likely aligned, as it is user's "pattern" string, and - // __first1 + 1 is most likely not aligned, as the match is in the middle of - // the string. - if (_Traits::compare(__first1, __first2, __len2) == 0) - return __first1; - - ++__first1; - } -} - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos > __sz) - return __npos; - - if (__n == 0) // There is nothing to search, just return __pos. - return __pos; - - const _CharT *__r = __search_substring<_CharT, _Traits>( - __p + __pos, __p + __sz, __s, __s + __n); - - if (__r == __p + __sz) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - - -// __str_rfind - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_rfind(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__sz < 1) - return __npos; - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - { - if (_Traits::eq(*--__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_rfind(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - __pos = _VSTD::min(__pos, __sz); - if (__n < __sz - __pos) - __pos += __n; - else - __pos = __sz; - const _CharT* __r = _VSTD::__find_end( - __p, __p + __pos, __s, __s + __n, _Traits::eq, - random_access_iterator_tag(), random_access_iterator_tag()); - if (__n > 0 && __r == __p + __pos) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - -// __str_find_first_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos >= __sz || __n == 0) - return __npos; - const _CharT* __r = _VSTD::__find_first_of_ce - (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); - if (__r == __p + __sz) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - - -// __str_find_last_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT - { - if (__n != 0) - { - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - { - const _CharT* __r = _Traits::find(__s, __n, *--__ps); - if (__r) - return static_cast<_SizeT>(__ps - __p); - } - } - return __npos; -} - - -// __str_find_first_not_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_not_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos < __sz) - { - const _CharT* __pe = __p + __sz; - for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) - if (_Traits::find(__s, __n, *__ps) == 0) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_first_not_of(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos < __sz) - { - const _CharT* __pe = __p + __sz; - for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) - if (!_Traits::eq(*__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - - -// __str_find_last_not_of -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_not_of(const _CharT *__p, _SizeT __sz, - const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT -{ - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - if (_Traits::find(__s, __n, *--__ps) == 0) - return static_cast<_SizeT>(__ps - __p); - return __npos; -} - - -template -inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY -__str_find_last_not_of(const _CharT *__p, _SizeT __sz, - _CharT __c, _SizeT __pos) _NOEXCEPT -{ - if (__pos < __sz) - ++__pos; - else - __pos = __sz; - for (const _CharT* __ps = __p + __pos; __ps != __p;) - if (!_Traits::eq(*--__ps, __c)) - return static_cast<_SizeT>(__ps - __p); - return __npos; -} - -template -inline _LIBCPP_INLINE_VISIBILITY -size_t __do_string_hash(_Ptr __p, _Ptr __e) -{ - typedef typename iterator_traits<_Ptr>::value_type value_type; - return __murmur2_or_cityhash()(__p, (__e-__p)*sizeof(value_type)); -} - -template > -struct __quoted_output_proxy -{ - _Iter __first; - _Iter __last; - _CharT __delim; - _CharT __escape; - - __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) - : __first(__f), __last(__l), __delim(__d), __escape(__e) {} - // This would be a nice place for a string_ref -}; - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___STRING diff --git a/external/include/c++/v1/__threading_support b/external/include/c++/v1/__threading_support deleted file mode 100644 index 2024900..0000000 --- a/external/include/c++/v1/__threading_support +++ /dev/null @@ -1,402 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_THREADING_SUPPORT -#define _LIBCPP_THREADING_SUPPORT - -#include <__config> -#include -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -# include <__external_threading> -#elif !defined(_LIBCPP_HAS_NO_THREADS) - -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -# include -# include -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_HAS_THREAD_API_WIN32) -#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS -#else -#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY -#endif - -#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) -#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) -#else -#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -// Mutex -typedef pthread_mutex_t __libcpp_mutex_t; -#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - -typedef pthread_mutex_t __libcpp_recursive_mutex_t; - -// Condition Variable -typedef pthread_cond_t __libcpp_condvar_t; -#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER - -// Execute once -typedef pthread_once_t __libcpp_exec_once_flag; -#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT - -// Thread id -typedef pthread_t __libcpp_thread_id; - -// Thread -#define _LIBCPP_NULL_THREAD 0U - -typedef pthread_t __libcpp_thread_t; - -// Thread Local Storage -typedef pthread_key_t __libcpp_tls_key; - -#define _LIBCPP_TLS_DESTRUCTOR_CC -#else -// Mutex -typedef void* __libcpp_mutex_t; -#define _LIBCPP_MUTEX_INITIALIZER 0 - -#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__) -typedef void* __libcpp_recursive_mutex_t[6]; -#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__) -typedef void* __libcpp_recursive_mutex_t[5]; -#else -# error Unsupported architecture -#endif - -// Condition Variable -typedef void* __libcpp_condvar_t; -#define _LIBCPP_CONDVAR_INITIALIZER 0 - -// Execute Once -typedef void* __libcpp_exec_once_flag; -#define _LIBCPP_EXEC_ONCE_INITIALIZER 0 - -// Thread ID -typedef long __libcpp_thread_id; - -// Thread -#define _LIBCPP_NULL_THREAD 0U - -typedef void* __libcpp_thread_t; - -// Thread Local Storage -typedef long __libcpp_tls_key; - -#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall -#endif - -// Mutex -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_mutex_lock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_mutex_destroy(__libcpp_mutex_t *__m); - -// Condition variable -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); - -_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS -int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, - timespec *__ts); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); - -// Execute once -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_execute_once(__libcpp_exec_once_flag *flag, - void (*init_routine)(void)); - -// Thread id -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); - -// Thread -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_thread_isnull(const __libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), - void *__arg); - -_LIBCPP_THREAD_ABI_VISIBILITY -__libcpp_thread_id __libcpp_thread_get_current_id(); - -_LIBCPP_THREAD_ABI_VISIBILITY -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_join(__libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_thread_detach(__libcpp_thread_t *__t); - -_LIBCPP_THREAD_ABI_VISIBILITY -void __libcpp_thread_yield(); - -_LIBCPP_THREAD_ABI_VISIBILITY -void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); - -// Thread local storage -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_tls_create(__libcpp_tls_key* __key, - void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); - -_LIBCPP_THREAD_ABI_VISIBILITY -void *__libcpp_tls_get(__libcpp_tls_key __key); - -_LIBCPP_THREAD_ABI_VISIBILITY -int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); - -#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ - defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \ - defined(_LIBCPP_HAS_THREAD_API_PTHREAD) - -int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) -{ - pthread_mutexattr_t attr; - int __ec = pthread_mutexattr_init(&attr); - if (__ec) - return __ec; - __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - if (__ec) { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutex_init(__m, &attr); - if (__ec) { - pthread_mutexattr_destroy(&attr); - return __ec; - } - __ec = pthread_mutexattr_destroy(&attr); - if (__ec) { - pthread_mutex_destroy(__m); - return __ec; - } - return 0; -} - -int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_lock(__m); -} - -bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_trylock(__m) == 0; -} - -int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_unlock(__m); -} - -int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m) -{ - return pthread_mutex_destroy(__m); -} - -int __libcpp_mutex_lock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_lock(__m); -} - -bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_trylock(__m) == 0; -} - -int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) -{ - return pthread_mutex_unlock(__m); -} - -int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) -{ - return pthread_mutex_destroy(__m); -} - -// Condition Variable -int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) -{ - return pthread_cond_signal(__cv); -} - -int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) -{ - return pthread_cond_broadcast(__cv); -} - -int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) -{ - return pthread_cond_wait(__cv, __m); -} - -int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, - timespec *__ts) -{ - return pthread_cond_timedwait(__cv, __m, __ts); -} - -int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) -{ - return pthread_cond_destroy(__cv); -} - -// Execute once -int __libcpp_execute_once(__libcpp_exec_once_flag *flag, - void (*init_routine)(void)) { - return pthread_once(flag, init_routine); -} - -// Thread id -// Returns non-zero if the thread ids are equal, otherwise 0 -bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) -{ - return pthread_equal(t1, t2) != 0; -} - -// Returns non-zero if t1 < t2, otherwise 0 -bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) -{ - return t1 < t2; -} - -// Thread -bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) { - return *__t == 0; -} - -int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), - void *__arg) -{ - return pthread_create(__t, 0, __func, __arg); -} - -__libcpp_thread_id __libcpp_thread_get_current_id() -{ - return pthread_self(); -} - -__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) -{ - return *__t; -} - -int __libcpp_thread_join(__libcpp_thread_t *__t) -{ - return pthread_join(*__t, 0); -} - -int __libcpp_thread_detach(__libcpp_thread_t *__t) -{ - return pthread_detach(*__t); -} - -void __libcpp_thread_yield() -{ - sched_yield(); -} - -void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) -{ - using namespace chrono; - seconds __s = duration_cast(__ns); - timespec __ts; - typedef decltype(__ts.tv_sec) ts_sec; - _LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits::max(); - - if (__s.count() < __ts_sec_max) - { - __ts.tv_sec = static_cast(__s.count()); - __ts.tv_nsec = static_cast((__ns - __s).count()); - } - else - { - __ts.tv_sec = __ts_sec_max; - __ts.tv_nsec = 999999999; // (10^9 - 1) - } - - while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR); -} - -// Thread local storage -int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *)) -{ - return pthread_key_create(__key, __at_exit); -} - -void *__libcpp_tls_get(__libcpp_tls_key __key) -{ - return pthread_getspecific(__key); -} - -int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) -{ - return pthread_setspecific(__key, __p); -} - -#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // !_LIBCPP_HAS_NO_THREADS - -#endif // _LIBCPP_THREADING_SUPPORT diff --git a/external/include/c++/v1/__tree b/external/include/c++/v1/__tree deleted file mode 100644 index 3b3586c..0000000 --- a/external/include/c++/v1/__tree +++ /dev/null @@ -1,2843 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TREE -#define _LIBCPP___TREE - -#include <__config> -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class __tree; -template - class _LIBCPP_TEMPLATE_VIS __tree_iterator; -template - class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; - -template class __tree_end_node; -template class __tree_node_base; -template class __tree_node; - -template -struct __value_type; - -template ::value && !__libcpp_is_final<_Compare>::value> -class __map_value_compare; - -template class __map_node_destructor; -template class _LIBCPP_TEMPLATE_VIS __map_iterator; -template class _LIBCPP_TEMPLATE_VIS __map_const_iterator; - -/* - -_NodePtr algorithms - -The algorithms taking _NodePtr are red black tree algorithms. Those -algorithms taking a parameter named __root should assume that __root -points to a proper red black tree (unless otherwise specified). - -Each algorithm herein assumes that __root->__parent_ points to a non-null -structure which has a member __left_ which points back to __root. No other -member is read or written to at __root->__parent_. - -__root->__parent_ will be referred to below (in comments only) as end_node. -end_node->__left_ is an externably accessible lvalue for __root, and can be -changed by node insertion and removal (without explicit reference to end_node). - -All nodes (with the exception of end_node), even the node referred to as -__root, have a non-null __parent_ field. - -*/ - -// Returns: true if __x is a left child of its parent, else false -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -bool -__tree_is_left_child(_NodePtr __x) _NOEXCEPT -{ - return __x == __x->__parent_->__left_; -} - -// Determines if the subtree rooted at __x is a proper red black subtree. If -// __x is a proper subtree, returns the black height (null counts as 1). If -// __x is an improper subtree, returns 0. -template -unsigned -__tree_sub_invariant(_NodePtr __x) -{ - if (__x == nullptr) - return 1; - // parent consistency checked by caller - // check __x->__left_ consistency - if (__x->__left_ != nullptr && __x->__left_->__parent_ != __x) - return 0; - // check __x->__right_ consistency - if (__x->__right_ != nullptr && __x->__right_->__parent_ != __x) - return 0; - // check __x->__left_ != __x->__right_ unless both are nullptr - if (__x->__left_ == __x->__right_ && __x->__left_ != nullptr) - return 0; - // If this is red, neither child can be red - if (!__x->__is_black_) - { - if (__x->__left_ && !__x->__left_->__is_black_) - return 0; - if (__x->__right_ && !__x->__right_->__is_black_) - return 0; - } - unsigned __h = __tree_sub_invariant(__x->__left_); - if (__h == 0) - return 0; // invalid left subtree - if (__h != __tree_sub_invariant(__x->__right_)) - return 0; // invalid or different height right subtree - return __h + __x->__is_black_; // return black height of this node -} - -// Determines if the red black tree rooted at __root is a proper red black tree. -// __root == nullptr is a proper tree. Returns true is __root is a proper -// red black tree, else returns false. -template -bool -__tree_invariant(_NodePtr __root) -{ - if (__root == nullptr) - return true; - // check __x->__parent_ consistency - if (__root->__parent_ == nullptr) - return false; - if (!__tree_is_left_child(__root)) - return false; - // root must be black - if (!__root->__is_black_) - return false; - // do normal node checks - return __tree_sub_invariant(__root) != 0; -} - -// Returns: pointer to the left-most node under __x. -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_min(_NodePtr __x) _NOEXCEPT -{ - while (__x->__left_ != nullptr) - __x = __x->__left_; - return __x; -} - -// Returns: pointer to the right-most node under __x. -// Precondition: __x != nullptr. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_max(_NodePtr __x) _NOEXCEPT -{ - while (__x->__right_ != nullptr) - __x = __x->__right_; - return __x; -} - -// Returns: pointer to the next in-order node after __x. -// Precondition: __x != nullptr. -template -_NodePtr -__tree_next(_NodePtr __x) _NOEXCEPT -{ - if (__x->__right_ != nullptr) - return __tree_min(__x->__right_); - while (!__tree_is_left_child(__x)) - __x = __x->__parent_unsafe(); - return __x->__parent_unsafe(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_EndNodePtr -__tree_next_iter(_NodePtr __x) _NOEXCEPT -{ - if (__x->__right_ != nullptr) - return static_cast<_EndNodePtr>(__tree_min(__x->__right_)); - while (!__tree_is_left_child(__x)) - __x = __x->__parent_unsafe(); - return static_cast<_EndNodePtr>(__x->__parent_); -} - -// Returns: pointer to the previous in-order node before __x. -// Precondition: __x != nullptr. -// Note: __x may be the end node. -template -inline _LIBCPP_INLINE_VISIBILITY -_NodePtr -__tree_prev_iter(_EndNodePtr __x) _NOEXCEPT -{ - if (__x->__left_ != nullptr) - return __tree_max(__x->__left_); - _NodePtr __xx = static_cast<_NodePtr>(__x); - while (__tree_is_left_child(__xx)) - __xx = __xx->__parent_unsafe(); - return __xx->__parent_unsafe(); -} - -// Returns: pointer to a node which has no children -// Precondition: __x != nullptr. -template -_NodePtr -__tree_leaf(_NodePtr __x) _NOEXCEPT -{ - while (true) - { - if (__x->__left_ != nullptr) - { - __x = __x->__left_; - continue; - } - if (__x->__right_ != nullptr) - { - __x = __x->__right_; - continue; - } - break; - } - return __x; -} - -// Effects: Makes __x->__right_ the subtree root with __x as its left child -// while preserving in-order order. -// Precondition: __x->__right_ != nullptr -template -void -__tree_left_rotate(_NodePtr __x) _NOEXCEPT -{ - _NodePtr __y = __x->__right_; - __x->__right_ = __y->__left_; - if (__x->__right_ != nullptr) - __x->__right_->__set_parent(__x); - __y->__parent_ = __x->__parent_; - if (__tree_is_left_child(__x)) - __x->__parent_->__left_ = __y; - else - __x->__parent_unsafe()->__right_ = __y; - __y->__left_ = __x; - __x->__set_parent(__y); -} - -// Effects: Makes __x->__left_ the subtree root with __x as its right child -// while preserving in-order order. -// Precondition: __x->__left_ != nullptr -template -void -__tree_right_rotate(_NodePtr __x) _NOEXCEPT -{ - _NodePtr __y = __x->__left_; - __x->__left_ = __y->__right_; - if (__x->__left_ != nullptr) - __x->__left_->__set_parent(__x); - __y->__parent_ = __x->__parent_; - if (__tree_is_left_child(__x)) - __x->__parent_->__left_ = __y; - else - __x->__parent_unsafe()->__right_ = __y; - __y->__right_ = __x; - __x->__set_parent(__y); -} - -// Effects: Rebalances __root after attaching __x to a leaf. -// Precondition: __root != nulptr && __x != nullptr. -// __x has no children. -// __x == __root or == a direct or indirect child of __root. -// If __x were to be unlinked from __root (setting __root to -// nullptr if __root == __x), __tree_invariant(__root) == true. -// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_ -// may be different than the value passed in as __root. -template -void -__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT -{ - __x->__is_black_ = __x == __root; - while (__x != __root && !__x->__parent_unsafe()->__is_black_) - { - // __x->__parent_ != __root because __x->__parent_->__is_black == false - if (__tree_is_left_child(__x->__parent_unsafe())) - { - _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_; - if (__y != nullptr && !__y->__is_black_) - { - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = __x == __root; - __y->__is_black_ = true; - } - else - { - if (!__tree_is_left_child(__x)) - { - __x = __x->__parent_unsafe(); - __tree_left_rotate(__x); - } - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = false; - __tree_right_rotate(__x); - break; - } - } - else - { - _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_; - if (__y != nullptr && !__y->__is_black_) - { - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = __x == __root; - __y->__is_black_ = true; - } - else - { - if (__tree_is_left_child(__x)) - { - __x = __x->__parent_unsafe(); - __tree_right_rotate(__x); - } - __x = __x->__parent_unsafe(); - __x->__is_black_ = true; - __x = __x->__parent_unsafe(); - __x->__is_black_ = false; - __tree_left_rotate(__x); - break; - } - } - } -} - -// Precondition: __root != nullptr && __z != nullptr. -// __tree_invariant(__root) == true. -// __z == __root or == a direct or indirect child of __root. -// Effects: unlinks __z from the tree rooted at __root, rebalancing as needed. -// Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_ -// nor any of its children refer to __z. end_node->__left_ -// may be different than the value passed in as __root. -template -void -__tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT -{ - // __z will be removed from the tree. Client still needs to destruct/deallocate it - // __y is either __z, or if __z has two children, __tree_next(__z). - // __y will have at most one child. - // __y will be the initial hole in the tree (make the hole at a leaf) - _NodePtr __y = (__z->__left_ == nullptr || __z->__right_ == nullptr) ? - __z : __tree_next(__z); - // __x is __y's possibly null single child - _NodePtr __x = __y->__left_ != nullptr ? __y->__left_ : __y->__right_; - // __w is __x's possibly null uncle (will become __x's sibling) - _NodePtr __w = nullptr; - // link __x to __y's parent, and find __w - if (__x != nullptr) - __x->__parent_ = __y->__parent_; - if (__tree_is_left_child(__y)) - { - __y->__parent_->__left_ = __x; - if (__y != __root) - __w = __y->__parent_unsafe()->__right_; - else - __root = __x; // __w == nullptr - } - else - { - __y->__parent_unsafe()->__right_ = __x; - // __y can't be root if it is a right child - __w = __y->__parent_->__left_; - } - bool __removed_black = __y->__is_black_; - // If we didn't remove __z, do so now by splicing in __y for __z, - // but copy __z's color. This does not impact __x or __w. - if (__y != __z) - { - // __z->__left_ != nulptr but __z->__right_ might == __x == nullptr - __y->__parent_ = __z->__parent_; - if (__tree_is_left_child(__z)) - __y->__parent_->__left_ = __y; - else - __y->__parent_unsafe()->__right_ = __y; - __y->__left_ = __z->__left_; - __y->__left_->__set_parent(__y); - __y->__right_ = __z->__right_; - if (__y->__right_ != nullptr) - __y->__right_->__set_parent(__y); - __y->__is_black_ = __z->__is_black_; - if (__root == __z) - __root = __y; - } - // There is no need to rebalance if we removed a red, or if we removed - // the last node. - if (__removed_black && __root != nullptr) - { - // Rebalance: - // __x has an implicit black color (transferred from the removed __y) - // associated with it, no matter what its color is. - // If __x is __root (in which case it can't be null), it is supposed - // to be black anyway, and if it is doubly black, then the double - // can just be ignored. - // If __x is red (in which case it can't be null), then it can absorb - // the implicit black just by setting its color to black. - // Since __y was black and only had one child (which __x points to), __x - // is either red with no children, else null, otherwise __y would have - // different black heights under left and right pointers. - // if (__x == __root || __x != nullptr && !__x->__is_black_) - if (__x != nullptr) - __x->__is_black_ = true; - else - { - // Else __x isn't root, and is "doubly black", even though it may - // be null. __w can not be null here, else the parent would - // see a black height >= 2 on the __x side and a black height - // of 1 on the __w side (__w must be a non-null black or a red - // with a non-null black child). - while (true) - { - if (!__tree_is_left_child(__w)) // if x is left child - { - if (!__w->__is_black_) - { - __w->__is_black_ = true; - __w->__parent_unsafe()->__is_black_ = false; - __tree_left_rotate(__w->__parent_unsafe()); - // __x is still valid - // reset __root only if necessary - if (__root == __w->__left_) - __root = __w; - // reset sibling, and it still can't be null - __w = __w->__left_->__right_; - } - // __w->__is_black_ is now true, __w may have null children - if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && - (__w->__right_ == nullptr || __w->__right_->__is_black_)) - { - __w->__is_black_ = false; - __x = __w->__parent_unsafe(); - // __x can no longer be null - if (__x == __root || !__x->__is_black_) - { - __x->__is_black_ = true; - break; - } - // reset sibling, and it still can't be null - __w = __tree_is_left_child(__x) ? - __x->__parent_unsafe()->__right_ : - __x->__parent_->__left_; - // continue; - } - else // __w has a red child - { - if (__w->__right_ == nullptr || __w->__right_->__is_black_) - { - // __w left child is non-null and red - __w->__left_->__is_black_ = true; - __w->__is_black_ = false; - __tree_right_rotate(__w); - // __w is known not to be root, so root hasn't changed - // reset sibling, and it still can't be null - __w = __w->__parent_unsafe(); - } - // __w has a right red child, left child may be null - __w->__is_black_ = __w->__parent_unsafe()->__is_black_; - __w->__parent_unsafe()->__is_black_ = true; - __w->__right_->__is_black_ = true; - __tree_left_rotate(__w->__parent_unsafe()); - break; - } - } - else - { - if (!__w->__is_black_) - { - __w->__is_black_ = true; - __w->__parent_unsafe()->__is_black_ = false; - __tree_right_rotate(__w->__parent_unsafe()); - // __x is still valid - // reset __root only if necessary - if (__root == __w->__right_) - __root = __w; - // reset sibling, and it still can't be null - __w = __w->__right_->__left_; - } - // __w->__is_black_ is now true, __w may have null children - if ((__w->__left_ == nullptr || __w->__left_->__is_black_) && - (__w->__right_ == nullptr || __w->__right_->__is_black_)) - { - __w->__is_black_ = false; - __x = __w->__parent_unsafe(); - // __x can no longer be null - if (!__x->__is_black_ || __x == __root) - { - __x->__is_black_ = true; - break; - } - // reset sibling, and it still can't be null - __w = __tree_is_left_child(__x) ? - __x->__parent_unsafe()->__right_ : - __x->__parent_->__left_; - // continue; - } - else // __w has a red child - { - if (__w->__left_ == nullptr || __w->__left_->__is_black_) - { - // __w right child is non-null and red - __w->__right_->__is_black_ = true; - __w->__is_black_ = false; - __tree_left_rotate(__w); - // __w is known not to be root, so root hasn't changed - // reset sibling, and it still can't be null - __w = __w->__parent_unsafe(); - } - // __w has a left red child, right child may be null - __w->__is_black_ = __w->__parent_unsafe()->__is_black_; - __w->__parent_unsafe()->__is_black_ = true; - __w->__left_->__is_black_ = true; - __tree_right_rotate(__w->__parent_unsafe()); - break; - } - } - } - } - } -} - -// node traits - - -#ifndef _LIBCPP_CXX03_LANG -template -struct __is_tree_value_type_imp : false_type {}; - -template -struct __is_tree_value_type_imp<__value_type<_Key, _Value>> : true_type {}; - -template -struct __is_tree_value_type : false_type {}; - -template -struct __is_tree_value_type<_One> : __is_tree_value_type_imp::type> {}; -#endif - -template -struct __tree_key_value_types { - typedef _Tp key_type; - typedef _Tp __node_value_type; - typedef _Tp __container_value_type; - static const bool __is_map = false; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& __get_key(_Tp const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& __get_value(__node_value_type const& __v) { - return __v; - } - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n); - } -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static __container_value_type&& __move(__node_value_type& __v) { - return _VSTD::move(__v); - } -#endif -}; - -template -struct __tree_key_value_types<__value_type<_Key, _Tp> > { - typedef _Key key_type; - typedef _Tp mapped_type; - typedef __value_type<_Key, _Tp> __node_value_type; - typedef pair __container_value_type; - typedef __container_value_type __map_value_type; - static const bool __is_map = true; - - _LIBCPP_INLINE_VISIBILITY - static key_type const& - __get_key(__node_value_type const& __t) { - return __t.__get_value().first; - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - key_type const&>::type - __get_key(_Up& __t) { - return __t.first; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type const& - __get_value(__node_value_type const& __t) { - return __t.__get_value(); - } - - template - _LIBCPP_INLINE_VISIBILITY - static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, - __container_value_type const&>::type - __get_value(_Up& __t) { - return __t; - } - - _LIBCPP_INLINE_VISIBILITY - static __container_value_type* __get_ptr(__node_value_type& __n) { - return _VSTD::addressof(__n.__get_value()); - } - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - static pair __move(__node_value_type& __v) { - return __v.__move(); - } -#endif -}; - -template -struct __tree_node_base_types { - typedef _VoidPtr __void_pointer; - - typedef __tree_node_base<__void_pointer> __node_base_type; - typedef typename __rebind_pointer<_VoidPtr, __node_base_type>::type - __node_base_pointer; - - typedef __tree_end_node<__node_base_pointer> __end_node_type; - typedef typename __rebind_pointer<_VoidPtr, __end_node_type>::type - __end_node_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) - typedef __end_node_pointer __parent_pointer; -#else - typedef typename conditional< - is_pointer<__end_node_pointer>::value, - __end_node_pointer, - __node_base_pointer>::type __parent_pointer; -#endif - -private: - static_assert((is_same::element_type, void>::value), - "_VoidPtr does not point to unqualified void type"); -}; - -template , - bool = _KVTypes::__is_map> -struct __tree_map_pointer_types {}; - -template -struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> { - typedef typename _KVTypes::__map_value_type _Mv; - typedef typename __rebind_pointer<_AllocPtr, _Mv>::type - __map_value_type_pointer; - typedef typename __rebind_pointer<_AllocPtr, const _Mv>::type - __const_map_value_type_pointer; -}; - -template ::element_type> -struct __tree_node_types; - -template -struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> > - : public __tree_node_base_types<_VoidPtr>, - __tree_key_value_types<_Tp>, - __tree_map_pointer_types<_Tp, _VoidPtr> -{ - typedef __tree_node_base_types<_VoidPtr> __base; - typedef __tree_key_value_types<_Tp> __key_base; - typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base; -public: - - typedef typename pointer_traits<_NodePtr>::element_type __node_type; - typedef _NodePtr __node_pointer; - - typedef _Tp __node_value_type; - typedef typename __rebind_pointer<_VoidPtr, __node_value_type>::type - __node_value_type_pointer; - typedef typename __rebind_pointer<_VoidPtr, const __node_value_type>::type - __const_node_value_type_pointer; -#if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) - typedef typename __base::__end_node_pointer __iter_pointer; -#else - typedef typename conditional< - is_pointer<__node_pointer>::value, - typename __base::__end_node_pointer, - __node_pointer>::type __iter_pointer; -#endif -private: - static_assert(!is_const<__node_type>::value, - "_NodePtr should never be a pointer to const"); - static_assert((is_same::type, - _NodePtr>::value), "_VoidPtr does not rebind to _NodePtr."); -}; - -template -struct __make_tree_node_types { - typedef typename __rebind_pointer<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> >::type - _NodePtr; - typedef __tree_node_types<_NodePtr> type; -}; - -// node - -template -class __tree_end_node -{ -public: - typedef _Pointer pointer; - pointer __left_; - - _LIBCPP_INLINE_VISIBILITY - __tree_end_node() _NOEXCEPT : __left_() {} -}; - -template -class __tree_node_base - : public __tree_node_base_types<_VoidPtr>::__end_node_type -{ - typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes; - -public: - typedef typename _NodeBaseTypes::__node_base_pointer pointer; - typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer; - - pointer __right_; - __parent_pointer __parent_; - bool __is_black_; - - _LIBCPP_INLINE_VISIBILITY - pointer __parent_unsafe() const { return static_cast(__parent_);} - - _LIBCPP_INLINE_VISIBILITY - void __set_parent(pointer __p) { - __parent_ = static_cast<__parent_pointer>(__p); - } - -private: - ~__tree_node_base() _LIBCPP_EQUAL_DELETE; - __tree_node_base(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; - __tree_node_base& operator=(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; -}; - -template -class __tree_node - : public __tree_node_base<_VoidPtr> -{ -public: - typedef _Tp __node_value_type; - - __node_value_type __value_; - -private: - ~__tree_node() _LIBCPP_EQUAL_DELETE; - __tree_node(__tree_node const&) _LIBCPP_EQUAL_DELETE; - __tree_node& operator=(__tree_node const&) _LIBCPP_EQUAL_DELETE; -}; - - -template -class __tree_node_destructor -{ - typedef _Allocator allocator_type; - typedef allocator_traits __alloc_traits; - -public: - typedef typename __alloc_traits::pointer pointer; -private: - typedef __tree_node_types _NodeTypes; - allocator_type& __na_; - - __tree_node_destructor& operator=(const __tree_node_destructor&); - -public: - bool __value_constructed; - - _LIBCPP_INLINE_VISIBILITY - explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT - : __na_(__na), - __value_constructed(__val) - {} - - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - { - if (__value_constructed) - __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); - if (__p) - __alloc_traits::deallocate(__na_, __p, 1); - } - - template friend class __map_node_destructor; -}; - -#if _LIBCPP_STD_VER > 14 -template -struct __generic_container_node_destructor; -template -struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> - : __tree_node_destructor<_Alloc> -{ - using __tree_node_destructor<_Alloc>::__tree_node_destructor; -}; -#endif - -template -class _LIBCPP_TEMPLATE_VIS __tree_iterator -{ - typedef __tree_node_types<_NodePtr> _NodeTypes; - typedef _NodePtr __node_pointer; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - typedef pointer_traits<__node_pointer> __pointer_traits; - - __iter_pointer __ptr_; - -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _DiffType difference_type; - typedef value_type& reference; - typedef typename _NodeTypes::__node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __ptr_(nullptr) -#endif - {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const - {return __get_np()->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const - {return pointer_traits::pointer_to(__get_np()->__value_);} - - _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator++() { - __ptr_ = static_cast<__iter_pointer>( - __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); - return *this; - } - _LIBCPP_INLINE_VISIBILITY - __tree_iterator operator++(int) - {__tree_iterator __t(*this); ++(*this); return __t;} - - _LIBCPP_INLINE_VISIBILITY - __tree_iterator& operator--() { - __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>( - static_cast<__end_node_pointer>(__ptr_))); - return *this; - } - _LIBCPP_INLINE_VISIBILITY - __tree_iterator operator--(int) - {__tree_iterator __t(*this); --(*this); return __t;} - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) - {return __x.__ptr_ == __y.__ptr_;} - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) - {return !(__x == __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } - template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; -}; - -template -class _LIBCPP_TEMPLATE_VIS __tree_const_iterator -{ - typedef __tree_node_types<_NodePtr> _NodeTypes; - typedef typename _NodeTypes::__node_pointer __node_pointer; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - typedef typename _NodeTypes::__end_node_pointer __end_node_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - typedef pointer_traits<__node_pointer> __pointer_traits; - - __iter_pointer __ptr_; - -public: - typedef bidirectional_iterator_tag iterator_category; - typedef _Tp value_type; - typedef _DiffType difference_type; - typedef const value_type& reference; - typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - - _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT -#if _LIBCPP_STD_VER > 11 - : __ptr_(nullptr) -#endif - {} - -private: - typedef __tree_iterator - __non_const_iterator; -public: - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT - : __ptr_(__p.__ptr_) {} - - _LIBCPP_INLINE_VISIBILITY reference operator*() const - {return __get_np()->__value_;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const - {return pointer_traits::pointer_to(__get_np()->__value_);} - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator++() { - __ptr_ = static_cast<__iter_pointer>( - __tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_))); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator operator++(int) - {__tree_const_iterator __t(*this); ++(*this); return __t;} - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator& operator--() { - __ptr_ = static_cast<__iter_pointer>(__tree_prev_iter<__node_base_pointer>( - static_cast<__end_node_pointer>(__ptr_))); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __tree_const_iterator operator--(int) - {__tree_const_iterator __t(*this); --(*this); return __t;} - - friend _LIBCPP_INLINE_VISIBILITY - bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) - {return __x.__ptr_ == __y.__ptr_;} - friend _LIBCPP_INLINE_VISIBILITY - bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) - {return !(__x == __y);} - -private: - _LIBCPP_INLINE_VISIBILITY - explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT - : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT - : __ptr_(__p) {} - _LIBCPP_INLINE_VISIBILITY - __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } - - template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; - template friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; - -}; - -#ifndef _LIBCPP_CXX03_LANG -template -struct __diagnose_tree_helper { - static constexpr bool __trigger_diagnostics() - _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value, - "the specified comparator type does not provide a const call operator") - { return true; } -}; - -template -struct __diagnose_tree_helper< - __value_type<_Key, _Value>, - __map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>, - _Alloc -> : __diagnose_tree_helper<_Key, _KeyComp, _Alloc> -{ -}; -#endif // !_LIBCPP_CXX03_LANG - -template -class __tree -{ -public: - typedef _Tp value_type; - typedef _Compare value_compare; - typedef _Allocator allocator_type; - -private: - typedef allocator_traits __alloc_traits; - typedef typename __make_tree_node_types::type - _NodeTypes; - typedef typename _NodeTypes::key_type key_type; -public: - typedef typename _NodeTypes::__node_value_type __node_value_type; - typedef typename _NodeTypes::__container_value_type __container_value_type; - - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_type; - -public: - typedef typename _NodeTypes::__void_pointer __void_pointer; - - typedef typename _NodeTypes::__node_type __node; - typedef typename _NodeTypes::__node_pointer __node_pointer; - - typedef typename _NodeTypes::__node_base_type __node_base; - typedef typename _NodeTypes::__node_base_pointer __node_base_pointer; - - typedef typename _NodeTypes::__end_node_type __end_node_t; - typedef typename _NodeTypes::__end_node_pointer __end_node_ptr; - - typedef typename _NodeTypes::__parent_pointer __parent_pointer; - typedef typename _NodeTypes::__iter_pointer __iter_pointer; - - typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator; - typedef allocator_traits<__node_allocator> __node_traits; - -private: - // check for sane allocator pointer rebinding semantics. Rebinding the - // allocator for a new pointer type should be exactly the same as rebinding - // the pointer using 'pointer_traits'. - static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - typedef typename __rebind_alloc_helper<__node_traits, __node_base>::type - __node_base_allocator; - typedef allocator_traits<__node_base_allocator> __node_base_traits; - static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value), - "Allocator does not rebind pointers in a sane manner."); - -private: - __iter_pointer __begin_node_; - __compressed_pair<__end_node_t, __node_allocator> __pair1_; - __compressed_pair __pair3_; - -public: - _LIBCPP_INLINE_VISIBILITY - __iter_pointer __end_node() _NOEXCEPT - { - return static_cast<__iter_pointer>( - pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first()) - ); - } - _LIBCPP_INLINE_VISIBILITY - __iter_pointer __end_node() const _NOEXCEPT - { - return static_cast<__iter_pointer>( - pointer_traits<__end_node_ptr>::pointer_to( - const_cast<__end_node_t&>(__pair1_.first()) - ) - ); - } - _LIBCPP_INLINE_VISIBILITY - __node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();} -private: - _LIBCPP_INLINE_VISIBILITY - const __node_allocator& __node_alloc() const _NOEXCEPT - {return __pair1_.second();} - _LIBCPP_INLINE_VISIBILITY - __iter_pointer& __begin_node() _NOEXCEPT {return __begin_node_;} - _LIBCPP_INLINE_VISIBILITY - const __iter_pointer& __begin_node() const _NOEXCEPT {return __begin_node_;} -public: - _LIBCPP_INLINE_VISIBILITY - allocator_type __alloc() const _NOEXCEPT - {return allocator_type(__node_alloc());} -private: - _LIBCPP_INLINE_VISIBILITY - size_type& size() _NOEXCEPT {return __pair3_.first();} -public: - _LIBCPP_INLINE_VISIBILITY - const size_type& size() const _NOEXCEPT {return __pair3_.first();} - _LIBCPP_INLINE_VISIBILITY - value_compare& value_comp() _NOEXCEPT {return __pair3_.second();} - _LIBCPP_INLINE_VISIBILITY - const value_compare& value_comp() const _NOEXCEPT - {return __pair3_.second();} -public: - - _LIBCPP_INLINE_VISIBILITY - __node_pointer __root() const _NOEXCEPT - {return static_cast<__node_pointer>(__end_node()->__left_);} - - __node_base_pointer* __root_ptr() const _NOEXCEPT { - return _VSTD::addressof(__end_node()->__left_); - } - - typedef __tree_iterator iterator; - typedef __tree_const_iterator const_iterator; - - explicit __tree(const value_compare& __comp) - _NOEXCEPT_( - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_copy_constructible::value); - explicit __tree(const allocator_type& __a); - __tree(const value_compare& __comp, const allocator_type& __a); - __tree(const __tree& __t); - __tree& operator=(const __tree& __t); - template - void __assign_unique(_InputIterator __first, _InputIterator __last); - template - void __assign_multi(_InputIterator __first, _InputIterator __last); -#ifndef _LIBCPP_CXX03_LANG - __tree(__tree&& __t) - _NOEXCEPT_( - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value); - __tree(__tree&& __t, const allocator_type& __a); - __tree& operator=(__tree&& __t) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value); -#endif // _LIBCPP_CXX03_LANG - - ~__tree(); - - _LIBCPP_INLINE_VISIBILITY - iterator begin() _NOEXCEPT {return iterator(__begin_node());} - _LIBCPP_INLINE_VISIBILITY - const_iterator begin() const _NOEXCEPT {return const_iterator(__begin_node());} - _LIBCPP_INLINE_VISIBILITY - iterator end() _NOEXCEPT {return iterator(__end_node());} - _LIBCPP_INLINE_VISIBILITY - const_iterator end() const _NOEXCEPT {return const_iterator(__end_node());} - - _LIBCPP_INLINE_VISIBILITY - size_type max_size() const _NOEXCEPT - {return std::min( - __node_traits::max_size(__node_alloc()), - numeric_limits::max());} - - void clear() _NOEXCEPT; - - void swap(__tree& __t) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_( - __is_nothrow_swappable::value - && (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - ); -#else - _NOEXCEPT_(__is_nothrow_swappable::value); -#endif - -#ifndef _LIBCPP_CXX03_LANG - template - pair - __emplace_unique_key_args(_Key const&, _Args&&... __args); - template - iterator - __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...); - - template - pair __emplace_unique_impl(_Args&&... __args); - - template - iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args); - - template - iterator __emplace_multi(_Args&&... __args); - - template - iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args); - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Pp&& __x) { - return __emplace_unique_extract_key(_VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - pair - >::type __emplace_unique(_First&& __f, _Second&& __s) { - return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique(_Args&&... __args) { - return __emplace_unique_impl(_VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { - return __emplace_unique_impl(_VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { - return __emplace_unique_key_args(__x, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - pair - __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { - return __emplace_unique_key_args(__x.first, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) { - return __emplace_hint_unique_extract_key(__p, _VSTD::forward<_Pp>(__x), - __can_extract_key<_Pp, key_type>()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename enable_if< - __can_extract_map_key<_First, key_type, __container_value_type>::value, - iterator - >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { - return __emplace_hint_unique_key_args(__p, __f, - _VSTD::forward<_First>(__f), - _VSTD::forward<_Second>(__s)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) { - return __emplace_hint_unique_impl(__p, _VSTD::forward<_Args>(__args)...); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) { - return __emplace_hint_unique_impl(__p, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) { - return __emplace_hint_unique_key_args(__p, __x, _VSTD::forward<_Pp>(__x)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator - __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) { - return __emplace_hint_unique_key_args(__p, __x.first, _VSTD::forward<_Pp>(__x)); - } - -#else - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const&, _Args& __args); - template - _LIBCPP_INLINE_VISIBILITY - iterator __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&); -#endif - - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(const __container_value_type& __v) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, const __container_value_type& __v) { - return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v); - } - -#ifdef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const __container_value_type& __v); - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, const __container_value_type& __v); -#else - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(__container_value_type&& __v) { - return __emplace_unique_key_args(_NodeTypes::__get_key(__v), _VSTD::move(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, __container_value_type&& __v) { - return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)); - } - - template ::type, - __container_value_type - >::value - >::type> - _LIBCPP_INLINE_VISIBILITY - pair __insert_unique(_Vp&& __v) { - return __emplace_unique(_VSTD::forward<_Vp>(__v)); - } - - template ::type, - __container_value_type - >::value - >::type> - _LIBCPP_INLINE_VISIBILITY - iterator __insert_unique(const_iterator __p, _Vp&& __v) { - return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(__container_value_type&& __v) { - return __emplace_multi(_VSTD::move(__v)); - } - - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, __container_value_type&& __v) { - return __emplace_hint_multi(__p, _VSTD::move(__v)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(_Vp&& __v) { - return __emplace_multi(_VSTD::forward<_Vp>(__v)); - } - - template - _LIBCPP_INLINE_VISIBILITY - iterator __insert_multi(const_iterator __p, _Vp&& __v) { - return __emplace_hint_multi(__p, _VSTD::forward<_Vp>(__v)); - } - -#endif // !_LIBCPP_CXX03_LANG - - pair __node_insert_unique(__node_pointer __nd); - iterator __node_insert_unique(const_iterator __p, - __node_pointer __nd); - - iterator __node_insert_multi(__node_pointer __nd); - iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); - - - _LIBCPP_INLINE_VISIBILITY iterator __remove_node_pointer(__node_pointer); - -#if _LIBCPP_STD_VER > 14 - template - _LIBCPP_INLINE_VISIBILITY - _InsertReturnType __node_handle_insert_unique(_NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&); - - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(_NodeHandle&&); - template - _LIBCPP_INLINE_VISIBILITY - iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&); - - - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(key_type const&); - template - _LIBCPP_INLINE_VISIBILITY - _NodeHandle __node_handle_extract(const_iterator); -#endif - - iterator erase(const_iterator __p); - iterator erase(const_iterator __f, const_iterator __l); - template - size_type __erase_unique(const _Key& __k); - template - size_type __erase_multi(const _Key& __k); - - void __insert_node_at(__parent_pointer __parent, - __node_base_pointer& __child, - __node_base_pointer __new_node); - - template - iterator find(const _Key& __v); - template - const_iterator find(const _Key& __v) const; - - template - size_type __count_unique(const _Key& __k) const; - template - size_type __count_multi(const _Key& __k) const; - - template - _LIBCPP_INLINE_VISIBILITY - iterator lower_bound(const _Key& __v) - {return __lower_bound(__v, __root(), __end_node());} - template - iterator __lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result); - template - _LIBCPP_INLINE_VISIBILITY - const_iterator lower_bound(const _Key& __v) const - {return __lower_bound(__v, __root(), __end_node());} - template - const_iterator __lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const; - template - _LIBCPP_INLINE_VISIBILITY - iterator upper_bound(const _Key& __v) - {return __upper_bound(__v, __root(), __end_node());} - template - iterator __upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result); - template - _LIBCPP_INLINE_VISIBILITY - const_iterator upper_bound(const _Key& __v) const - {return __upper_bound(__v, __root(), __end_node());} - template - const_iterator __upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const; - template - pair - __equal_range_unique(const _Key& __k); - template - pair - __equal_range_unique(const _Key& __k) const; - - template - pair - __equal_range_multi(const _Key& __k); - template - pair - __equal_range_multi(const _Key& __k) const; - - typedef __tree_node_destructor<__node_allocator> _Dp; - typedef unique_ptr<__node, _Dp> __node_holder; - - __node_holder remove(const_iterator __p) _NOEXCEPT; -private: - __node_base_pointer& - __find_leaf_low(__parent_pointer& __parent, const key_type& __v); - __node_base_pointer& - __find_leaf_high(__parent_pointer& __parent, const key_type& __v); - __node_base_pointer& - __find_leaf(const_iterator __hint, - __parent_pointer& __parent, const key_type& __v); - // FIXME: Make this function const qualified. Unfortunetly doing so - // breaks existing code which uses non-const callable comparators. - template - __node_base_pointer& - __find_equal(__parent_pointer& __parent, const _Key& __v); - template - _LIBCPP_INLINE_VISIBILITY __node_base_pointer& - __find_equal(__parent_pointer& __parent, const _Key& __v) const { - return const_cast<__tree*>(this)->__find_equal(__parent, __v); - } - template - __node_base_pointer& - __find_equal(const_iterator __hint, __parent_pointer& __parent, - __node_base_pointer& __dummy, - const _Key& __v); - -#ifndef _LIBCPP_CXX03_LANG - template - __node_holder __construct_node(_Args&& ...__args); -#else - __node_holder __construct_node(const __container_value_type& __v); -#endif - - void destroy(__node_pointer __nd) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree& __t) - {__copy_assign_alloc(__t, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree& __t, true_type) - { - if (__node_alloc() != __t.__node_alloc()) - clear(); - __node_alloc() = __t.__node_alloc(); - } - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __tree&, false_type) {} - - void __move_assign(__tree& __t, false_type); - void __move_assign(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value); - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree& __t) - _NOEXCEPT_( - !__node_traits::propagate_on_container_move_assignment::value || - is_nothrow_move_assignable<__node_allocator>::value) - {__move_assign_alloc(__t, integral_constant());} - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) - {__node_alloc() = _VSTD::move(__t.__node_alloc());} - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} - - __node_pointer __detach(); - static __node_pointer __detach(__node_pointer); - - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; -}; - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) - _NOEXCEPT_( - is_nothrow_default_constructible<__node_allocator>::value && - is_nothrow_copy_constructible::value) - : __pair3_(0, __comp) -{ - __begin_node() = __end_node(); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0) -{ - __begin_node() = __end_node(); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, - const allocator_type& __a) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0, __comp) -{ - __begin_node() = __end_node(); -} - -// Precondition: size() != 0 -template -typename __tree<_Tp, _Compare, _Allocator>::__node_pointer -__tree<_Tp, _Compare, _Allocator>::__detach() -{ - __node_pointer __cache = static_cast<__node_pointer>(__begin_node()); - __begin_node() = __end_node(); - __end_node()->__left_->__parent_ = nullptr; - __end_node()->__left_ = nullptr; - size() = 0; - // __cache->__left_ == nullptr - if (__cache->__right_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__right_); - // __cache->__left_ == nullptr - // __cache->__right_ == nullptr - return __cache; -} - -// Precondition: __cache != nullptr -// __cache->left_ == nullptr -// __cache->right_ == nullptr -// This is no longer a red-black tree -template -typename __tree<_Tp, _Compare, _Allocator>::__node_pointer -__tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache) -{ - if (__cache->__parent_ == nullptr) - return nullptr; - if (__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) - { - __cache->__parent_->__left_ = nullptr; - __cache = static_cast<__node_pointer>(__cache->__parent_); - if (__cache->__right_ == nullptr) - return __cache; - return static_cast<__node_pointer>(__tree_leaf(__cache->__right_)); - } - // __cache is right child - __cache->__parent_unsafe()->__right_ = nullptr; - __cache = static_cast<__node_pointer>(__cache->__parent_); - if (__cache->__left_ == nullptr) - return __cache; - return static_cast<__node_pointer>(__tree_leaf(__cache->__left_)); -} - -template -__tree<_Tp, _Compare, _Allocator>& -__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) -{ - if (this != &__t) - { - value_comp() = __t.value_comp(); - __copy_assign_alloc(__t); - __assign_multi(__t.begin(), __t.end()); - } - return *this; -} - -template -template -void -__tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value), - "__assign_unique may only be called with the containers value type"); - - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__value_ = *__first; - __node_pointer __next = __detach(__cache); - __node_insert_unique(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - for (; __first != __last; ++__first) - __insert_unique(*__first); -} - -template -template -void -__tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) -{ - typedef iterator_traits<_InputIterator> _ITraits; - typedef typename _ITraits::value_type _ItValueType; - static_assert((is_same<_ItValueType, __container_value_type>::value || - is_same<_ItValueType, __node_value_type>::value), - "__assign_multi may only be called with the containers value type" - " or the nodes value type"); - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __cache != nullptr && __first != __last; ++__first) - { - __cache->__value_ = *__first; - __node_pointer __next = __detach(__cache); - __node_insert_multi(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - for (; __first != __last; ++__first) - __insert_multi(_NodeTypes::__get_value(*__first)); -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) - : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), - __pair3_(0, __t.value_comp()) -{ - __begin_node() = __end_node(); -} - -#ifndef _LIBCPP_CXX03_LANG - -template -__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) - _NOEXCEPT_( - is_nothrow_move_constructible<__node_allocator>::value && - is_nothrow_move_constructible::value) - : __begin_node_(_VSTD::move(__t.__begin_node_)), - __pair1_(_VSTD::move(__t.__pair1_)), - __pair3_(_VSTD::move(__t.__pair3_)) -{ - if (size() == 0) - __begin_node() = __end_node(); - else - { - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } -} - -template -__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) - : __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0, _VSTD::move(__t.value_comp())) -{ - if (__a == __t.__alloc()) - { - if (__t.size() == 0) - __begin_node() = __end_node(); - else - { - __begin_node() = __t.__begin_node(); - __end_node()->__left_ = __t.__end_node()->__left_; - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - size() = __t.size(); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } - } - else - { - __begin_node() = __end_node(); - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value) -{ - destroy(static_cast<__node_pointer>(__end_node()->__left_)); - __begin_node_ = __t.__begin_node_; - __pair1_.first() = __t.__pair1_.first(); - __move_assign_alloc(__t); - __pair3_ = _VSTD::move(__t.__pair3_); - if (size() == 0) - __begin_node() = __end_node(); - else - { - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - __t.__begin_node() = __t.__end_node(); - __t.__end_node()->__left_ = nullptr; - __t.size() = 0; - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) -{ - if (__node_alloc() == __t.__node_alloc()) - __move_assign(__t, true_type()); - else - { - value_comp() = _VSTD::move(__t.value_comp()); - const_iterator __e = end(); - if (size() != 0) - { - __node_pointer __cache = __detach(); -#ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - while (__cache != nullptr && __t.size() != 0) - { - __cache->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_); - __node_pointer __next = __detach(__cache); - __node_insert_multi(__cache); - __cache = __next; - } -#ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS - if (__cache != nullptr) - { - while (__cache->__parent_ != nullptr) - __cache = static_cast<__node_pointer>(__cache->__parent_); - destroy(__cache); - } - } - while (__t.size() != 0) - __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_)); - } -} - -template -__tree<_Tp, _Compare, _Allocator>& -__tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) - _NOEXCEPT_( - __node_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value && - is_nothrow_move_assignable<__node_allocator>::value) - -{ - __move_assign(__t, integral_constant()); - return *this; -} - -#endif // _LIBCPP_CXX03_LANG - -template -__tree<_Tp, _Compare, _Allocator>::~__tree() -{ - static_assert((is_copy_constructible::value), - "Comparator must be copy-constructible."); -#ifndef _LIBCPP_CXX03_LANG - static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>:: - __trigger_diagnostics()), ""); -#endif - destroy(__root()); -} - -template -void -__tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT -{ - if (__nd != nullptr) - { - destroy(static_cast<__node_pointer>(__nd->__left_)); - destroy(static_cast<__node_pointer>(__nd->__right_)); - __node_allocator& __na = __node_alloc(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_)); - __node_traits::deallocate(__na, __nd, 1); - } -} - -template -void -__tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) -#if _LIBCPP_STD_VER <= 11 - _NOEXCEPT_( - __is_nothrow_swappable::value - && (!__node_traits::propagate_on_container_swap::value || - __is_nothrow_swappable<__node_allocator>::value) - ) -#else - _NOEXCEPT_(__is_nothrow_swappable::value) -#endif -{ - using _VSTD::swap; - swap(__begin_node_, __t.__begin_node_); - swap(__pair1_.first(), __t.__pair1_.first()); - __swap_allocator(__node_alloc(), __t.__node_alloc()); - __pair3_.swap(__t.__pair3_); - if (size() == 0) - __begin_node() = __end_node(); - else - __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node()); - if (__t.size() == 0) - __t.__begin_node() = __t.__end_node(); - else - __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node()); -} - -template -void -__tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT -{ - destroy(__root()); - size() = 0; - __begin_node() = __end_node(); - __end_node()->__left_ = nullptr; -} - -// Find lower_bound place to insert -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, - const key_type& __v) -{ - __node_pointer __nd = __root(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__nd->__value_, __v)) - { - if (__nd->__right_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__right_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - else - { - if (__nd->__left_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__left_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find upper_bound place to insert -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, - const key_type& __v) -{ - __node_pointer __nd = __root(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__v, __nd->__value_)) - { - if (__nd->__left_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__left_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - else - { - if (__nd->__right_ != nullptr) - __nd = static_cast<__node_pointer>(__nd->__right_); - else - { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find leaf place to insert closest to __hint -// First check prior to __hint. -// Next check after __hint. -// Next do O(log N) search. -// Set __parent to parent of null leaf -// Return reference to null leaf -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, - __parent_pointer& __parent, - const key_type& __v) -{ - if (__hint == end() || !value_comp()(*__hint, __v)) // check before - { - // __v <= *__hint - const_iterator __prior = __hint; - if (__prior == begin() || !value_comp()(__v, *--__prior)) - { - // *prev(__hint) <= __v <= *__hint - if (__hint.__ptr_->__left_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return __parent->__left_; - } - else - { - __parent = static_cast<__parent_pointer>(__prior.__ptr_); - return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; - } - } - // __v < *prev(__hint) - return __find_leaf_high(__parent, __v); - } - // else __v > *__hint - return __find_leaf_low(__parent, __v); -} - -// Find place to insert if __v doesn't exist -// Set __parent to parent of null leaf -// Return reference to null leaf -// If __v exists, set parent to node of __v and return reference to node of __v -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, - const _Key& __v) -{ - __node_pointer __nd = __root(); - __node_base_pointer* __nd_ptr = __root_ptr(); - if (__nd != nullptr) - { - while (true) - { - if (value_comp()(__v, __nd->__value_)) - { - if (__nd->__left_ != nullptr) { - __nd_ptr = _VSTD::addressof(__nd->__left_); - __nd = static_cast<__node_pointer>(__nd->__left_); - } else { - __parent = static_cast<__parent_pointer>(__nd); - return __parent->__left_; - } - } - else if (value_comp()(__nd->__value_, __v)) - { - if (__nd->__right_ != nullptr) { - __nd_ptr = _VSTD::addressof(__nd->__right_); - __nd = static_cast<__node_pointer>(__nd->__right_); - } else { - __parent = static_cast<__parent_pointer>(__nd); - return __nd->__right_; - } - } - else - { - __parent = static_cast<__parent_pointer>(__nd); - return *__nd_ptr; - } - } - } - __parent = static_cast<__parent_pointer>(__end_node()); - return __parent->__left_; -} - -// Find place to insert if __v doesn't exist -// First check prior to __hint. -// Next check after __hint. -// Next do O(log N) search. -// Set __parent to parent of null leaf -// Return reference to null leaf -// If __v exists, set parent to node of __v and return reference to node of __v -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& -__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, - __parent_pointer& __parent, - __node_base_pointer& __dummy, - const _Key& __v) -{ - if (__hint == end() || value_comp()(__v, *__hint)) // check before - { - // __v < *__hint - const_iterator __prior = __hint; - if (__prior == begin() || value_comp()(*--__prior, __v)) - { - // *prev(__hint) < __v < *__hint - if (__hint.__ptr_->__left_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return __parent->__left_; - } - else - { - __parent = static_cast<__parent_pointer>(__prior.__ptr_); - return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_; - } - } - // __v <= *prev(__hint) - return __find_equal(__parent, __v); - } - else if (value_comp()(*__hint, __v)) // check after - { - // *__hint < __v - const_iterator __next = _VSTD::next(__hint); - if (__next == end() || value_comp()(__v, *__next)) - { - // *__hint < __v < *_VSTD::next(__hint) - if (__hint.__get_np()->__right_ == nullptr) - { - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_; - } - else - { - __parent = static_cast<__parent_pointer>(__next.__ptr_); - return __parent->__left_; - } - } - // *next(__hint) <= __v - return __find_equal(__parent, __v); - } - // else __v == *__hint - __parent = static_cast<__parent_pointer>(__hint.__ptr_); - __dummy = static_cast<__node_base_pointer>(__hint.__ptr_); - return __dummy; -} - -template -void -__tree<_Tp, _Compare, _Allocator>::__insert_node_at(__parent_pointer __parent, - __node_base_pointer& __child, - __node_base_pointer __new_node) -{ - __new_node->__left_ = nullptr; - __new_node->__right_ = nullptr; - __new_node->__parent_ = __parent; - // __new_node->__is_black_ is initialized in __tree_balance_after_insert - __child = __new_node; - if (__begin_node()->__left_ != nullptr) - __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_); - __tree_balance_after_insert(__end_node()->__left_, __child); - ++size(); -} - -#ifndef _LIBCPP_CXX03_LANG -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) -#else -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args& __args) -#endif -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __k); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node(__args); -#endif - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - - -#ifndef _LIBCPP_CXX03_LANG -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( - const_iterator __p, _Key const& __k, _Args&&... __args) -#else -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( - const_iterator __p, _Key const& __k, _Args& __args) -#endif -{ - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { -#ifndef _LIBCPP_CXX03_LANG - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node(__args); -#endif - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - } - return iterator(__r); -} - - -#ifndef _LIBCPP_CXX03_LANG - -template -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&& ...__args) -{ - static_assert(!__is_tree_value_type<_Args...>::value, - "Cannot construct from __value_type"); - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...); - __h.get_deleter().__value_constructed = true; - return __h; -} - - -template -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __h->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - __r = __h.release(); - } - return iterator(__r); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(static_cast<__node_pointer>(__h.release())); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, - _Args&&... __args) -{ - __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(static_cast<__node_pointer>(__h.release())); -} - - -#else // _LIBCPP_CXX03_LANG - -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::__construct_node(const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -#endif // _LIBCPP_CXX03_LANG - -#ifdef _LIBCPP_CXX03_LANG -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__insert_multi(const __container_value_type& __v) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__v)); - __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(__h.release()); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __container_value_type& __v) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__v)); - __node_holder __h = __construct_node(__v); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); - return iterator(__h.release()); -} -#endif - -template -pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, __nd->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - bool __inserted = false; - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - __r = __nd; - __inserted = true; - } - return pair(iterator(__r), __inserted); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p, - __node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__p, __parent, __nd->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - __r = __nd; - } - return iterator(__r); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - return iterator(__nd); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, - __node_pointer __nd) -{ - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd)); - return iterator(__nd); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) -{ - iterator __r(__ptr); - ++__r; - if (__begin_node() == __ptr) - __begin_node() = __r.__ptr_; - --size(); - __tree_remove(__end_node()->__left_, - static_cast<__node_base_pointer>(__ptr)); - return __r; -} - -#if _LIBCPP_STD_VER > 14 -template -template -_LIBCPP_INLINE_VISIBILITY -_InsertReturnType -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique( - _NodeHandle&& __nh) -{ - if (__nh.empty()) - return _InsertReturnType{end(), false, _NodeHandle()}; - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_equal(__parent, - __ptr->__value_); - if (__child != nullptr) - return _InsertReturnType{ - iterator(static_cast<__node_pointer>(__child)), - false, _VSTD::move(__nh)}; - - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return _InsertReturnType{iterator(__ptr), true, _NodeHandle()}; -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer __dummy; - __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, - __ptr->__value_); - __node_pointer __r = static_cast<__node_pointer>(__child); - if (__child == nullptr) - { - __insert_node_at(__parent, __child, - static_cast<__node_base_pointer>(__ptr)); - __r = __ptr; - __nh.__release(); - } - return iterator(__r); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) -{ - iterator __it = find(__key); - if (__it == end()) - return _NodeHandle(); - return __node_handle_extract<_NodeHandle>(__it); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -_NodeHandle -__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) -{ - __node_pointer __np = __p.__get_np(); - __remove_node_pointer(__np); - return _NodeHandle(__np, __alloc()); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf_high( - __parent, _NodeTypes::__get_key(__ptr->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return iterator(__ptr); -} - -template -template -_LIBCPP_INLINE_VISIBILITY -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi( - const_iterator __hint, _NodeHandle&& __nh) -{ - if (__nh.empty()) - return end(); - - __node_pointer __ptr = __nh.__ptr_; - __parent_pointer __parent; - __node_base_pointer& __child = __find_leaf(__hint, __parent, - _NodeTypes::__get_key(__ptr->__value_)); - __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr)); - __nh.__release(); - return iterator(__ptr); -} - -#endif // _LIBCPP_STD_VER > 14 - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) -{ - __node_pointer __np = __p.__get_np(); - iterator __r = __remove_node_pointer(__np); - __node_allocator& __na = __node_alloc(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr( - const_cast<__node_value_type&>(*__p))); - __node_traits::deallocate(__na, __np, 1); - return __r; -} - -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) -{ - while (__f != __l) - __f = erase(__f); - return iterator(__l.__ptr_); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) -{ - iterator __i = find(__k); - if (__i == end()) - return 0; - erase(__i); - return 1; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) -{ - pair __p = __equal_range_multi(__k); - size_type __r = 0; - for (; __p.first != __p.second; ++__r) - __p.first = erase(__p.first); - return __r; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) -{ - iterator __p = __lower_bound(__v, __root(), __end_node()); - if (__p != end() && !value_comp()(__v, *__p)) - return __p; - return end(); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const -{ - const_iterator __p = __lower_bound(__v, __root(), __end_node()); - if (__p != end() && !value_comp()(__v, *__p)) - return __p; - return end(); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const -{ - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return 1; - } - return 0; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::size_type -__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const -{ - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _VSTD::distance( - __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result) - ); - } - return 0; -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) -{ - while (__root != nullptr) - { - if (!value_comp()(__root->__value_, __v)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const -{ - while (__root != nullptr) - { - if (!value_comp()(__root->__value_, __v)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return const_iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) -{ - while (__root != nullptr) - { - if (value_comp()(__v, __root->__value_)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return iterator(__result); -} - -template -template -typename __tree<_Tp, _Compare, _Allocator>::const_iterator -__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, - __node_pointer __root, - __iter_pointer __result) const -{ - while (__root != nullptr) - { - if (value_comp()(__v, __root->__value_)) - { - __result = static_cast<__iter_pointer>(__root); - __root = static_cast<__node_pointer>(__root->__left_); - } - else - __root = static_cast<__node_pointer>(__root->__right_); - } - return const_iterator(__result); -} - -template -template -pair::iterator, - typename __tree<_Tp, _Compare, _Allocator>::iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(iterator(__rt), - iterator( - __rt->__right_ != nullptr ? - static_cast<__iter_pointer>(__tree_min(__rt->__right_)) - : __result)); - } - return _Pp(iterator(__result), iterator(__result)); -} - -template -template -pair::const_iterator, - typename __tree<_Tp, _Compare, _Allocator>::const_iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(const_iterator(__rt), - const_iterator( - __rt->__right_ != nullptr ? - static_cast<__iter_pointer>(__tree_min(__rt->__right_)) - : __result)); - } - return _Pp(const_iterator(__result), const_iterator(__result)); -} - -template -template -pair::iterator, - typename __tree<_Tp, _Compare, _Allocator>::iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); - } - return _Pp(iterator(__result), iterator(__result)); -} - -template -template -pair::const_iterator, - typename __tree<_Tp, _Compare, _Allocator>::const_iterator> -__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const -{ - typedef pair _Pp; - __iter_pointer __result = __end_node(); - __node_pointer __rt = __root(); - while (__rt != nullptr) - { - if (value_comp()(__k, __rt->__value_)) - { - __result = static_cast<__iter_pointer>(__rt); - __rt = static_cast<__node_pointer>(__rt->__left_); - } - else if (value_comp()(__rt->__value_, __k)) - __rt = static_cast<__node_pointer>(__rt->__right_); - else - return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)), - __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)); - } - return _Pp(const_iterator(__result), const_iterator(__result)); -} - -template -typename __tree<_Tp, _Compare, _Allocator>::__node_holder -__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT -{ - __node_pointer __np = __p.__get_np(); - if (__begin_node() == __p.__ptr_) - { - if (__np->__right_ != nullptr) - __begin_node() = static_cast<__iter_pointer>(__np->__right_); - else - __begin_node() = static_cast<__iter_pointer>(__np->__parent_); - } - --size(); - __tree_remove(__end_node()->__left_, - static_cast<__node_base_pointer>(__np)); - return __node_holder(__np, _Dp(__node_alloc(), true)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -void -swap(__tree<_Tp, _Compare, _Allocator>& __x, - __tree<_Tp, _Compare, _Allocator>& __y) - _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) -{ - __x.swap(__y); -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___TREE diff --git a/external/include/c++/v1/__tuple b/external/include/c++/v1/__tuple deleted file mode 100644 index 69d6ee9..0000000 --- a/external/include/c++/v1/__tuple +++ /dev/null @@ -1,556 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TUPLE -#define _LIBCPP___TUPLE - -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template class _LIBCPP_TEMPLATE_VIS tuple_size; - -#if !defined(_LIBCPP_CXX03_LANG) -template -using __enable_if_tuple_size_imp = _Tp; - -template -class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const _Tp, - typename enable_if::value>::type, - integral_constant)>>> - : public integral_constant::value> {}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - volatile _Tp, - typename enable_if::value>::type, - integral_constant)>>> - : public integral_constant::value> {}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const volatile _Tp, - integral_constant)>>> - : public integral_constant::value> {}; - -#else -template class _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -template class _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -template class _LIBCPP_TEMPLATE_VIS tuple_size : public tuple_size<_Tp> {}; -#endif - -template class _LIBCPP_TEMPLATE_VIS tuple_element; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> -{ -public: - typedef typename add_const::type>::type type; -}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> -{ -public: - typedef typename add_volatile::type>::type type; -}; - -template -class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> -{ -public: - typedef typename add_cv::type>::type type; -}; - -template struct __tuple_like : false_type {}; - -template struct __tuple_like : public __tuple_like<_Tp> {}; -template struct __tuple_like : public __tuple_like<_Tp> {}; -template struct __tuple_like : public __tuple_like<_Tp> {}; - -// tuple specializations - -#ifndef _LIBCPP_CXX03_LANG - -template struct __tuple_indices {}; - -template -struct __integer_sequence { - template