Mercurial > hg > CbC > CbC_llvm
changeset 238:8222e65f95b1
rm directory
author | kono |
---|---|
date | Wed, 09 Nov 2022 17:58:30 +0900 |
parents | edfff9242030 |
children | 173fe712db74 |
files | libcxx/include/__string libcxx/include/__tuple |
diffstat | 2 files changed, 0 insertions(+), 1697 deletions(-) [+] |
line wrap: on
line diff
--- a/libcxx/include/__string Wed Jul 21 11:30:30 2021 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1146 +0,0 @@ -// -*- C++ -*- -//===-------------------------- __string ----------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___STRING -#define _LIBCPP___STRING - -#include <__config> -#include <__algorithm/copy.h> -#include <__algorithm/copy_backward.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/find_first_of.h> -#include <__algorithm/find_end.h> -#include <__algorithm/min.h> -#include <__functional/hash.h> // for __murmur2_or_cityhash -#include <__iterator/iterator_traits.h> -#include <cstdio> // for EOF -#include <cstdint> // for uint_least16_t -#include <cstring> // for memcpy -#include <cwchar> // for wmemcpy -#include <type_traits> // for __libcpp_is_constant_evaluated - -#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 - -// The the extern template ABI lists are kept outside of <string> to improve the -// readability of that header. - -// The extern template ABI lists are kept outside of <string> to improve the -// readability of that header. We maintain 2 ABI lists: -// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST -// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST -// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI. -// -// For unstable, we may explicitly remove function that are external in V1, -// and add (new) external functions to better control inlining and compiler -// optimization opportunities. -// -// For stable, the ABI list should rarely change, except for adding new -// functions supporting new c++ version / API changes. Typically entries -// must never be removed from the stable list. -#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ - _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) - -#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ - _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ - _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ - _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) - - -// char_traits - -template <class _CharT> -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 _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - _LIBCPP_INLINE_VISIBILITY - static _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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 <class _CharT> -_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 <class _CharT> -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 <class _CharT> -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 nullptr; -} - -template <class _CharT> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* -char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - if (__n == 0) return __s1; - 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 <class _CharT> -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -_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 <class _CharT> -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -_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; -} - -// constexpr versions of move/copy/assign. - -template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -_CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) return __s1; - if (__s1 < __s2) { - _VSTD::copy(__s2, __s2 + __n, __s1); - } else if (__s2 < __s1) { - _VSTD::copy_backward(__s2, __s2 + __n, __s1 + __n); - } - return __s1; -} - -template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -_CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT -{ - _VSTD::copy_n(__s2, __n, __s1); - return __s1; -} - -template <class _CharT> -static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -_CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT -{ - _VSTD::fill_n(__s, __n, __a); - return __s; -} - -// char_traits<char> - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits<char> -{ - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); - } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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 __libcpp_is_constant_evaluated() - ? _VSTD::__copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); - } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)_VSTD::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<char>::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 _VSTD::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<char>::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*) _VSTD::memchr(__s, to_int_type(__a), __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -// char_traits<wchar_t> - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> -{ - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n); - } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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 __libcpp_is_constant_evaluated() - ? _VSTD::__copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); - } - static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : _VSTD::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<wchar_t>::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 _VSTD::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 -} - - -template <class _Traits> -_LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 1 - return __s ? _Traits::length(__s) : (_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, "p == nullptr", "null pointer pass to non-null argument of char_traits<...>::length")), 0); -#else - return _Traits::length(__s); -#endif -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX14 -size_t -char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_wcslen(__s); -#elif _LIBCPP_STD_VER <= 14 - return _VSTD::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<wchar_t>::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 _VSTD::wmemchr(__s, __a, __n); -#else - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -#endif -} - - -#ifndef _LIBCPP_HAS_NO_CHAR8_T - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> -{ - typedef char8_t char_type; - typedef unsigned int int_type; - typedef streamoff off_type; - typedef u8streampos pos_type; - typedef mbstate_t state_type; - - static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept - {__c1 = __c2;} - static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept - {return __c1 < __c2;} - - static constexpr - int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - - static constexpr - size_t length(const char_type* __s) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY static constexpr - const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; - - static _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__move_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); - } - - static _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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 __libcpp_is_constant_evaluated() - ? _VSTD::__copy_constexpr(__s1, __s2, __n) - : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); - } - - static _LIBCPP_CONSTEXPR_AFTER_CXX17 - char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT - { - return __libcpp_is_constant_evaluated() - ? _VSTD::__assign_constexpr(__s, __n, __a) - : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); - } - - static inline constexpr int_type not_eof(int_type __c) noexcept - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - static inline constexpr char_type to_char_type(int_type __c) noexcept - {return char_type(__c);} - static inline constexpr int_type to_int_type(char_type __c) noexcept - {return int_type(__c);} - static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept - {return __c1 == __c2;} - static inline constexpr int_type eof() noexcept - {return int_type(EOF);} -}; - -// TODO use '__builtin_strlen' if it ever supports char8_t ?? -inline constexpr -size_t -char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline constexpr -int -char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ -#if __has_feature(cxx_constexpr_string_builtins) - return __builtin_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 -} - -// TODO use '__builtin_char_memchr' if it ever supports char8_t ?? -inline constexpr -const char8_t* -char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -} - -#endif // #_LIBCPP_HAS_NO_CHAR8_T - -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - -template <> -struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> -{ - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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<char16_t>::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<char16_t>::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<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -char16_t* -char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) return __s1; - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 -char16_t* -char_traits<char16_t>::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 _LIBCPP_CONSTEXPR_AFTER_CXX17 -char16_t* -char_traits<char16_t>::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<char32_t> -{ - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - 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<char32_t>::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<char32_t>::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<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return nullptr; -} - -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -char32_t* -char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT -{ - if (__n == 0) return __s1; - 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 _LIBCPP_CONSTEXPR_AFTER_CXX17 -char32_t* -char_traits<char32_t>::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 _LIBCPP_CONSTEXPR_AFTER_CXX17 -char32_t* -char_traits<char32_t>::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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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 == nullptr) - return __npos; - return static_cast<_SizeT>(__r - __p); -} - -template <class _CharT, class _Traits> -inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT * -__search_substring(const _CharT *__first1, const _CharT *__last1, - const _CharT *__first2, const _CharT *__last2) _NOEXCEPT { - // 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 == nullptr) - 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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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) == nullptr) - return static_cast<_SizeT>(__ps - __p); - } - return __npos; -} - - -template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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) == nullptr) - return static_cast<_SizeT>(__ps - __p); - return __npos; -} - - -template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> -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<class _Ptr> -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<size_t>()(__p, (__e-__p)*sizeof(value_type)); -} - -template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> > -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
--- a/libcxx/include/__tuple Wed Jul 21 11:30:30 2021 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,551 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___TUPLE -#define _LIBCPP___TUPLE - -#include <__config> -#include <cstddef> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - - -_LIBCPP_BEGIN_NAMESPACE_STD - -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size; - -#if !defined(_LIBCPP_CXX03_LANG) -template <class _Tp, class...> -using __enable_if_tuple_size_imp = _Tp; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const _Tp, - typename enable_if<!is_volatile<_Tp>::value>::type, - integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> - : public integral_constant<size_t, tuple_size<_Tp>::value> {}; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - volatile _Tp, - typename enable_if<!is_const<_Tp>::value>::type, - integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> - : public integral_constant<size_t, tuple_size<_Tp>::value> {}; - -template <class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< - const volatile _Tp, - integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> - : public integral_constant<size_t, tuple_size<_Tp>::value> {}; - -#else -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {}; -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {}; -template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; -#endif - -template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element; - -template <size_t _Ip, class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> -{ - typedef _LIBCPP_NODEBUG_TYPE typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; -}; - -template <size_t _Ip, class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> -{ - typedef _LIBCPP_NODEBUG_TYPE typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; -}; - -template <size_t _Ip, class _Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> -{ - typedef _LIBCPP_NODEBUG_TYPE typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; -}; - -template <class _Tp> struct __tuple_like : false_type {}; - -template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {}; -template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {}; -template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {}; - -// tuple specializations - -#ifndef _LIBCPP_CXX03_LANG - -template <size_t...> struct __tuple_indices {}; - -template <class _IdxType, _IdxType... _Values> -struct __integer_sequence { - template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType> - using __convert = _ToIndexSeq<_ToIndexType, _Values...>; - - template <size_t _Sp> - using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>; -}; - -#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) -namespace __detail { - -template<typename _Tp, size_t ..._Extra> struct __repeat; -template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> { - typedef _LIBCPP_NODEBUG_TYPE __integer_sequence<_Tp, - _Np..., - sizeof...(_Np) + _Np..., - 2 * sizeof...(_Np) + _Np..., - 3 * sizeof...(_Np) + _Np..., - 4 * sizeof...(_Np) + _Np..., - 5 * sizeof...(_Np) + _Np..., - 6 * sizeof...(_Np) + _Np..., - 7 * sizeof...(_Np) + _Np..., - _Extra...> type; -}; - -template<size_t _Np> struct __parity; -template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {}; - -template<> struct __make<0> { typedef __integer_sequence<size_t> type; }; -template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; }; -template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; }; -template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; }; -template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; }; -template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; }; -template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; }; -template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; }; - -template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; }; -template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; }; -template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; }; -template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; }; -template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; -template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; -template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; -template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; - -} // namespace detail - -#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) - -#if __has_builtin(__make_integer_seq) -template <size_t _Ep, size_t _Sp> -using __make_indices_imp = - typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template - __to_tuple_indices<_Sp>; -#else -template <size_t _Ep, size_t _Sp> -using __make_indices_imp = - typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>; - -#endif - -template <size_t _Ep, size_t _Sp = 0> -struct __make_tuple_indices -{ - static_assert(_Sp <= _Ep, "__make_tuple_indices input error"); - typedef __make_indices_imp<_Ep, _Sp> type; -}; - - -template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple; - -template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {}; - -template <class ..._Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > - : public integral_constant<size_t, sizeof...(_Tp)> -{ -}; - -template <size_t _Ip, class ..._Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename tuple_element<_Ip, tuple<_Tp...> >::type& -get(tuple<_Tp...>&) _NOEXCEPT; - -template <size_t _Ip, class ..._Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const typename tuple_element<_Ip, tuple<_Tp...> >::type& -get(const tuple<_Tp...>&) _NOEXCEPT; - -template <size_t _Ip, class ..._Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename tuple_element<_Ip, tuple<_Tp...> >::type&& -get(tuple<_Tp...>&&) _NOEXCEPT; - -template <size_t _Ip, class ..._Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const typename tuple_element<_Ip, tuple<_Tp...> >::type&& -get(const tuple<_Tp...>&&) _NOEXCEPT; - -#endif // !defined(_LIBCPP_CXX03_LANG) - -// pair specializations - -template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {}; - -template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename tuple_element<_Ip, pair<_T1, _T2> >::type& -get(pair<_T1, _T2>&) _NOEXCEPT; - -template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const typename tuple_element<_Ip, pair<_T1, _T2> >::type& -get(const pair<_T1, _T2>&) _NOEXCEPT; - -#ifndef _LIBCPP_CXX03_LANG -template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename tuple_element<_Ip, pair<_T1, _T2> >::type&& -get(pair<_T1, _T2>&&) _NOEXCEPT; - -template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& -get(const pair<_T1, _T2>&&) _NOEXCEPT; -#endif - -// array specializations - -template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array; - -template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {}; - -template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -_Tp& -get(array<_Tp, _Size>&) _NOEXCEPT; - -template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const _Tp& -get(const array<_Tp, _Size>&) _NOEXCEPT; - -#ifndef _LIBCPP_CXX03_LANG -template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -_Tp&& -get(array<_Tp, _Size>&&) _NOEXCEPT; - -template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -const _Tp&& -get(const array<_Tp, _Size>&&) _NOEXCEPT; -#endif - -#ifndef _LIBCPP_CXX03_LANG - -// __tuple_types - -template <class ..._Tp> struct __tuple_types {}; - -#if !__has_builtin(__type_pack_element) - -namespace __indexer_detail { - -template <size_t _Idx, class _Tp> -struct __indexed { using type _LIBCPP_NODEBUG_TYPE = _Tp; }; - -template <class _Types, class _Indexes> struct __indexer; - -template <class ..._Types, size_t ..._Idx> -struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>> - : __indexed<_Idx, _Types>... -{}; - -template <size_t _Idx, class _Tp> -__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); - -} // namespace __indexer_detail - -template <size_t _Idx, class ..._Types> -using __type_pack_element _LIBCPP_NODEBUG_TYPE = typename decltype( - __indexer_detail::__at_index<_Idx>( - __indexer_detail::__indexer< - __tuple_types<_Types...>, - typename __make_tuple_indices<sizeof...(_Types)>::type - >{}) - )::type; -#endif - -template <size_t _Ip, class ..._Types> -struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>> -{ - static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); - typedef _LIBCPP_NODEBUG_TYPE __type_pack_element<_Ip, _Types...> type; -}; - - -template <class ..._Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > - : public integral_constant<size_t, sizeof...(_Tp)> -{ -}; - -template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {}; - -template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile> -struct __apply_cv_mf; -template <> -struct __apply_cv_mf<false, false, false> { - template <class _Tp> using __apply = _Tp; -}; -template <> -struct __apply_cv_mf<false, true, false> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp; -}; -template <> -struct __apply_cv_mf<false, false, true> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp; -}; -template <> -struct __apply_cv_mf<false, true, true> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp; -}; -template <> -struct __apply_cv_mf<true, false, false> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = _Tp&; -}; -template <> -struct __apply_cv_mf<true, true, false> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp&; -}; -template <> -struct __apply_cv_mf<true, false, true> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp&; -}; -template <> -struct __apply_cv_mf<true, true, true> { - template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp&; -}; -template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type> -using __apply_cv_t _LIBCPP_NODEBUG_TYPE = __apply_cv_mf< - is_lvalue_reference<_Tp>::value, - is_const<_RawTp>::value, - is_volatile<_RawTp>::value>; - -// __make_tuple_types - -// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a -// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep). -// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a -// lvalue_reference type, then __tuple_types<_Types&...> is the result. - -template <class _TupleTypes, class _TupleIndices> -struct __make_tuple_types_flat; - -template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx> -struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { - // Specialization for pair, tuple, and __tuple_types - template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>> - using __apply_quals _LIBCPP_NODEBUG_TYPE = __tuple_types< - typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>... - >; -}; - -template <class _Vt, size_t _Np, size_t ..._Idx> -struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { - template <size_t> - using __value_type = _Vt; - template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>> - using __apply_quals = __tuple_types< - typename _ApplyFn::template __apply<__value_type<_Idx>>... - >; -}; - -template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, - size_t _Sp = 0, - bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)> -struct __make_tuple_types -{ - static_assert(_Sp <= _Ep, "__make_tuple_types input error"); - using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type; - using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; - using type = typename _Maker::template __apply_quals<_Tp>; -}; - -template <class ..._Types, size_t _Ep> -struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { - typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type; -}; - -template <class ..._Types, size_t _Ep> -struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { - typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type; -}; - -template <bool ..._Preds> -struct __all_dummy; - -template <bool ..._Pred> -using __all = _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>; - -struct __tuple_sfinae_base { - template <template <class, class...> class _Trait, - class ..._LArgs, class ..._RArgs> - static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>) - -> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>; - template <template <class...> class> - static auto __do_test(...) -> false_type; - - template <class _FromArgs, class _ToArgs> - using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); - template <class _FromArgs, class _ToArgs> - using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{})); - template <class _FromArgs, class _ToArgs> - using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{})); -}; - -// __tuple_convertible - -template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, - bool = __tuple_like<_Up>::value> -struct __tuple_convertible - : public false_type {}; - -template <class _Tp, class _Up> -struct __tuple_convertible<_Tp, _Up, true, true> - : public __tuple_sfinae_base::__convertible< - typename __make_tuple_types<_Tp>::type - , typename __make_tuple_types<_Up>::type - > -{}; - -// __tuple_constructible - -template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, - bool = __tuple_like<_Up>::value> -struct __tuple_constructible - : public false_type {}; - -template <class _Tp, class _Up> -struct __tuple_constructible<_Tp, _Up, true, true> - : public __tuple_sfinae_base::__constructible< - typename __make_tuple_types<_Tp>::type - , typename __make_tuple_types<_Up>::type - > -{}; - -// __tuple_assignable - -template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, - bool = __tuple_like<_Up>::value> -struct __tuple_assignable - : public false_type {}; - -template <class _Tp, class _Up> -struct __tuple_assignable<_Tp, _Up, true, true> - : public __tuple_sfinae_base::__assignable< - typename __make_tuple_types<_Tp>::type - , typename __make_tuple_types<_Up&>::type - > -{}; - - -template <size_t _Ip, class ..._Tp> -struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > -{ - typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <size_t _Ip, class ..._Tp> -using tuple_element_t _LIBCPP_NODEBUG_TYPE = typename tuple_element <_Ip, _Tp...>::type; -#endif - -template <bool _IsTuple, class _SizeTrait, size_t _Expected> -struct __tuple_like_with_size_imp : false_type {}; - -template <class _SizeTrait, size_t _Expected> -struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected> - : integral_constant<bool, _SizeTrait::value == _Expected> {}; - -template <class _Tuple, size_t _ExpectedSize, - class _RawTuple = typename __uncvref<_Tuple>::type> -using __tuple_like_with_size _LIBCPP_NODEBUG_TYPE = __tuple_like_with_size_imp< - __tuple_like<_RawTuple>::value, - tuple_size<_RawTuple>, _ExpectedSize - >; - -struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail { - - static constexpr bool __enable_explicit_default() { return false; } - static constexpr bool __enable_implicit_default() { return false; } - template <class ...> - static constexpr bool __enable_explicit() { return false; } - template <class ...> - static constexpr bool __enable_implicit() { return false; } - template <class ...> - static constexpr bool __enable_assign() { return false; } -}; -#endif // !defined(_LIBCPP_CXX03_LANG) - -#if _LIBCPP_STD_VER > 14 - -template <bool _CanCopy, bool _CanMove> -struct __sfinae_ctor_base {}; -template <> -struct __sfinae_ctor_base<false, false> { - __sfinae_ctor_base() = default; - __sfinae_ctor_base(__sfinae_ctor_base const&) = delete; - __sfinae_ctor_base(__sfinae_ctor_base &&) = delete; - __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default; - __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default; -}; -template <> -struct __sfinae_ctor_base<true, false> { - __sfinae_ctor_base() = default; - __sfinae_ctor_base(__sfinae_ctor_base const&) = default; - __sfinae_ctor_base(__sfinae_ctor_base &&) = delete; - __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default; - __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default; -}; -template <> -struct __sfinae_ctor_base<false, true> { - __sfinae_ctor_base() = default; - __sfinae_ctor_base(__sfinae_ctor_base const&) = delete; - __sfinae_ctor_base(__sfinae_ctor_base &&) = default; - __sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default; - __sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default; -}; - -template <bool _CanCopy, bool _CanMove> -struct __sfinae_assign_base {}; -template <> -struct __sfinae_assign_base<false, false> { - __sfinae_assign_base() = default; - __sfinae_assign_base(__sfinae_assign_base const&) = default; - __sfinae_assign_base(__sfinae_assign_base &&) = default; - __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete; - __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete; -}; -template <> -struct __sfinae_assign_base<true, false> { - __sfinae_assign_base() = default; - __sfinae_assign_base(__sfinae_assign_base const&) = default; - __sfinae_assign_base(__sfinae_assign_base &&) = default; - __sfinae_assign_base& operator=(__sfinae_assign_base const&) = default; - __sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete; -}; -template <> -struct __sfinae_assign_base<false, true> { - __sfinae_assign_base() = default; - __sfinae_assign_base(__sfinae_assign_base const&) = default; - __sfinae_assign_base(__sfinae_assign_base &&) = default; - __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete; - __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default; -}; -#endif // _LIBCPP_STD_VER > 14 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___TUPLE