diff --git a/libcxx/.clang-format b/libcxx/.clang-format --- a/libcxx/.clang-format +++ b/libcxx/.clang-format @@ -1,5 +1,76 @@ BasedOnStyle: LLVM +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveBitFields: Consecutive +AlignEscapedNewlines: Right +AlignOperands: AlignAfterOperator +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortFunctionsOnASingleLine: true +AllowShortLambdasOnASingleLine: All +AttributeMacros: ['_LIBCPP_HIDE_FROM_ABI', + '_LIBCPP_CONSTEXPR', + '_LIBCPP_CONSTEXPR_AFTER_CXX11', + '_LIBCPP_CONSTEXPR_AFTER_CXX14', + '_LIBCPP_CONSTEXPR_AFTER_CXX17', + '_LIBCPP_CONSTEXPR_AFTER_CXX20', + '_LIBCPP_ALIGNOF', + '_ALIGNAS_TYPE', + '_ALIGNAS', + '_LIBCPP_NORETURN', + '_LIBCPP_ALWAYS_INLINE', + '_LIBCPP_DISABLE_EXTENTSION_WARNING', + '_LIBCPP_HIDDEN', + '_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS', + '_LIBCPP_FUNC_VIS', + '_LIBCPP_TYPE_VIS', + '_LIBCPP_TEMPLATE_VIS', + '_LIBCPP_TEMPLATE_DATA_VIS', + '_LIBCPP_EXPORTED_FROM_ABI', + '_LIBCPP_OVERRIDABLE_FUNC_VIS', + '_LIBCPP_EXCEPTION_ABI', + '_LIBCPP_ENUM_VIS', + '_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS', + '_LIBCPP_INTERNAL_LINKAGE', + '_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION', + '_LIBCPP_HIDE_FROM_ABI_AFTER_V1', + '_LIBCPP_INLINE_VISIBILITY', + '_LIBCPP_CONSTEVAL', + '_LIBCPP_NOALIAS', + '_LIBCPP_USING_IF_EXISTS', + '_LIBCPP_DEPRECATED', + '_LIBCPP_DEPRECATED_IN_CXX11', + '_LIBCPP_DEPRECATED_IN_CXX14', + '_LIBCPP_DEPRECATED_IN_CXX17', + '_LIBCPP_DEPRECATED_IN_CXX20', + '_LIBCPP_NODISCARD', + '_LIBCPP_NODISCARD_EXT', + '_LIBCPP_NO_DESTROY', + '_LIBCPP_WEAK', + '_LIBCPP_CONSTINIT', + '_LIBCPP_FALLTHROUGH', + '_LIBCPP_STANDALONE_DEBUG', + '_LIBCPP_NO_UNIQUE_ADDRESS', + ] +BinPackArguments: false +BinPackParameters: false +BreakBeforeBinaryOperators: All +BreakBeforeConceptDeclarations: true +BreakInheritanceList: BeforeColon +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +IndentWrappedFunctionNames: false +IndentRequires: true +InsertTrailingCommas: Wrapped +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +PackConstructorInitializers: NextLine + +PenaltyIndentedWhitespace: 61 + --- Language: Cpp Standard: c++20 diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -24,293 +24,293 @@ #ifdef __cplusplus -#define _LIBCPP_VERSION 15000 +# define _LIBCPP_VERSION 15000 -#if __STDC_HOSTED__ == 0 -# define _LIBCPP_FREESTANDING -#endif +# if __STDC_HOSTED__ == 0 +# define _LIBCPP_FREESTANDING +# 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 -# elif __cplusplus <= 202002L -# define _LIBCPP_STD_VER 20 +# 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 +# elif __cplusplus <= 202002L +# define _LIBCPP_STD_VER 20 +# else +# define _LIBCPP_STD_VER 22 // current year, or date of c++2b 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 -# define _LIBCPP_STD_VER 22 // current year, or date of c++2b 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 - // ... add new file formats here ... -#endif +// ... add new file formats here ... +# endif -#if _LIBCPP_ABI_VERSION >= 2 +# if _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 +# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT // Fix deque iterator type in order to support incomplete types. -# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +# 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 +# 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 +# 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 +# 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 // 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 +# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION // Override the default return value of exception::what() for // bad_function_call::what() with a string that is specific to // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break // because it changes the vtable layout of bad_function_call. -# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE +# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE // Enable optimized version of __do_get_(un)signed which avoids redundant copies. -# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET +# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET // In C++20 and later, don't derive std::plus from std::binary_function, // nor std::negate from std::unary_function. -# define _LIBCPP_ABI_NO_BINDER_BASES +# define _LIBCPP_ABI_NO_BINDER_BASES // Give reverse_iterator one data member of type T, not two. // Also, in C++17 and later, don't derive iterator types from std::iterator. -# define _LIBCPP_ABI_NO_ITERATOR_BASES +# define _LIBCPP_ABI_NO_ITERATOR_BASES // Use the smallest possible integer type to represent the index of the variant. // Previously libc++ used "unsigned int" exclusively. -# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION +# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION // Unstable attempt to provide a more optimized std::function -# define _LIBCPP_ABI_OPTIMIZED_FUNCTION +# define _LIBCPP_ABI_OPTIMIZED_FUNCTION // All the regex constants must be distinct and nonzero. -# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO +# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO // Use raw pointers, not wrapped ones, for std::span's iterator type. -# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS +# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS // Re-worked external template instantiations for std::string with a focus on // performance and fast-path inlining. -# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION +# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION // Enable clang::trivial_abi on std::unique_ptr. -# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI +# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr -# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI +# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI // std::random_device holds some state when it uses an implementation that gets // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this // implementation to another one on a platform that has already shipped // std::random_device, one needs to retain the same object layout to remain ABI // compatible. This switch removes these workarounds for platforms that don't care // about ABI compatibility. -# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT +# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT // Remove basic_string common base -# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON +# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON // Remove vector base class -# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON +# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON // According to the Standard, `bitset::operator[] const` returns bool -# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL -#elif _LIBCPP_ABI_VERSION == 1 -# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) +# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL +# 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 +# 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 +# if defined(__FreeBSD__) +# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR +# endif # endif -#endif -#if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 +# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 // Enable additional explicit instantiations of iostreams components. This // reduces the number of weak definitions generated in programs that use // iostreams by providing a single strong definition in the shared library. -# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 // 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 -#endif +# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION +# endif -#define _LIBCPP_TOSTRING2(x) #x -#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) +# define _LIBCPP_TOSTRING2(x) # x +# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) -#if __cplusplus < 201103L -#define _LIBCPP_CXX03_LANG -#endif +# if __cplusplus < 201103L +# define _LIBCPP_CXX03_LANG +# endif -#ifndef __has_attribute -#define __has_attribute(__x) 0 -#endif +# ifndef __has_attribute +# define __has_attribute(__x) 0 +# endif -#ifndef __has_builtin -#define __has_builtin(__x) 0 -#endif +# ifndef __has_builtin +# define __has_builtin(__x) 0 +# endif -#ifndef __has_extension -#define __has_extension(__x) 0 -#endif +# ifndef __has_extension +# define __has_extension(__x) 0 +# endif -#ifndef __has_feature -#define __has_feature(__x) 0 -#endif +# ifndef __has_feature +# define __has_feature(__x) 0 +# endif -#ifndef __has_cpp_attribute -#define __has_cpp_attribute(__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 __is_identifier +# define __is_identifier(__x) 1 +# endif -#ifndef __has_declspec_attribute -#define __has_declspec_attribute(__x) 0 -#endif +# ifndef __has_declspec_attribute +# define __has_declspec_attribute(__x) 0 +# endif -#define __has_keyword(__x) !(__is_identifier(__x)) +# define __has_keyword(__x) !(__is_identifier(__x)) -#ifndef __has_include -#define __has_include(...) 0 -#endif +# ifndef __has_include +# define __has_include(...) 0 +# endif -#if defined(__apple_build_version__) -# define _LIBCPP_COMPILER_CLANG_BASED -# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) -#elif defined(__clang__) -# define _LIBCPP_COMPILER_CLANG_BASED -# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) -#elif defined(__GNUC__) -# define _LIBCPP_COMPILER_GCC -#elif defined(_MSC_VER) -# define _LIBCPP_COMPILER_MSVC -#elif defined(__IBMCPP__) -# define _LIBCPP_COMPILER_IBM -#endif +# if defined(__apple_build_version__) +# define _LIBCPP_COMPILER_CLANG_BASED +# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) +# elif defined(__clang__) +# define _LIBCPP_COMPILER_CLANG_BASED +# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) +# elif defined(__GNUC__) +# define _LIBCPP_COMPILER_GCC +# elif defined(_MSC_VER) +# define _LIBCPP_COMPILER_MSVC +# elif defined(__IBMCPP__) +# define _LIBCPP_COMPILER_IBM +# endif -#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L -#error "libc++ does not support using GCC with C++03. Please enable C++11" -#endif +# if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L +# error "libc++ does not support using GCC with C++03. Please enable C++11" +# 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) +# 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 -# define _LIBCPP_ABI_ITANIUM +# if defined(_WIN32) && defined(_MSC_VER) +# define _LIBCPP_ABI_MICROSOFT +# else +# define _LIBCPP_ABI_ITANIUM +# endif # endif -#endif -#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) -# define _LIBCPP_ABI_VCRUNTIME -#endif +# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) +# define _LIBCPP_ABI_VCRUNTIME +# 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__) - -#if defined(__MVS__) -# include // for __NATIVE_ASCII_F -#endif - -#ifdef __LITTLE_ENDIAN__ -# if __LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# endif // __LITTLE_ENDIAN__ -#endif // __LITTLE_ENDIAN__ +# 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 __BIG_ENDIAN__ -# if __BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BIG_ENDIAN__ -#endif // __BIG_ENDIAN__ +# if defined(__MVS__) +# include // for __NATIVE_ASCII_F +# endif -#ifdef __BYTE_ORDER__ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# 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 +# include +# if _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_LITTLE_ENDIAN +# else // _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_BIG_ENDIAN +# endif // _BYTE_ORDER == _LITTLE_ENDIAN +# endif // __FreeBSD__ + +# if defined(__NetBSD__) || defined(__OpenBSD__) +# include +# if _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_LITTLE_ENDIAN +# else // _BYTE_ORDER == _LITTLE_ENDIAN +# define _LIBCPP_BIG_ENDIAN +# endif // _BYTE_ORDER == _LITTLE_ENDIAN +# endif // defined(__NetBSD__) || defined(__OpenBSD__) + +# if defined(_WIN32) +# define _LIBCPP_WIN32API # 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 -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -#endif // __FreeBSD__ - -#if defined(__NetBSD__) || defined(__OpenBSD__) -# include -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -#endif // defined(__NetBSD__) || defined(__OpenBSD__) - -#if defined(_WIN32) -# define _LIBCPP_WIN32API -# define _LIBCPP_LITTLE_ENDIAN -# define _LIBCPP_SHORT_WCHAR 1 +# define _LIBCPP_SHORT_WCHAR 1 // Both MinGW and native MSVC provide a "MSVC"-like environment -# define _LIBCPP_MSVCRT_LIKE +# 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 -#endif // defined(_WIN32) +# 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 +# endif // defined(_WIN32) -#ifdef __sun__ -# include -# ifdef _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else -# define _LIBCPP_BIG_ENDIAN -# endif -#endif // __sun__ +# ifdef __sun__ +# include +# ifdef _LITTLE_ENDIAN +# define _LIBCPP_LITTLE_ENDIAN +# else +# define _LIBCPP_BIG_ENDIAN +# endif +# endif // __sun__ -#if defined(_AIX) && !defined(__64BIT__) - // The size of wchar is 2 byte on 32-bit mode on AIX. -# define _LIBCPP_SHORT_WCHAR 1 -#endif +# if defined(_AIX) && !defined(__64BIT__) +// The size of wchar is 2 byte on 32-bit mode on AIX. +# define _LIBCPP_SHORT_WCHAR 1 +# endif // Libc++ supports various implementations of std::random_device. // @@ -350,443 +350,453 @@ // Use rand_s(), for use on Windows. // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ - defined(__OpenBSD__) || defined(__DragonFly__) -# define _LIBCPP_USING_ARC4_RANDOM -#elif defined(__wasi__) -# define _LIBCPP_USING_GETENTROPY -#elif defined(__Fuchsia__) -# define _LIBCPP_USING_FUCHSIA_CPRNG -#elif defined(__native_client__) -# 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 +# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \ + || defined(__DragonFly__) +# define _LIBCPP_USING_ARC4_RANDOM +# elif defined(__wasi__) +# define _LIBCPP_USING_GETENTROPY +# elif defined(__Fuchsia__) +# define _LIBCPP_USING_FUCHSIA_CPRNG +# elif defined(__native_client__) +# define _LIBCPP_USING_NACL_RANDOM +# elif defined(_LIBCPP_WIN32API) +# define _LIBCPP_USING_WIN32_RANDOM +# else +# define _LIBCPP_USING_DEV_RANDOM # 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 !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) -#ifndef _LIBCPP_CXX03_LANG -# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) -#elif defined(_LIBCPP_COMPILER_CLANG_BASED) -# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) -#else -# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" -#endif +# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) +# else +# define _LIBCPP_NO_CFI +# endif -#define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) +# ifndef _LIBCPP_CXX03_LANG +# define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) +# elif defined(_LIBCPP_COMPILER_CLANG_BASED) +# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) +# else +# error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" +# endif -#if defined(_LIBCPP_COMPILER_CLANG_BASED) +# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) -#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) -# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -#endif +# if defined(_LIBCPP_COMPILER_CLANG_BASED) -#if __has_feature(cxx_alignas) -# define _ALIGNAS_TYPE(x) alignas(x) -# define _ALIGNAS(x) alignas(x) -#else -# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -# define _ALIGNAS(x) __attribute__((__aligned__(x))) -#endif +# if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) +# 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__(_LIBCPP_ALIGNOF(x)))) +# define _ALIGNAS(x) __attribute__((__aligned__(x))) +# endif -#if __cplusplus < 201103L +# if __cplusplus < 201103L typedef __char16_t char16_t; typedef __char32_t char32_t; -#endif +# endif -#if !__has_feature(cxx_exceptions) -# define _LIBCPP_NO_EXCEPTIONS -#endif +# if !__has_feature(cxx_exceptions) +# define _LIBCPP_NO_EXCEPTIONS +# endif -#if __has_feature(cxx_attributes) -# define _LIBCPP_NORETURN [[noreturn]] -#else -# define _LIBCPP_NORETURN __attribute__ ((noreturn)) -#endif +# if __has_feature(cxx_attributes) +# define _LIBCPP_NORETURN [[noreturn]] +# else +# define _LIBCPP_NORETURN __attribute__((noreturn)) +# endif -#ifdef _LIBCPP_CXX03_LANG -# define nullptr __nullptr -#endif +# ifdef _LIBCPP_CXX03_LANG +# define nullptr __nullptr +# endif // Objective-C++ features (opt-in) -#if __has_feature(objc_arc) -#define _LIBCPP_HAS_OBJC_ARC -#endif +# 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(objc_arc_weak) +# define _LIBCPP_HAS_OBJC_ARC_WEAK +# endif -#if __has_extension(blocks) -# define _LIBCPP_HAS_EXTENSION_BLOCKS -#endif +# if __has_extension(blocks) +# define _LIBCPP_HAS_EXTENSION_BLOCKS +# endif -#if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) -# define _LIBCPP_HAS_BLOCKS_RUNTIME -#endif +# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) +# define _LIBCPP_HAS_BLOCKS_RUNTIME +# endif -#if !(__has_feature(cxx_noexcept)) -#define _LIBCPP_HAS_NO_NOEXCEPT -#endif +# if !(__has_feature(cxx_noexcept)) +# define _LIBCPP_HAS_NO_NOEXCEPT +# endif -#if !__has_feature(address_sanitizer) -#define _LIBCPP_HAS_NO_ASAN -#endif +# if !__has_feature(address_sanitizer) +# define _LIBCPP_HAS_NO_ASAN +# endif // Allow for build-time disabling of unsigned integer sanitization -#if __has_attribute(no_sanitize) -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) -#endif +# if __has_attribute(no_sanitize) +# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) +# endif -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) -#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ -#elif defined(_LIBCPP_COMPILER_GCC) +# elif defined(_LIBCPP_COMPILER_GCC) -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) +# define _ALIGNAS(x) __attribute__((__aligned__(x))) +# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -#define _LIBCPP_NORETURN __attribute__((noreturn)) +# define _LIBCPP_NORETURN __attribute__((noreturn)) -#if !defined(__EXCEPTIONS) -# define _LIBCPP_NO_EXCEPTIONS -#endif +# if !defined(__EXCEPTIONS) +# define _LIBCPP_NO_EXCEPTIONS +# endif -#if !defined(__SANITIZE_ADDRESS__) -#define _LIBCPP_HAS_NO_ASAN -#endif +# if !defined(__SANITIZE_ADDRESS__) +# define _LIBCPP_HAS_NO_ASAN +# endif -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) -#define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ +# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ -#elif defined(_LIBCPP_COMPILER_MSVC) +# elif defined(_LIBCPP_COMPILER_MSVC) -#define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " 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 +# if _MSC_VER < 1900 +# error "MSVC versions prior to Visual Studio 2015 are not supported" +# endif -#define __alignof__ __alignof -#define _LIBCPP_NORETURN __declspec(noreturn) -#define _ALIGNAS(x) __declspec(align(x)) -#define _ALIGNAS_TYPE(x) alignas(x) +# define __alignof__ __alignof +# define _LIBCPP_NORETURN __declspec(noreturn) +# define _ALIGNAS(x) __declspec(align(x)) +# define _ALIGNAS_TYPE(x) alignas(x) -#define _LIBCPP_WEAK +# define _LIBCPP_WEAK -#define _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_HAS_NO_ASAN -#define _LIBCPP_ALWAYS_INLINE __forceinline +# define _LIBCPP_ALWAYS_INLINE __forceinline -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# define _LIBCPP_HAS_NO_VECTOR_EXTENSION -#define _LIBCPP_DISABLE_EXTENSION_WARNING +# define _LIBCPP_DISABLE_EXTENSION_WARNING -#elif defined(_LIBCPP_COMPILER_IBM) +# elif defined(_LIBCPP_COMPILER_IBM) -#define _ALIGNAS(x) __attribute__((__aligned__(x))) -#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) -#define _ATTRIBUTE(x) __attribute__((x)) -#define _LIBCPP_NORETURN __attribute__((noreturn)) +# define _ALIGNAS(x) __attribute__((__aligned__(x))) +# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) +# define _ATTRIBUTE(x) __attribute__((x)) +# define _LIBCPP_NORETURN __attribute__((noreturn)) -#define _LIBCPP_HAS_NO_UNICODE_CHARS +# define _LIBCPP_HAS_NO_UNICODE_CHARS -#if defined(_AIX) -#define __MULTILOCALE_API -#endif +# if defined(_AIX) +# define __MULTILOCALE_API +# endif -#define _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_HAS_NO_ASAN -#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) -#define _LIBCPP_HAS_NO_VECTOR_EXTENSION +# define _LIBCPP_HAS_NO_VECTOR_EXTENSION -#define _LIBCPP_DISABLE_EXTENSION_WARNING +# define _LIBCPP_DISABLE_EXTENSION_WARNING -#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] +# endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] -#if defined(_LIBCPP_OBJECT_FORMAT_COFF) +# if defined(_LIBCPP_OBJECT_FORMAT_COFF) -#ifdef _DLL -# define _LIBCPP_CRT_FUNC __declspec(dllimport) -#else -# define _LIBCPP_CRT_FUNC -#endif +# 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 -# define _LIBCPP_EXPORTED_FROM_ABI -#elif defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_DLL_VIS __declspec(dllexport) -# if defined(__MINGW32__) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# else -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS -# endif -# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS -# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) -#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 -# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) -#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 +# define _LIBCPP_EXPORTED_FROM_ABI +# elif defined(_LIBCPP_BUILDING_LIBRARY) +# define _LIBCPP_DLL_VIS __declspec(dllexport) +# if defined(__MINGW32__) +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS +# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS +# else +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS +# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS +# endif +# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS +# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) +# 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 +# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) +# endif -#define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS -#define _LIBCPP_FUNC_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_TEMPLATE_DATA_VIS -#define _LIBCPP_ENUM_VIS +# define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS +# define _LIBCPP_FUNC_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_TEMPLATE_DATA_VIS +# define _LIBCPP_ENUM_VIS -#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) +# 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 +# ifndef _LIBCPP_HIDDEN +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_HIDDEN __attribute__((__visibility__("hidden"))) +# else +# define _LIBCPP_HIDDEN +# endif # endif -#endif -#ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# 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 +# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN +# else +# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS +# endif # endif -#endif -#ifndef _LIBCPP_FUNC_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_FUNC_VIS +# ifndef _LIBCPP_FUNC_VIS +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_FUNC_VIS __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_FUNC_VIS +# endif # endif -#endif -#ifndef _LIBCPP_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_TYPE_VIS +# ifndef _LIBCPP_TYPE_VIS +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_TYPE_VIS __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_TYPE_VIS +# endif # 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"))) +# 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 __attribute__ ((__visibility__("default"))) +# define _LIBCPP_TEMPLATE_VIS # endif -# else -# define _LIBCPP_TEMPLATE_VIS # endif -#endif -#ifndef _LIBCPP_TEMPLATE_DATA_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_TEMPLATE_DATA_VIS +# ifndef _LIBCPP_TEMPLATE_DATA_VIS +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_TEMPLATE_DATA_VIS +# endif # endif -#endif -#ifndef _LIBCPP_EXPORTED_FROM_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_EXPORTED_FROM_ABI +# ifndef _LIBCPP_EXPORTED_FROM_ABI +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_EXPORTED_FROM_ABI +# endif # endif -#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 +# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS +# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS # 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 +# ifndef _LIBCPP_EXCEPTION_ABI +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_EXCEPTION_ABI __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_EXCEPTION_ABI +# endif # endif -#endif -#ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) -# else -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS +# 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 -#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_EXTERN_TEMPLATE_TYPE_VIS +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__((__visibility__("default"))) +# else +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS +# endif +# endif -#if __has_attribute(exclude_from_explicit_instantiation) -# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) -#else - // Try to approximate the effect of exclude_from_explicit_instantiation - // (which is that entities are not assumed to be provided by explicit - // template instantiations in the dylib) by always inlining those entities. -# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE -#endif +# ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS +# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS +# 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 +# if __has_attribute(internal_linkage) +# define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage)) # else -# define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 +# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE # endif -#endif -#ifndef _LIBCPP_HIDE_FROM_ABI -# if _LIBCPP_HIDE_FROM_ABI_PER_TU -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE +# if __has_attribute(exclude_from_explicit_instantiation) +# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) # else -# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION +// Try to approximate the effect of exclude_from_explicit_instantiation +// (which is that entities are not assumed to be provided by explicit +// template instantiations in the dylib) by always inlining those entities. +# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _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 +# 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_EXCLUDE_FROM_EXPLICIT_INSTANTIATION +# 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 +# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI # 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_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. -#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { -#define _LIBCPP_END_NAMESPACE_STD } } -#define _VSTD std +# define _LIBCPP_BEGIN_NAMESPACE_STD \ + namespace std { \ + inline namespace _LIBCPP_ABI_NAMESPACE { +# define _LIBCPP_END_NAMESPACE_STD \ + } \ + } +# define _VSTD std _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER > 14 -#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 +# if _LIBCPP_STD_VER > 14 +# 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 _LIBCPP_END_NAMESPACE_FILESYSTEM \ + _LIBCPP_END_NAMESPACE_STD \ + } \ + } -#define _VSTD_FS std::__fs::filesystem +# define _VSTD_FS std::__fs::filesystem -#if __has_attribute(__enable_if__) -# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) -#endif +# if __has_attribute(__enable_if__) +# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) +# endif -#ifndef _LIBCPP_HAS_NO_NOEXCEPT -# define _NOEXCEPT noexcept -# define _NOEXCEPT_(x) noexcept(x) -#else -# define _NOEXCEPT throw() -# define _NOEXCEPT_(x) -#endif +# ifndef _LIBCPP_HAS_NO_NOEXCEPT +# define _NOEXCEPT noexcept +# define _NOEXCEPT_(x) noexcept(x) +# else +# define _NOEXCEPT throw() +# define _NOEXCEPT_(x) +# endif -#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS -typedef unsigned short char16_t; -typedef unsigned int char32_t; -#endif +# ifdef _LIBCPP_HAS_NO_UNICODE_CHARS + typedef unsigned short char16_t; +typedef unsigned int char32_t; +# endif -#ifndef __SIZEOF_INT128__ -#define _LIBCPP_HAS_NO_INT128 -#endif +# ifndef __SIZEOF_INT128__ +# define _LIBCPP_HAS_NO_INT128 +# endif -#ifdef _LIBCPP_CXX03_LANG -# define static_assert(...) _Static_assert(__VA_ARGS__) -# define decltype(...) __decltype(__VA_ARGS__) -#endif // _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG +# define static_assert(...) _Static_assert(__VA_ARGS__) +# define decltype(...) __decltype(__VA_ARGS__) +# endif // _LIBCPP_CXX03_LANG -#ifdef _LIBCPP_CXX03_LANG -# define _LIBCPP_CONSTEXPR -#else -# define _LIBCPP_CONSTEXPR constexpr -#endif +# ifdef _LIBCPP_CXX03_LANG +# define _LIBCPP_CONSTEXPR +# else +# define _LIBCPP_CONSTEXPR constexpr +# endif -#ifndef __cpp_consteval -# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR -#else -# define _LIBCPP_CONSTEVAL consteval -#endif +# ifndef __cpp_consteval +# define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR +# else +# define _LIBCPP_CONSTEVAL consteval +# endif -#ifdef __GNUC__ -# define _LIBCPP_NOALIAS __attribute__((__malloc__)) -#else -# define _LIBCPP_NOALIAS -#endif +# ifdef __GNUC__ +# define _LIBCPP_NOALIAS __attribute__((__malloc__)) +# else +# define _LIBCPP_NOALIAS +# endif -#if __has_attribute(using_if_exists) -# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) -#else -# define _LIBCPP_USING_IF_EXISTS -#endif +# if __has_attribute(using_if_exists) +# define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) +# else +# define _LIBCPP_USING_IF_EXISTS +# endif -#ifdef _LIBCPP_CXX03_LANG -# 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_CXX03_LANG -# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x -# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) -#endif // _LIBCPP_CXX03_LANG +# ifdef _LIBCPP_CXX03_LANG +# 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_CXX03_LANG +# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x +# define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) +# endif // _LIBCPP_CXX03_LANG // _LIBCPP_DEBUG potential values: // - undefined: No assertions. This is the default. @@ -831,243 +841,229 @@ // depends on it (several instances in ). Those special declarations // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled // even when the debug mode is enabled. -#if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) -# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ -# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */ -#elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY) -# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ -# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; -#else -# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; -# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; -#endif +# if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) +# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ +# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */ +# elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY) +# define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ +# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; +# else +# define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +# define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; +# endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ - defined(__sun__) || defined(__NetBSD__) -#define _LIBCPP_LOCALE__L_EXTENSIONS 1 -#endif +# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) \ + || defined(__NetBSD__) +# define _LIBCPP_LOCALE__L_EXTENSIONS 1 +# endif -#ifdef __FreeBSD__ -#define _DECLARE_C99_LDBL_MATH 1 -#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_LIBRARY_ALIGNED_ALLOCATION -#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) - // We're deferring to Microsoft's STL to provide aligned new et al. We don't - // have it unless the language feature test macro is defined. -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -#elif defined(__MVS__) -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION -#endif +# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 +# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) +// We're deferring to Microsoft's STL to provide aligned new et al. We don't +// have it unless the language feature test macro is defined. +# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# elif defined(__MVS__) +# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# endif -#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ - (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -#endif +# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!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__) +# define _LIBCPP_HAS_DEFAULTRUNELOCALE +# endif -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) -#define _LIBCPP_WCTYPE_IS_MASK -#endif +# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) +# define _LIBCPP_WCTYPE_IS_MASK +# endif -#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) -#define _LIBCPP_HAS_NO_CHAR8_T -#endif +# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) +# define _LIBCPP_HAS_NO_CHAR8_T +# endif // Deprecation macros. // // Deprecations warnings are always enabled, except when users explicitly opt-out // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. -#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) -# if __has_attribute(deprecated) -# define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) -# elif _LIBCPP_STD_VER > 11 -# define _LIBCPP_DEPRECATED [[deprecated]] +# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) +# if __has_attribute(deprecated) +# define _LIBCPP_DEPRECATED __attribute__((deprecated)) +# elif _LIBCPP_STD_VER > 11 +# define _LIBCPP_DEPRECATED [[deprecated]] +# else +# define _LIBCPP_DEPRECATED +# endif # else # define _LIBCPP_DEPRECATED # endif -#else -# define _LIBCPP_DEPRECATED -#endif -#if !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX11 -#endif +# if !defined(_LIBCPP_CXX03_LANG) +# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED +# else +# define _LIBCPP_DEPRECATED_IN_CXX11 +# endif -#if _LIBCPP_STD_VER > 11 -# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX14 -#endif +# if _LIBCPP_STD_VER > 11 +# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED +# else +# define _LIBCPP_DEPRECATED_IN_CXX14 +# endif -#if _LIBCPP_STD_VER > 14 -# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX17 -#endif +# if _LIBCPP_STD_VER > 14 +# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED +# else +# define _LIBCPP_DEPRECATED_IN_CXX17 +# endif -#if _LIBCPP_STD_VER > 17 -# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_IN_CXX20 -#endif +# if _LIBCPP_STD_VER > 17 +# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED +# else +# define _LIBCPP_DEPRECATED_IN_CXX20 +# endif -#if !defined(_LIBCPP_HAS_NO_CHAR8_T) -# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED -#else -# define _LIBCPP_DEPRECATED_WITH_CHAR8_T -#endif +# if !defined(_LIBCPP_HAS_NO_CHAR8_T) +# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED +# else +# define _LIBCPP_DEPRECATED_WITH_CHAR8_T +# endif // Macros to enter and leave a state where deprecation warnings are suppressed. -#if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ - _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -# define _LIBCPP_SUPPRESS_DEPRECATED_POP \ - _Pragma("GCC diagnostic pop") -#else -# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH -# define _LIBCPP_SUPPRESS_DEPRECATED_POP -#endif +# if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") +# else +# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH +# define _LIBCPP_SUPPRESS_DEPRECATED_POP +# endif -#if _LIBCPP_STD_VER <= 11 -# define _LIBCPP_EXPLICIT_AFTER_CXX11 -#else -# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit -#endif +# if _LIBCPP_STD_VER <= 11 +# define _LIBCPP_EXPLICIT_AFTER_CXX11 +# else +# define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit +# endif -#if _LIBCPP_STD_VER > 11 -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX11 -#endif +# if _LIBCPP_STD_VER > 11 +# define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +# else +# define _LIBCPP_CONSTEXPR_AFTER_CXX11 +# endif -#if _LIBCPP_STD_VER > 14 -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX14 -#endif +# if _LIBCPP_STD_VER > 14 +# define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr +# else +# define _LIBCPP_CONSTEXPR_AFTER_CXX14 +# endif -#if _LIBCPP_STD_VER > 17 -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr -#else -# define _LIBCPP_CONSTEXPR_AFTER_CXX17 -#endif +# if _LIBCPP_STD_VER > 17 +# define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr +# else +# define _LIBCPP_CONSTEXPR_AFTER_CXX17 +# endif -#if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) -# define _LIBCPP_NODISCARD [[nodiscard]] -#elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] -#else +# if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) +# define _LIBCPP_NODISCARD [[nodiscard]] +# elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) +# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] +# else // We can't use GCC's [[gnu::warn_unused_result]] and // __attribute__((warn_unused_result)), because GCC does not silence them via // (void) cast. -# define _LIBCPP_NODISCARD -#endif +# define _LIBCPP_NODISCARD +# endif // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not // specified as such as an extension. -#if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) -# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD -#else -# define _LIBCPP_NODISCARD_EXT -#endif +# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) +# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD +# else +# define _LIBCPP_NODISCARD_EXT +# endif -#if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ - (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) -# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD -#else -# define _LIBCPP_NODISCARD_AFTER_CXX17 -#endif +# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD +# else +# define _LIBCPP_NODISCARD_AFTER_CXX17 +# endif -#if __has_attribute(no_destroy) -# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) -#else -# define _LIBCPP_NO_DESTROY -#endif +# if __has_attribute(no_destroy) +# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) +# else +# define _LIBCPP_NO_DESTROY +# endif -#ifndef _LIBCPP_HAS_NO_ASAN -extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( - const void *, const void *, const void *, const void *); -#endif +# ifndef _LIBCPP_HAS_NO_ASAN +extern "C" _LIBCPP_FUNC_VIS void +__sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); +# endif // Try to find out if RTTI is disabled. -#if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) -# define _LIBCPP_NO_RTTI -#elif defined(__GNUC__) && !defined(__GXX_RTTI) -# define _LIBCPP_NO_RTTI -#elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) -# define _LIBCPP_NO_RTTI -#endif +# if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) +# define _LIBCPP_NO_RTTI +# elif defined(__GNUC__) && !defined(__GXX_RTTI) +# define _LIBCPP_NO_RTTI +# elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) +# define _LIBCPP_NO_RTTI +# endif -#ifndef _LIBCPP_WEAK -#define _LIBCPP_WEAK __attribute__((__weak__)) -#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(__wasi__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NuttX__) || \ - defined(__linux__) || \ - defined(__GNU__) || \ - defined(__APPLE__) || \ - defined(__sun__) || \ - defined(__MVS__) || \ - defined(_AIX) -# define _LIBCPP_HAS_THREAD_API_PTHREAD -# elif defined(__Fuchsia__) - // TODO(44575): Switch to C11 thread API when possible. -# 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_THREAD_API_PTHREAD) -#if defined(__ANDROID__) && __ANDROID_API__ >= 30 -#define _LIBCPP_HAS_COND_CLOCKWAIT -#elif defined(_LIBCPP_GLIBC_PREREQ) -#if _LIBCPP_GLIBC_PREREQ(2, 30) -#define _LIBCPP_HAS_COND_CLOCKWAIT -#endif -#endif -#endif +# 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(__wasi__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__NuttX__) \ + || defined(__linux__) || defined(__GNU__) || defined(__APPLE__) || defined(__sun__) || defined(__MVS__) \ + || defined(_AIX) +# define _LIBCPP_HAS_THREAD_API_PTHREAD +# elif defined(__Fuchsia__) +// TODO(44575): Switch to C11 thread API when possible. +# 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_THREAD_API_PTHREAD) +# if defined(__ANDROID__) && __ANDROID_API__ >= 30 +# define _LIBCPP_HAS_COND_CLOCKWAIT +# elif defined(_LIBCPP_GLIBC_PREREQ) +# if _LIBCPP_GLIBC_PREREQ(2, 30) +# define _LIBCPP_HAS_COND_CLOCKWAIT +# endif +# endif +# endif -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) -#error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ +# 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 +# endif -#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) -#error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ +# 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 +# endif -#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) -#error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ +# 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 +# endif -#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) -#define __STDCPP_THREADS__ 1 -#endif +# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) +# define __STDCPP_THREADS__ 1 +# endif // The glibc and Bionic implementation of pthreads implements // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 @@ -1079,11 +1075,10 @@ // // TODO(EricWF): Enable this optimization on Bionic after speaking to their // respective stakeholders. -#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ - || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ - || defined(_LIBCPP_HAS_THREAD_API_WIN32) -# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION -#endif +# if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ + || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) +# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION +# endif // Destroying a condvar is a nop on Windows. // @@ -1093,273 +1088,257 @@ // // TODO(EricWF): This is potentially true for some pthread implementations // as well. -#if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ - defined(_LIBCPP_HAS_THREAD_API_WIN32) -# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION -#endif +# if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) +# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION +# endif // Some systems do not provide gets() in their C library, for security reasons. -#if defined(_LIBCPP_MSVCRT) || \ - (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ - defined(__OpenBSD__) -# define _LIBCPP_C_HAS_NO_GETS -#endif - -#if defined(__BIONIC__) || defined(__NuttX__) || \ - defined(__Fuchsia__) || defined(__wasi__) || \ - defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) -#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE -#endif +# if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) +# define _LIBCPP_C_HAS_NO_GETS +# endif -#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) -# define _LIBCPP_HAS_C_ATOMIC_IMP -#elif defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_HAS_GCC_ATOMIC_IMP -#endif +# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) \ + || defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) +# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE +# endif -#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ - !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ - !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) -# define _LIBCPP_HAS_NO_ATOMIC_HEADER -#else -# ifndef _LIBCPP_ATOMIC_FLAG_TYPE -# define _LIBCPP_ATOMIC_FLAG_TYPE bool +# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) +# define _LIBCPP_HAS_C_ATOMIC_IMP +# elif defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_HAS_GCC_ATOMIC_IMP # endif -# ifdef _LIBCPP_FREESTANDING -# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS + +# if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) \ + && !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) +# define _LIBCPP_HAS_NO_ATOMIC_HEADER +# else +# ifndef _LIBCPP_ATOMIC_FLAG_TYPE +# define _LIBCPP_ATOMIC_FLAG_TYPE bool +# endif +# ifdef _LIBCPP_FREESTANDING +# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS +# endif # endif -#endif -#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -#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) +# 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. In MinGW mode, __declspec evaluates to __attribute__, and thus // combining the two does work. -# if !defined(_MSC_VER) -# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS +# if !defined(_MSC_VER) +# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS +# endif # endif # endif -#endif -#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) -#else -# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) -#endif +# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS +# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) +# else +# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) +# endif -#if _LIBCPP_STD_VER > 17 -# define _LIBCPP_CONSTINIT constinit -#elif __has_attribute(require_constant_initialization) -# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) -#else -# define _LIBCPP_CONSTINIT -#endif +# if _LIBCPP_STD_VER > 17 +# define _LIBCPP_CONSTINIT constinit +# elif __has_attribute(require_constant_initialization) +# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) +# else +# define _LIBCPP_CONSTINIT +# 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(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 // Use a function like macro to imply that it must be followed by a semicolon -#if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough) -# define _LIBCPP_FALLTHROUGH() [[fallthrough]] -#elif __has_cpp_attribute(clang::fallthrough) -# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] -#elif __has_attribute(__fallthrough__) -# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) -#else -# define _LIBCPP_FALLTHROUGH() ((void)0) -#endif +# if _LIBCPP_STD_VER > 14 && __has_cpp_attribute(fallthrough) +# define _LIBCPP_FALLTHROUGH() [[fallthrough]] +# elif __has_cpp_attribute(clang::fallthrough) +# define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] +# elif __has_attribute(__fallthrough__) +# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) +# else +# define _LIBCPP_FALLTHROUGH() ((void)0) +# endif -#if __has_attribute(__nodebug__) -#define _LIBCPP_NODEBUG __attribute__((__nodebug__)) -#else -#define _LIBCPP_NODEBUG -#endif +# if __has_attribute(__nodebug__) +# define _LIBCPP_NODEBUG __attribute__((__nodebug__)) +# else +# define _LIBCPP_NODEBUG +# endif -#if __has_attribute(__standalone_debug__) -#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) -#else -#define _LIBCPP_STANDALONE_DEBUG -#endif +# if __has_attribute(__standalone_debug__) +# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) +# else +# define _LIBCPP_STANDALONE_DEBUG +# endif -#if __has_attribute(__preferred_name__) -#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) -#else -#define _LIBCPP_PREFERRED_NAME(x) -#endif +# if __has_attribute(__preferred_name__) +# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) +# else +# define _LIBCPP_PREFERRED_NAME(x) +# endif // We often repeat things just for handling wide characters in the library. // When wide characters are disabled, it can be useful to have a quick way of // disabling it without having to resort to #if-#endif, which has a larger // impact on readability. -#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) -# define _LIBCPP_IF_WIDE_CHARACTERS(...) -#else -# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ -#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_HAS_NO_WIDE_CHARACTERS) +# define _LIBCPP_IF_WIDE_CHARACTERS(...) +# else +# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ +# endif -#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) -#define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR -#define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS -#define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -#endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES - -#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) -#define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS -#define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS -#define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS -#define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR -#define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS -#endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES - -#if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L -#define _LIBCPP_HAS_NO_CXX20_COROUTINES -#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_COMPILER_IBM) -#define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO -#endif +# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) +# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR +# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS +# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE +# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES + +# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) +# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS +# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS +# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS +# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR +# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS +# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES + +# if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L +# define _LIBCPP_HAS_NO_CXX20_COROUTINES +# 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\")") +# if defined(_LIBCPP_COMPILER_IBM) +# define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO # 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(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# pragma comment(lib, "c++.lib") +# 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 -# pragma comment(lib, "libc++.lib") +# 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_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) -#endif // _LIBCPP_NO_AUTO_LINK +# 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(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) +# 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 // Configures the fopen close-on-exec mode character, if any. This string will // be appended to any mode string used by fstream for fopen/fdopen. // // Not all platforms support this, but it helps avoid fd-leaks on platforms that // do. -#if defined(__BIONIC__) -# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" -#else -# define _LIBCPP_FOPEN_CLOEXEC_MODE -#endif +# if defined(__BIONIC__) +# define _LIBCPP_FOPEN_CLOEXEC_MODE "e" +# else +# define _LIBCPP_FOPEN_CLOEXEC_MODE +# endif // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set // of functions used in cstdio may not be available for low API levels when // using 64-bit file offsets on LP32. -#if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 -#define _LIBCPP_HAS_NO_FGETPOS_FSETPOS -#endif +# if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 +# define _LIBCPP_HAS_NO_FGETPOS_FSETPOS +# endif -#if __has_attribute(init_priority) - // TODO: Remove this once we drop support for building libc++ with old Clangs -# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ - (defined(__apple_build_version__) && __apple_build_version__ < 13000000) -# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) -# else -# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) -# endif -#else -# define _LIBCPP_INIT_PRIORITY_MAX -#endif +# if __has_attribute(init_priority) +// TODO: Remove this once we drop support for building libc++ with old Clangs +# if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) \ + || (defined(__apple_build_version__) && __apple_build_version__ < 13000000) +# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) +# else +# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) +# endif +# else +# define _LIBCPP_INIT_PRIORITY_MAX +# endif -#if defined(__GNUC__) || defined(__clang__) - // The attribute uses 1-based indices for ordinary and static member functions. - // The attribute uses 2-based indices for non-static member functions. -# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ - __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) -#else -# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ -#endif +# if defined(__GNUC__) || defined(__clang__) +// The attribute uses 1-based indices for ordinary and static member functions. +// The attribute uses 2-based indices for non-static member functions. +# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ + __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) +# else +# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ +# endif -#if __has_cpp_attribute(msvc::no_unique_address) - // MSVC implements [[no_unique_address]] as a silent no-op currently. - // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) - // However, MSVC implements [[msvc::no_unique_address]] which does what - // [[no_unique_address]] is supposed to do, in general. - - // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or - // [[msvc::no_unique_address]] though. If/when it does implement - // [[msvc::no_unique_address]], this should be preferred though. -# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] -#elif __has_cpp_attribute(no_unique_address) -# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] -#else -# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ - // Note that this can be replaced by #error as soon as clang-cl - // implements msvc::no_unique_address, since there should be no C++20 - // compiler that doesn't support one of the two attributes at that point. - // We generally don't want to use this macro outside of C++20-only code, - // because using it conditionally in one language version only would make - // the ABI inconsistent. -#endif +# if __has_cpp_attribute(msvc::no_unique_address) +// MSVC implements [[no_unique_address]] as a silent no-op currently. +// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) +// However, MSVC implements [[msvc::no_unique_address]] which does what +// [[no_unique_address]] is supposed to do, in general. + +// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or +// [[msvc::no_unique_address]] though. If/when it does implement +// [[msvc::no_unique_address]], this should be preferred though. +# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] +# elif __has_cpp_attribute(no_unique_address) +# define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] +# else +# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ +// Note that this can be replaced by #error as soon as clang-cl +// implements msvc::no_unique_address, since there should be no C++20 +// compiler that doesn't support one of the two attributes at that point. +// We generally don't want to use this macro outside of C++20-only code, +// because using it conditionally in one language version only would make +// the ABI inconsistent. +# endif -#ifdef _LIBCPP_COMPILER_CLANG_BASED -# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") -# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) -#elif defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") -# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) -#else -# define _LIBCPP_DIAGNOSTIC_PUSH -# define _LIBCPP_DIAGNOSTIC_POP -# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) -# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) -#endif +# ifdef _LIBCPP_COMPILER_CLANG_BASED +# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") +# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) +# elif defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") +# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) +# else +# define _LIBCPP_DIAGNOSTIC_PUSH +# define _LIBCPP_DIAGNOSTIC_POP +# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) +# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) +# endif -#if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") -# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") -#else -# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ -# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ -#endif +# if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") +# define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") +# else +# define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ +# define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ +# endif #endif // __cplusplus diff --git a/libcxx/include/__ranges/lazy_split_view.h b/libcxx/include/__ranges/lazy_split_view.h --- a/libcxx/include/__ranges/lazy_split_view.h +++ b/libcxx/include/__ranges/lazy_split_view.h @@ -49,74 +49,79 @@ namespace ranges { -template struct __require_constant; +template +struct __require_constant; template -concept __tiny_range = - sized_range<_Range> && - requires { typename __require_constant::size()>; } && - (remove_reference_t<_Range>::size() <= 1); +concept __tiny_range + = sized_range<_Range> && requires { typename __require_constant::size()>; } + && (remove_reference_t<_Range>::size() <= 1); template - requires view<_View> && view<_Pattern> && - indirectly_comparable, iterator_t<_Pattern>, ranges::equal_to> && - (forward_range<_View> || __tiny_range<_Pattern>) -class lazy_split_view : public view_interface> { - - _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); + requires view<_View> && view<_Pattern> + && indirectly_comparable< + iterator_t<_View>, + iterator_t<_Pattern>, + ranges::equal_to> + && (forward_range<_View> || __tiny_range<_Pattern>)class lazy_split_view + : public view_interface> { + _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern(); using _MaybeCurrent = _If, __non_propagating_cache>, __empty_cache>; _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); - template struct __outer_iterator; - template struct __inner_iterator; + template + struct __outer_iterator; + template + struct __inner_iterator; public: - _LIBCPP_HIDE_FROM_ABI - lazy_split_view() - requires default_initializable<_View> && default_initializable<_Pattern> = default; + _LIBCPP_HIDE_FROM_ABI lazy_split_view() + requires default_initializable<_View> && default_initializable<_Pattern> + = default; - _LIBCPP_HIDE_FROM_ABI - constexpr lazy_split_view(_View __base, _Pattern __pattern) - : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {} + _LIBCPP_HIDE_FROM_ABI constexpr lazy_split_view(_View __base, _Pattern __pattern) + : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {} template - requires constructible_from<_View, views::all_t<_Range>> && - constructible_from<_Pattern, single_view>> - _LIBCPP_HIDE_FROM_ABI - constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e) - : __base_(views::all(std::forward<_Range>(__r))) - // TODO(varconst): use `views::single` once it's implemented. - , __pattern_(ranges::single_view(std::move(__e))) {} - - _LIBCPP_HIDE_FROM_ABI - constexpr _View base() const& requires copy_constructible<_View> { return __base_; } - _LIBCPP_HIDE_FROM_ABI - constexpr _View base() && { return std::move(__base_); } - - _LIBCPP_HIDE_FROM_ABI - constexpr auto begin() { + requires constructible_from<_View, views::all_t<_Range>> + && constructible_from<_Pattern, single_view>> + _LIBCPP_HIDE_FROM_ABI constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e) + : __base_(views::all(std::forward<_Range>(__r))) + // TODO(varconst): use `views::single` once it's implemented. + , + __pattern_(ranges::single_view(std::move(__e))) {} + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& + requires copy_constructible<_View> + { + return __base_; + } + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } + + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { if constexpr (forward_range<_View>) { - return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::begin(__base_)}; + return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::begin(__base_)}; } else { __current_.__emplace(ranges::begin(__base_)); return __outer_iterator{*this}; } } - _LIBCPP_HIDE_FROM_ABI - constexpr auto begin() const requires forward_range<_View> && forward_range { + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const + requires forward_range<_View> && forward_range + { return __outer_iterator{*this, ranges::begin(__base_)}; } - _LIBCPP_HIDE_FROM_ABI - constexpr auto end() requires forward_range<_View> && common_range<_View> { - return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::end(__base_)}; + _LIBCPP_HIDE_FROM_ABI constexpr auto end() + requires forward_range<_View> && common_range<_View> + { + return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::end(__base_)}; } - _LIBCPP_HIDE_FROM_ABI - constexpr auto end() const { + _LIBCPP_HIDE_FROM_ABI constexpr auto end() const { if constexpr (forward_range<_View> && forward_range && common_range) { return __outer_iterator{*this, ranges::end(__base_)}; } else { @@ -125,7 +130,6 @@ } private: - template struct __outer_iterator_category {}; @@ -142,15 +146,14 @@ friend __outer_iterator; using _Parent = __maybe_const<_Const, lazy_split_view>; - using _Base = __maybe_const<_Const, _View>; + using _Base = __maybe_const<_Const, _View>; - _Parent* __parent_ = nullptr; - using _MaybeCurrent = _If, iterator_t<_Base>, __empty_cache>; + _Parent* __parent_ = nullptr; + using _MaybeCurrent = _If, iterator_t<_Base>, __empty_cache>; _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); - bool __trailing_empty_ = false; + bool __trailing_empty_ = false; - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto& __current() noexcept { + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __current() noexcept { if constexpr (forward_range<_View>) { return __current_; } else { @@ -158,8 +161,7 @@ } } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr const auto& __current() const noexcept { + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const auto& __current() const noexcept { if constexpr (forward_range<_View>) { return __current_; } else { @@ -169,56 +171,44 @@ // Workaround for the GCC issue that doesn't allow calling `__parent_->__base_` from friend functions (because // `__base_` is private). - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto& __parent_base() const noexcept { - return __parent_->__base_; - } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __parent_base() const noexcept { return __parent_->__base_; } public: // using iterator_category = inherited; using iterator_concept = conditional_t, forward_iterator_tag, input_iterator_tag>; - using difference_type = range_difference_t<_Base>; + using difference_type = range_difference_t<_Base>; struct value_type : view_interface { private: __outer_iterator __i_ = __outer_iterator(); public: - _LIBCPP_HIDE_FROM_ABI - value_type() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit value_type(__outer_iterator __i) - : __i_(std::move(__i)) {} - - _LIBCPP_HIDE_FROM_ABI - constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; } - _LIBCPP_HIDE_FROM_ABI - constexpr default_sentinel_t end() const noexcept { return default_sentinel; } + _LIBCPP_HIDE_FROM_ABI value_type() = default; + _LIBCPP_HIDE_FROM_ABI constexpr explicit value_type(__outer_iterator __i) : __i_(std::move(__i)) {} + + _LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; } + _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; } }; - _LIBCPP_HIDE_FROM_ABI - __outer_iterator() = default; + _LIBCPP_HIDE_FROM_ABI __outer_iterator() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __outer_iterator(_Parent& __parent) - requires (!forward_range<_Base>) - : __parent_(std::addressof(__parent)) {} + _LIBCPP_HIDE_FROM_ABI constexpr explicit __outer_iterator(_Parent& __parent) + requires(!forward_range<_Base>) + : __parent_(std::addressof(__parent)) {} - _LIBCPP_HIDE_FROM_ABI - constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current) + _LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current) requires forward_range<_Base> - : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {} + : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {} - _LIBCPP_HIDE_FROM_ABI - constexpr __outer_iterator(__outer_iterator __i) - requires _Const && convertible_to, iterator_t<_Base>> - : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {} + _LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator(__outer_iterator __i) + requires _Const + && convertible_to, + iterator_t<_Base>> + : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {} - _LIBCPP_HIDE_FROM_ABI - constexpr value_type operator*() const { return value_type{*this}; } + _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return value_type{*this}; } - _LIBCPP_HIDE_FROM_ABI - constexpr __outer_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator& operator++() { const auto __end = ranges::end(__parent_->__base_); if (__current() == __end) { __trailing_empty_ = false; @@ -229,7 +219,6 @@ if (__pbegin == __pend) { // Empty pattern: split on every element in the input range ++__current(); - } else if constexpr (__tiny_range<_Pattern>) { // One-element pattern: we can use `ranges::find`. __current() = ranges::find(std::move(__current()), __end, *__pbegin); @@ -239,7 +228,6 @@ if (__current() == __end) __trailing_empty_ = true; } - } else { // General case for n-element pattern. do { @@ -257,26 +245,23 @@ return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator++(int) { + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) { if constexpr (forward_range<_Base>) { auto __tmp = *this; ++*this; return __tmp; - } else { ++*this; } } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y) - requires forward_range<_Base> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y) + requires forward_range<_Base> + { return __x.__current_ == __y.__current_ && __x.__trailing_empty_ == __y.__trailing_empty_; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) { _LIBCPP_ASSERT(__x.__parent_, "Cannot call comparison on a default-constructed iterator."); return __x.__current() == ranges::end(__x.__parent_base()) && !__x.__trailing_empty_; } @@ -288,10 +273,9 @@ template struct __inner_iterator_category<_Tp> { using iterator_category = _If< - derived_from>::iterator_category, forward_iterator_tag>, - forward_iterator_tag, - typename iterator_traits>::iterator_category - >; + derived_from>::iterator_category, forward_iterator_tag>, + forward_iterator_tag, + typename iterator_traits>::iterator_category >; }; template @@ -300,18 +284,17 @@ using _Base = __maybe_const<_Const, _View>; // Workaround for a GCC issue. static constexpr bool _OuterConst = _Const; - __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>(); - bool __incremented_ = false; + __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>(); + bool __incremented_ = false; // Note: these private functions are necessary because GCC doesn't allow calls to private members of `__i_` from // free functions that are friends of `inner-iterator`. - _LIBCPP_HIDE_FROM_ABI - constexpr bool __is_done() const { + _LIBCPP_HIDE_FROM_ABI constexpr bool __is_done() const { _LIBCPP_ASSERT(__i_.__parent_, "Cannot call comparison on a default-constructed iterator."); auto [__pcur, __pend] = ranges::subrange{__i_.__parent_->__pattern_}; - auto __end = ranges::end(__i_.__parent_->__base_); + auto __end = ranges::end(__i_.__parent_->__base_); if constexpr (__tiny_range<_Pattern>) { const auto& __cur = __i_.__current(); @@ -321,7 +304,6 @@ return __incremented_; return *__cur == *__pcur; - } else { auto __cur = __i_.__current(); if (__cur == __end) @@ -340,40 +322,32 @@ } } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto& __outer_current() noexcept { - return __i_.__current(); - } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __outer_current() noexcept { return __i_.__current(); } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr const auto& __outer_current() const noexcept { + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const auto& __outer_current() const noexcept { return __i_.__current(); } public: // using iterator_category = inherited; using iterator_concept = typename __outer_iterator<_Const>::iterator_concept; - using value_type = range_value_t<_Base>; - using difference_type = range_difference_t<_Base>; + using value_type = range_value_t<_Base>; + using difference_type = range_difference_t<_Base>; - _LIBCPP_HIDE_FROM_ABI - __inner_iterator() = default; + _LIBCPP_HIDE_FROM_ABI __inner_iterator() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __inner_iterator(__outer_iterator<_Const> __i) - : __i_(std::move(__i)) {} + _LIBCPP_HIDE_FROM_ABI constexpr explicit __inner_iterator(__outer_iterator<_Const> __i) : __i_(std::move(__i)) {} - _LIBCPP_HIDE_FROM_ABI - constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); } - _LIBCPP_HIDE_FROM_ABI - constexpr iterator_t<_Base> base() && - requires forward_range<_View> { return std::move(__i_.__current()); } + _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); } + _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && + requires forward_range<_View> + { + return std::move(__i_.__current()); + } - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator*() const { return *__i_.__current(); } + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__i_.__current(); } - _LIBCPP_HIDE_FROM_ABI - constexpr __inner_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator& operator++() { __incremented_ = true; if constexpr (!forward_range<_Base>) { @@ -386,43 +360,39 @@ return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr decltype(auto) operator++(int) { + _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) { if constexpr (forward_range<_Base>) { auto __tmp = *this; ++*this; return __tmp; - } else { ++*this; } } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y) - requires forward_range<_Base> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y) + requires forward_range<_Base> + { return __x.__outer_current() == __y.__outer_current(); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) { return __x.__is_done(); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr decltype(auto) iter_move(const __inner_iterator& __i) - noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) { + _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) + iter_move(const __inner_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) { return ranges::iter_move(__i.__outer_current()); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr void iter_swap(const __inner_iterator& __x, const __inner_iterator& __y) - noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current()))) - requires indirectly_swappable> { + _LIBCPP_HIDE_FROM_ABI friend constexpr void + iter_swap(const __inner_iterator& __x, const __inner_iterator& __y) noexcept( + noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current()))) + requires indirectly_swappable> + { ranges::iter_swap(__x.__outer_current(), __y.__outer_current()); } }; - }; template @@ -430,31 +400,32 @@ template lazy_split_view(_Range&&, range_value_t<_Range>) - -> lazy_split_view, single_view>>; + -> lazy_split_view, single_view>>; namespace views { -namespace __lazy_split_view { -struct __fn : __range_adaptor_closure<__fn> { - template - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const - noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) - -> decltype( lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) - { return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); } - - template - requires constructible_from, _Pattern> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Pattern&& __pattern) const - noexcept(is_nothrow_constructible_v, _Pattern>) { - return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); - } -}; -} // namespace __lazy_split_view + namespace __lazy_split_view { + struct __fn : __range_adaptor_closure<__fn> { + template + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto + operator()(_Range&& __range, _Pattern&& __pattern) const noexcept( + noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) + -> decltype(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) { + return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); + } + + template + requires constructible_from< + decay_t<_Pattern>, + _Pattern> [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto + operator()(_Pattern&& __pattern) const noexcept(is_nothrow_constructible_v, _Pattern>) { + return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); + } + }; + } // namespace __lazy_split_view -inline namespace __cpo { - inline constexpr auto lazy_split = __lazy_split_view::__fn{}; -} // namespace __cpo + inline namespace __cpo { + inline constexpr auto lazy_split = __lazy_split_view::__fn{}; + } // namespace __cpo } // namespace views } // namespace ranges diff --git a/libcxx/include/__ranges/zip_view.h b/libcxx/include/__ranges/zip_view.h --- a/libcxx/include/__ranges/zip_view.h +++ b/libcxx/include/__ranges/zip_view.h @@ -49,9 +49,10 @@ namespace ranges { template -concept __zip_is_common = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) || - (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) || - ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); +concept __zip_is_common + = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) + || (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) + || ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); template auto __tuple_or_pair_test() -> pair<_Tp, _Up>; @@ -81,32 +82,41 @@ } template -_LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair< - invoke_result_t<_Fun&, typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type, - typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...> +_LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair< invoke_result_t< + _Fun&, + typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type, + typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...> __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) { - return {std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), - std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...}; + return {std::invoke( + __f, + std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), + std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...}; } template _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) { - return ranges::__tuple_zip_transform(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2), - std::make_index_sequence>::value>()); + return ranges::__tuple_zip_transform( + __f, + std::forward<_Tuple1>(__tuple1), + std::forward<_Tuple2>(__tuple2), + std::make_index_sequence>::value>()); } template -_LIBCPP_HIDE_FROM_ABI constexpr void __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, - index_sequence<_Indices...>) { - (std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), - std::get<_Indices>(std::forward<_Tuple2>(__tuple2))), +_LIBCPP_HIDE_FROM_ABI constexpr void +__tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) { + (std::invoke( + __f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), std::get<_Indices>(std::forward<_Tuple2>(__tuple2))), ...); } template _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) { - return ranges::__tuple_zip_for_each(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2), - std::make_index_sequence>::value>()); + return ranges::__tuple_zip_for_each( + __f, + std::forward<_Tuple1>(__tuple1), + std::forward<_Tuple2>(__tuple2), + std::make_index_sequence>::value>()); } template @@ -125,7 +135,6 @@ template requires(view<_Views> && ...) && (sizeof...(_Views) > 0) class zip_view : public view_interface> { - _LIBCPP_NO_UNIQUE_ADDRESS tuple<_Views...> __views_; template @@ -135,27 +144,25 @@ class __sentinel; public: - _LIBCPP_HIDE_FROM_ABI - zip_view() = default; + _LIBCPP_HIDE_FROM_ABI zip_view() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {} + _LIBCPP_HIDE_FROM_ABI constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {} - _LIBCPP_HIDE_FROM_ABI - constexpr auto begin() - requires(!(__simple_view<_Views> && ...)) { + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() + requires(!(__simple_view<_Views> && ...)) + { return __iterator(ranges::__tuple_transform(ranges::begin, __views_)); } - _LIBCPP_HIDE_FROM_ABI - constexpr auto begin() const - requires(range && ...) { + _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const + requires(range && ...) + { return __iterator(ranges::__tuple_transform(ranges::begin, __views_)); } - _LIBCPP_HIDE_FROM_ABI - constexpr auto end() - requires(!(__simple_view<_Views> && ...)) { + _LIBCPP_HIDE_FROM_ABI constexpr auto end() + requires(!(__simple_view<_Views> && ...)) + { if constexpr (!__zip_is_common<_Views...>) { return __sentinel(ranges::__tuple_transform(ranges::end, __views_)); } else if constexpr ((random_access_range<_Views> && ...)) { @@ -165,9 +172,9 @@ } } - _LIBCPP_HIDE_FROM_ABI - constexpr auto end() const - requires(range && ...) { + _LIBCPP_HIDE_FROM_ABI constexpr auto end() const + requires(range && ...) + { if constexpr (!__zip_is_common) { return __sentinel(ranges::__tuple_transform(ranges::end, __views_)); } else if constexpr ((random_access_range && ...)) { @@ -177,9 +184,9 @@ } } - _LIBCPP_HIDE_FROM_ABI - constexpr auto size() - requires(sized_range<_Views> && ...) { + _LIBCPP_HIDE_FROM_ABI constexpr auto size() + requires(sized_range<_Views> && ...) + { return std::apply( [](auto... __sizes) { using _CT = make_unsigned_t>; @@ -188,9 +195,9 @@ ranges::__tuple_transform(ranges::size, __views_)); } - _LIBCPP_HIDE_FROM_ABI - constexpr auto size() const - requires(sized_range && ...) { + _LIBCPP_HIDE_FROM_ABI constexpr auto size() const + requires(sized_range && ...) + { return std::apply( [](auto... __sizes) { using _CT = make_unsigned_t>; @@ -238,11 +245,10 @@ requires(view<_Views> && ...) && (sizeof...(_Views) > 0) template class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> { - __tuple_or_pair>...> __current_; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __iterator(__tuple_or_pair>...> __current) + _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator( + __tuple_or_pair>...> __current) : __current_(std::move(__current)) {} template @@ -255,78 +261,73 @@ public: using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>()); - using value_type = __tuple_or_pair>...>; - using difference_type = common_type_t>...>; + using value_type = __tuple_or_pair>...>; + using difference_type = common_type_t>...>; - _LIBCPP_HIDE_FROM_ABI - __iterator() = default; + _LIBCPP_HIDE_FROM_ABI __iterator() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator(__iterator __i) + _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator __i) requires _Const && (convertible_to, iterator_t<__maybe_const<_Const, _Views>>> && ...) : __current_(std::move(__i.__current_)) {} - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator*() const { + _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const { return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_); } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { ranges::__tuple_for_each([](auto& __i) { ++__i; }, __current_); return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr void operator++(int) { ++*this; } + _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++*this; } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator operator++(int) - requires __zip_all_forward<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) + requires __zip_all_forward<_Const, _Views...> + { auto __tmp = *this; ++*this; return __tmp; } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator& operator--() - requires __zip_all_bidirectional<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() + requires __zip_all_bidirectional<_Const, _Views...> + { ranges::__tuple_for_each([](auto& __i) { --__i; }, __current_); return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator operator--(int) - requires __zip_all_bidirectional<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) + requires __zip_all_bidirectional<_Const, _Views...> + { auto __tmp = *this; --*this; return __tmp; } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator& operator+=(difference_type __x) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __x) + requires __zip_all_random_access<_Const, _Views...> + { ranges::__tuple_for_each([&](_Iter& __i) { __i += iter_difference_t<_Iter>(__x); }, __current_); return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr __iterator& operator-=(difference_type __x) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __x) + requires __zip_all_random_access<_Const, _Views...> + { ranges::__tuple_for_each([&](_Iter& __i) { __i -= iter_difference_t<_Iter>(__x); }, __current_); return *this; } - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator[](difference_type __n) const - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const + requires __zip_all_random_access<_Const, _Views...> + { return ranges::__tuple_transform( [&](_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) - requires(equality_comparable>> && ...) { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) + requires(equality_comparable>> && ...) + { if constexpr (__zip_all_bidirectional<_Const, _Views...>) { return __x.__current_ == __y.__current_; } else { @@ -334,85 +335,86 @@ } } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) + requires __zip_all_random_access<_Const, _Views...> + { return __x.__current_ < __y.__current_; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) + requires __zip_all_random_access<_Const, _Views...> + { return __y < __x; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) + requires __zip_all_random_access<_Const, _Views...> + { return !(__y < __x); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) + requires __zip_all_random_access<_Const, _Views...> + { return !(__x < __y); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) - requires __zip_all_random_access<_Const, _Views...> && - (three_way_comparable>> && ...) { + _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) + requires __zip_all_random_access<_Const, _Views...> + && (three_way_comparable>> && ...) + { return __x.__current_ <=> __y.__current_; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) + requires __zip_all_random_access<_Const, _Views...> + { auto __r = __i; __r += __n; return __r; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) + requires __zip_all_random_access<_Const, _Views...> + { return __i + __n; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) - requires __zip_all_random_access<_Const, _Views...> { + _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) + requires __zip_all_random_access<_Const, _Views...> + { auto __r = __i; __r -= __n; return __r; } - _LIBCPP_HIDE_FROM_ABI - friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) - requires(sized_sentinel_for>, iterator_t<__maybe_const<_Const, _Views>>> && - ...) { + _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) + requires( + sized_sentinel_for>, iterator_t<__maybe_const<_Const, _Views>>> && ...) + { const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __x.__current_, __y.__current_); return std::apply( [](auto... __ds) { - return ranges::min({difference_type(__ds)...}, - [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); }); + return ranges::min({difference_type(__ds)...}, [](auto __a, auto __b) { + return ranges::__abs(__a) < ranges::__abs(__b); + }); }, __diffs); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr auto iter_move(const __iterator& __i) noexcept( - (noexcept(ranges::iter_move(declval>&>())) && ...) && - (is_nothrow_move_constructible_v>> && ...)) { + _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept( + (noexcept(ranges::iter_move(declval>&>())) && ...) + && (is_nothrow_move_constructible_v>> && ...)) { return ranges::__tuple_transform(ranges::iter_move, __i.__current_); } - _LIBCPP_HIDE_FROM_ABI - friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( - (noexcept(ranges::iter_swap(declval>&>(), - declval>&>())) && - ...)) - requires(indirectly_swappable>> && ...) { + _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept(( + noexcept(ranges::iter_swap( + declval>&>(), + declval>&>())) + && ...)) + requires(indirectly_swappable>> && ...) + { ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_); } }; @@ -421,11 +423,11 @@ requires(view<_Views> && ...) && (sizeof...(_Views) > 0) template class zip_view<_Views...>::__sentinel { - __tuple_or_pair>...> __end_; - _LIBCPP_HIDE_FROM_ABI - constexpr explicit __sentinel(__tuple_or_pair>...> __end) : __end_(__end) {} + _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel( + __tuple_or_pair>...> __end) + : __end_(__end) {} friend class zip_view<_Views...>; @@ -437,41 +439,40 @@ } public: - _LIBCPP_HIDE_FROM_ABI - __sentinel() = default; + _LIBCPP_HIDE_FROM_ABI __sentinel() = default; - _LIBCPP_HIDE_FROM_ABI - constexpr __sentinel(__sentinel __i) + _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel __i) requires _Const && (convertible_to, sentinel_t<__maybe_const<_Const, _Views>>> && ...) : __end_(std::move(__i.__end_)) {} template - requires(sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> && - ...) + requires( + sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> && ...) _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { return ranges::__tuple_any_equals(__iter_current(__x), __y.__end_); } template requires( - sized_sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> && - ...) + sized_sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> + && ...) _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t>...> operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) { const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_); return std::apply( [](auto... __ds) { using _Diff = common_type_t>...>; - return ranges::min({_Diff(__ds)...}, - [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); }); + return ranges::min({_Diff(__ds)...}, [](auto __a, auto __b) { + return ranges::__abs(__a) < ranges::__abs(__b); + }); }, __diffs); } template requires( - sized_sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> && - ...) + sized_sentinel_for>, iterator_t<__maybe_const<_OtherConst, _Views>>> + && ...) _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t>...> operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) { return -(__x - __y); @@ -482,23 +483,23 @@ inline constexpr bool enable_borrowed_range> = (enable_borrowed_range<_Views> && ...); namespace views { -namespace __zip { + namespace __zip { -struct __fn { - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view>{}; } + struct __fn { + _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view>{}; } - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... rs) const - noexcept(noexcept(zip_view...>(std::forward<_Ranges>(rs)...))) + template + _LIBCPP_HIDE_FROM_ABI constexpr auto + operator()(_Ranges&&... rs) const noexcept(noexcept(zip_view...>(std::forward<_Ranges>(rs)...))) -> decltype(zip_view...>(std::forward<_Ranges>(rs)...)) { - return zip_view...>(std::forward<_Ranges>(rs)...); - } -}; - -} // namespace __zip -inline namespace __cpo { - inline constexpr auto zip = __zip::__fn{}; -} // namespace __cpo + return zip_view...>(std::forward<_Ranges>(rs)...); + } + }; + + } // namespace __zip + inline namespace __cpo { + inline constexpr auto zip = __zip::__fn{}; + } // namespace __cpo } // namespace views } // namespace ranges diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -533,7 +533,7 @@ #include <__utility/unreachable.h> #include #include -#include // EOF +#include // EOF #include #include #include @@ -571,55 +571,47 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> - _LIBCPP_BEGIN_NAMESPACE_STD // basic_string -template -basic_string<_CharT, _Traits, _Allocator> -_LIBCPP_CONSTEXPR_AFTER_CXX17 -operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, - const basic_string<_CharT, _Traits, _Allocator>& __y); +template +basic_string<_CharT, _Traits, _Allocator> _LIBCPP_CONSTEXPR_AFTER_CXX17 +operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y); -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const _CharT* __x, const basic_string<_CharT, _Traits, _Allocator>& __y); -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(_CharT __x, const basic_string<_CharT, _Traits, _Allocator>& __y); -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); -_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&)) +_LIBCPP_EXTERN_TEMPLATE( + _LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&)) template struct __string_is_trivial_iterator : public false_type {}; template -struct __string_is_trivial_iterator<_Tp*> - : public is_arithmetic<_Tp> {}; +struct __string_is_trivial_iterator<_Tp*> : public is_arithmetic<_Tp> {}; template -struct __string_is_trivial_iterator<__wrap_iter<_Iter> > - : public __string_is_trivial_iterator<_Iter> {}; +struct __string_is_trivial_iterator<__wrap_iter<_Iter> > : public __string_is_trivial_iterator<_Iter> {}; template -struct __can_be_converted_to_string_view : public _BoolConstant< - is_convertible >::value && - !is_convertible::value - > {}; +struct __can_be_converted_to_string_view + : public _BoolConstant< + is_convertible >::value + && !is_convertible::value > {}; #ifndef _LIBCPP_HAS_NO_CHAR8_T typedef basic_string u8string; @@ -632,1418 +624,1248 @@ struct __uninitialized_size_tag {}; -template -class - _LIBCPP_TEMPLATE_VIS +template +class _LIBCPP_TEMPLATE_VIS #ifndef _LIBCPP_HAS_NO_CHAR8_T - _LIBCPP_PREFERRED_NAME(u8string) +_LIBCPP_PREFERRED_NAME(u8string) #endif #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - _LIBCPP_PREFERRED_NAME(u16string) - _LIBCPP_PREFERRED_NAME(u32string) + _LIBCPP_PREFERRED_NAME(u16string) _LIBCPP_PREFERRED_NAME(u32string) #endif - basic_string -{ + basic_string { + public: - typedef basic_string __self; - typedef basic_string_view<_CharT, _Traits> __self_view; - typedef _Traits traits_type; - typedef _CharT value_type; - typedef _Allocator allocator_type; - typedef allocator_traits __alloc_traits; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_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; - - static_assert((!is_array::value), "Character type of basic_string must not be an array"); - static_assert(( is_standard_layout::value), "Character type of basic_string must be standard-layout"); - static_assert(( is_trivial::value), "Character type of basic_string must be trivial"); - static_assert(( is_same<_CharT, typename traits_type::char_type>::value), - "traits_type::char_type must be the same type as CharT"); - static_assert(( is_same::value), - "Allocator::value_type must be same type as value_type"); - - typedef __wrap_iter iterator; - typedef __wrap_iter const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + typedef basic_string __self; + typedef basic_string_view<_CharT, _Traits> __self_view; + typedef _Traits traits_type; + typedef _CharT value_type; + typedef _Allocator allocator_type; + typedef allocator_traits __alloc_traits; + typedef typename __alloc_traits::size_type size_type; + typedef typename __alloc_traits::difference_type difference_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; + + static_assert((!is_array::value), "Character type of basic_string must not be an array"); + static_assert((is_standard_layout::value), "Character type of basic_string must be standard-layout"); + static_assert((is_trivial::value), "Character type of basic_string must be trivial"); + static_assert( + (is_same<_CharT, typename traits_type::char_type>::value), + "traits_type::char_type must be the same type as CharT"); + static_assert( + (is_same::value), + "Allocator::value_type must be same type as value_type"); + + typedef __wrap_iter iterator; + typedef __wrap_iter const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; private: - #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT - struct __long - { - pointer __data_; - size_type __size_; - size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; - size_type __is_long_ : 1; - }; - - enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? - (sizeof(__long) - 1)/sizeof(value_type) : 2}; - - struct __short - { - value_type __data_[__min_cap]; - unsigned char __padding[sizeof(value_type) - 1]; - unsigned char __size_ : 7; - unsigned char __is_long_ : 1; - }; - -// The __endian_factor is required because the field we use to store the size -// (either size_type or unsigned char depending on long/short) has one fewer -// bit than it would if it were not a bitfield. -// -// If the LSB is used to store the short-flag in the short string representation, -// we have to multiply the size by two when it is stored and divide it by two when -// it is loaded to make sure that we always store an even number. In the long string -// representation, we can ignore this because we can assume that we always allocate -// an even amount of value_types. -// -// If the MSB is used for the short-flag, the max_size() is numeric_limits::max() / 2. -// This does not impact the short string representation, since we never need the MSB -// for representing the size of a short string anyway. - -#ifdef _LIBCPP_BIG_ENDIAN - static const size_type __endian_factor = 2; -#else - static const size_type __endian_factor = 1; -#endif + struct __long { + pointer __data_; + size_type __size_; + size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; + size_type __is_long_ : 1; + }; + + enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 }; + + struct __short { + value_type __data_[__min_cap]; + unsigned char __padding[sizeof(value_type) - 1]; + unsigned char __size_ : 7; + unsigned char __is_long_ : 1; + }; + + // The __endian_factor is required because the field we use to store the size + // (either size_type or unsigned char depending on long/short) has one fewer + // bit than it would if it were not a bitfield. + // + // If the LSB is used to store the short-flag in the short string representation, + // we have to multiply the size by two when it is stored and divide it by two when + // it is loaded to make sure that we always store an even number. In the long string + // representation, we can ignore this because we can assume that we always allocate + // an even amount of value_types. + // + // If the MSB is used for the short-flag, the max_size() is numeric_limits::max() / 2. + // This does not impact the short string representation, since we never need the MSB + // for representing the size of a short string anyway. + +# ifdef _LIBCPP_BIG_ENDIAN + static const size_type __endian_factor = 2; +# else + static const size_type __endian_factor = 1; +# endif #else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT -#ifdef _LIBCPP_BIG_ENDIAN - static const size_type __endian_factor = 1; -#else - static const size_type __endian_factor = 2; -#endif +# ifdef _LIBCPP_BIG_ENDIAN + static const size_type __endian_factor = 1; +# else + static const size_type __endian_factor = 2; +# endif - struct __long - { - size_type __is_long_ : 1; - size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; - size_type __size_; - pointer __data_; - }; + struct __long { + size_type __is_long_ : 1; + size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; + size_type __size_; + pointer __data_; + }; - enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? - (sizeof(__long) - 1)/sizeof(value_type) : 2}; - - struct __short - { - union - { - struct { - unsigned char __is_long_ : 1; - unsigned char __size_ : 7; - }; - value_type __lx; - }; - value_type __data_[__min_cap]; + enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 }; + + struct __short { + union { + struct { + unsigned char __is_long_ : 1; + unsigned char __size_ : 7; + }; + value_type __lx; }; + value_type __data_[__min_cap]; + }; #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT - union __ulx{__long __lx; __short __lxx;}; + union __ulx { + __long __lx; + __short __lxx; + }; - enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; + enum { __n_words = sizeof(__ulx) / sizeof(size_type) }; - struct __raw - { - size_type __words[__n_words]; - }; + struct __raw { + size_type __words[__n_words]; + }; - struct __rep - { - union - { - __long __l; - __short __s; - __raw __r; - }; + struct __rep { + union { + __long __l; + __short __s; + __raw __r; }; + }; - __compressed_pair<__rep, allocator_type> __r_; - - // Construct a string with the given allocator and enough storage to hold `__size` characters, but - // don't initialize the characters. The contents of the string, including the null terminator, must be - // initialized separately. - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a) - : __r_(__default_init_tag(), __a) { - if (__size > max_size()) - __throw_length_error(); - if (__fits_in_sso(__size)) { - __zero(); - __set_short_size(__size); - } else { - auto __capacity = __recommend(__size) + 1; - auto __allocation = __alloc_traits::allocate(__alloc(), __capacity); - __begin_lifetime(__allocation, __capacity); - __set_long_cap(__capacity); - __set_long_pointer(__allocation); - __set_long_size(__size); - } - std::__debug_db_insert_c(this); + __compressed_pair<__rep, allocator_type> __r_; + + // Construct a string with the given allocator and enough storage to hold `__size` characters, but + // don't initialize the characters. The contents of the string, including the null terminator, must be + // initialized separately. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string( + __uninitialized_size_tag, size_type __size, const allocator_type& __a) + : __r_(__default_init_tag(), __a) { + if (__size > max_size()) + __throw_length_error(); + if (__fits_in_sso(__size)) { + __zero(); + __set_short_size(__size); + } else { + auto __capacity = __recommend(__size) + 1; + auto __allocation = __alloc_traits::allocate(__alloc(), __capacity); + __begin_lifetime(__allocation, __capacity); + __set_long_cap(__capacity); + __set_long_pointer(__allocation); + __set_long_size(__size); } + std::__debug_db_insert_c(this); + } public: - _LIBCPP_TEMPLATE_DATA_VIS - static const size_type npos = -1; + _LIBCPP_TEMPLATE_DATA_VIS static const size_type npos = -1; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string() - _NOEXCEPT_(is_nothrow_default_constructible::value); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 - _NOEXCEPT_(is_nothrow_copy_constructible::value); + _NOEXCEPT_(is_nothrow_copy_constructible::value); #else - _NOEXCEPT; + _NOEXCEPT; #endif - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(basic_string&& __str) -#if _LIBCPP_STD_VER <= 14 - _NOEXCEPT_(is_nothrow_move_constructible::value); -#else - _NOEXCEPT; -#endif - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(basic_string&& __str, const allocator_type& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(basic_string&& __str) +# if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_move_constructible::value); +# else + _NOEXCEPT; +# endif + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(basic_string&& __str, const allocator_type& __a); #endif // _LIBCPP_CXX03_LANG - template ::value, nullptr_t> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { - _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); - __init(__s, traits_type::length(__s)); - std::__debug_db_insert_c(this); - } + template ::value, nullptr_t> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const _CharT* __s) + : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); + __init(__s, traits_type::length(__s)); + std::__debug_db_insert_c(this); + } - template ::value, nullptr_t> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const _CharT* __s, const _Allocator& __a); + template ::value, nullptr_t> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const _CharT* __s, const _Allocator& __a); #if _LIBCPP_STD_VER > 20 - basic_string(nullptr_t) = delete; + basic_string(nullptr_t) = delete; #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const _CharT* __s, size_type __n); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(size_type __n, _CharT __c); - - template ::value, nullptr_t> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(size_type __n, _CharT __c, const _Allocator& __a); - - _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const basic_string& __str, size_type __pos, size_type __n, - const _Allocator& __a = _Allocator()); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const basic_string& __str, size_type __pos, - const _Allocator& __a = _Allocator()); - - template::value && !__is_same_uncvref<_Tp, basic_string>::value> > - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(const _Tp& __t, size_type __pos, size_type __n, - const allocator_type& __a = allocator_type()); - - template::value && - !__is_same_uncvref<_Tp, basic_string>::value> > - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - explicit basic_string(const _Tp& __t); - - template::value && !__is_same_uncvref<_Tp, basic_string>::value> > - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - explicit basic_string(const _Tp& __t, const allocator_type& __a); - - template::value> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(_InputIterator __first, _InputIterator __last); - template::value> > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const _CharT* __s, size_type __n); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(size_type __n, _CharT __c); + + template ::value, nullptr_t> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(size_type __n, _CharT __c, const _Allocator& __a); + + _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()); + + template < + class _Tp, + class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string>::value> > + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()); + + template < + class _Tp, + class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string>::value> > + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string( + const _Tp& __t); + + template < + class _Tp, + class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string>::value> > + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string( + const _Tp& __t, const allocator_type& __a); + + template ::value> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(_InputIterator __first, _InputIterator __last); + template ::value> > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(initializer_list<_CharT> __il); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string(initializer_list<_CharT> __il, const _Allocator& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(initializer_list<_CharT> __il); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + basic_string(initializer_list<_CharT> __il, const _Allocator& __a); #endif // _LIBCPP_CXX03_LANG - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string(); + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string(); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 operator __self_view() const _NOEXCEPT { + return __self_view(data(), size()); + } - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str); - template ::value && - !__is_same_uncvref<_Tp, basic_string>::value> > - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) { - __self_view __sv = __t; - return assign(__sv); - } + template < + class _Tp, + class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string>::value> > + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) { + __self_view __sv = __t; + return assign(__sv); + } #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& operator=(basic_string&& __str) - _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + operator=(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(initializer_list __il) { + return assign(__il.begin(), __il.size()); + } #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& operator=(const value_type* __s) {return assign(__s);} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const value_type* __s) { + return assign(__s); + } #if _LIBCPP_STD_VER > 20 - basic_string& operator=(nullptr_t) = delete; + basic_string& operator=(nullptr_t) = delete; #endif - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c); #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator begin() _NOEXCEPT - {return iterator(this, __get_pointer());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator begin() const _NOEXCEPT - {return const_iterator(this, __get_pointer());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator end() _NOEXCEPT - {return iterator(this, __get_pointer() + size());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator end() const _NOEXCEPT - {return const_iterator(this, __get_pointer() + size());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin() _NOEXCEPT { + return iterator(this, __get_pointer()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator begin() const _NOEXCEPT { + return const_iterator(this, __get_pointer()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end() _NOEXCEPT { + return iterator(this, __get_pointer() + size()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator end() const _NOEXCEPT { + return const_iterator(this, __get_pointer() + size()); + } #else - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator begin() _NOEXCEPT - {return iterator(__get_pointer());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator begin() const _NOEXCEPT - {return const_iterator(__get_pointer());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator end() _NOEXCEPT - {return iterator(__get_pointer() + size());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator end() const _NOEXCEPT - {return const_iterator(__get_pointer() + size());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin() _NOEXCEPT { return iterator(__get_pointer()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator begin() const _NOEXCEPT { + return const_iterator(__get_pointer()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end() _NOEXCEPT { + return iterator(__get_pointer() + size()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator end() const _NOEXCEPT { + return const_iterator(__get_pointer() + size()); + } #endif // _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - reverse_iterator rbegin() _NOEXCEPT - {return reverse_iterator(end());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_reverse_iterator rbegin() const _NOEXCEPT - {return const_reverse_iterator(end());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - reverse_iterator rend() _NOEXCEPT - {return reverse_iterator(begin());} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_reverse_iterator rend() const _NOEXCEPT - {return const_reverse_iterator(begin());} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator cbegin() const _NOEXCEPT - {return begin();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_iterator cend() const _NOEXCEPT - {return end();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_reverse_iterator crbegin() const _NOEXCEPT - {return rbegin();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_reverse_iterator crend() const _NOEXCEPT - {return rend();} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT - {return __is_long() ? __get_long_size() : __get_short_size();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT { - return (__is_long() ? __get_long_cap() : static_cast(__min_cap)) - 1; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reverse_iterator rbegin() _NOEXCEPT { + return reverse_iterator(end()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator rbegin() const _NOEXCEPT { + return const_reverse_iterator(end()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reverse_iterator rend() _NOEXCEPT { + return reverse_iterator(begin()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator rend() const _NOEXCEPT { + return const_reverse_iterator(begin()); + } - _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator cbegin() const _NOEXCEPT { return begin(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_iterator cend() const _NOEXCEPT { return end(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator crbegin() const _NOEXCEPT { + return rbegin(); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT { + return __is_long() ? __get_long_size() : __get_short_size(); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT { return size(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT { + return (__is_long() ? __get_long_cap() : static_cast(__min_cap)) - 1; + } - _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); } + + _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity); #if _LIBCPP_STD_VER > 20 - template - _LIBCPP_HIDE_FROM_ABI constexpr - void resize_and_overwrite(size_type __n, _Op __op) { - __resize_default_init(__n); - __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); - } + template + _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { + __resize_default_init(__n); + __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); + } #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n); - _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT; + _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT; - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool empty() const _NOEXCEPT {return size() == 0;} + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool empty() const _NOEXCEPT { + return size() == 0; + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_reference operator[](size_type __pos) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __pos) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const; - _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) { - return append(__str); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) { + return append(__str); + } - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string >::value, - basic_string& - > - operator+=(const _Tp& __t) { - __self_view __sv = __t; return append(__sv); - } + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string >::value, + basic_string& > + operator+=(const _Tp& __t) { + __self_view __sv = __t; + return append(__sv); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) { - return append(__s); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) { + return append(__s); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) { - push_back(__c); - return *this; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) { + push_back(__c); + return *this; + } #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& operator+=(initializer_list __il) { return append(__il); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(initializer_list __il) { + return append(__il); + } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& append(const basic_string& __str); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t< - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string>::value, - basic_string& - > - append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string>::value, - basic_string& - > - append(const _Tp& __t, size_type __pos, size_type __n=npos); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c); - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __append_default_init(size_type __n); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - __enable_if_t - < - __is_exactly_cpp17_input_iterator<_InputIterator>::value, - basic_string& - > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - append(_InputIterator __first, _InputIterator __last) { - const basic_string __temp(__first, __last, __alloc()); - append(__temp.data(), __temp.size()); - return *this; - } - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS - __enable_if_t - < - __is_cpp17_forward_iterator<_ForwardIterator>::value, - basic_string& - > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - append(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + basic_string& > + append(const _Tp& __t) { + __self_view __sv = __t; + return append(__sv.data(), __sv.size()); + } + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n = npos); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + basic_string& > + append(const _Tp& __t, size_type __pos, size_type __n = npos); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c); + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append_default_init(size_type __n); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t< + __is_exactly_cpp17_input_iterator<_InputIterator>::value, + basic_string& > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + append(_InputIterator __first, _InputIterator __last) { + const basic_string __temp(__first, __last, __alloc()); + append(__temp.data(), __temp.size()); + return *this; + } + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS __enable_if_t< + __is_cpp17_forward_iterator<_ForwardIterator>::value, + basic_string& > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + append(_ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& append(initializer_list __il) {return append(__il.begin(), __il.size());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(initializer_list __il) { + return append(__il.begin(), __il.size()); + } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back(); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - basic_string& - > - assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& assign(const basic_string& __str) { return *this = __str; } + _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back(); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > + assign(const _Tp& __t) { + __self_view __sv = __t; + return assign(__sv.data(), __sv.size()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str) { + return *this = __str; + } #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& assign(basic_string&& __str) - _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) - {*this = std::move(__str); return *this;} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + assign(basic_string&& __str) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { + *this = std::move(__str); + return *this; + } #endif - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string>::value, - basic_string& - > - assign(const _Tp & __t, size_type __pos, size_type __n=npos); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_exactly_cpp17_input_iterator<_InputIterator>::value, - basic_string& - > - assign(_InputIterator __first, _InputIterator __last); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_cpp17_forward_iterator<_ForwardIterator>::value, - basic_string& - > - assign(_ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + basic_string& > + assign(const _Tp& __t, size_type __pos, size_type __n = npos); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_string& > + assign(_InputIterator __first, _InputIterator __last); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string& > + assign(_ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& assign(initializer_list __il) {return assign(__il.begin(), __il.size());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(initializer_list __il) { + return assign(__il.begin(), __il.size()); + } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& insert(size_type __pos1, const basic_string& __str); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - basic_string& - > - insert(size_type __pos1, const _Tp& __t) - { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, - basic_string& - > - insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); - _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c); - _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator insert(const_iterator __pos, size_type __n, value_type __c); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_exactly_cpp17_input_iterator<_InputIterator>::value, - iterator - > - insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_cpp17_forward_iterator<_ForwardIterator>::value, - iterator - > - insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos1, const basic_string& __str); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > + insert(size_type __pos1, const _Tp& __t) { + __self_view __sv = __t; + return insert(__pos1, __sv.data(), __sv.size()); + } + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + basic_string& > + insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c); + _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator + insert(const_iterator __pos, size_type __n, value_type __c); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __is_exactly_cpp17_input_iterator<_InputIterator>::value, iterator > + insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value, iterator > + insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator insert(const_iterator __pos, initializer_list __il) - {return insert(__pos, __il.begin(), __il.end());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator + insert(const_iterator __pos, initializer_list __il) { + return insert(__pos, __il.begin(), __il.end()); + } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator erase(const_iterator __pos); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - iterator erase(const_iterator __first, const_iterator __last); - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - basic_string& - > - replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } - _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, - basic_string& - > - replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); - _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - basic_string& - > - replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_cpp17_input_iterator<_InputIterator>::value, - basic_string& - > - replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __pos); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last); + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > + replace(size_type __pos1, size_type __n1, const _Tp& __t) { + __self_view __sv = __t; + return replace(__pos1, __n1, __sv.data(), __sv.size()); + } + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + basic_string& > + replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, basic_string& > + replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { + __self_view __sv = __t; + return replace(__i1 - begin(), __i2 - __i1, __sv); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(const_iterator __i1, const_iterator __i2, const value_type* __s); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __is_cpp17_input_iterator<_InputIterator>::value, basic_string& > + replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list __il) - {return replace(__i1, __i2, __il.begin(), __il.end());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + replace(const_iterator __i1, const_iterator __i2, initializer_list __il) { + return replace(__i1, __i2, __il.begin(), __il.end()); + } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string substr(size_type __pos = 0, size_type __n = npos) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string + substr(size_type __pos = 0, size_type __n = npos) const; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void swap(basic_string& __str) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(basic_string& __str) #if _LIBCPP_STD_VER >= 14 - _NOEXCEPT; + _NOEXCEPT; #else - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value); + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const value_type* c_str() const _NOEXCEPT {return data();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const value_type* c_str() const _NOEXCEPT { return data(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const value_type* data() const _NOEXCEPT { + return std::__to_address(__get_pointer()); + } #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 value_type* data() _NOEXCEPT { + return std::__to_address(__get_pointer()); + } #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - allocator_type get_allocator() const _NOEXCEPT {return __alloc();} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - size_type - > - find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - int compare(const basic_string& __str) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - int - > - compare(const _Tp &__t) const _NOEXCEPT; - - template - _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - int - > - compare(size_type __pos1, size_type __n1, const _Tp& __t) const; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, - size_type __n2 = npos) const; - - template - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, - int - > - compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; - _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT; - _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; - _LIBCPP_CONSTEXPR_AFTER_CXX17 - int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT { + return __alloc(); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, size_type > + find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type + find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const basic_string& __str) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > + compare(const _Tp& __t) const _NOEXCEPT; + + template + _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 + __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > + compare(size_type __pos1, size_type __n1, const _Tp& __t) const; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 int + compare(size_type __pos1, size_type __n1, const basic_string& __str) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 int + compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const; + + template + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, + int > + compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT; + _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; + _LIBCPP_CONSTEXPR_AFTER_CXX17 int + compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; #if _LIBCPP_STD_VER > 17 - constexpr _LIBCPP_HIDE_FROM_ABI - bool starts_with(__self_view __sv) const noexcept - { return __self_view(data(), size()).starts_with(__sv); } + constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { + return __self_view(data(), size()).starts_with(__sv); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool starts_with(value_type __c) const noexcept - { return !empty() && _Traits::eq(front(), __c); } + constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { + return !empty() && _Traits::eq(front(), __c); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool starts_with(const value_type* __s) const noexcept - { return starts_with(__self_view(__s)); } + constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept { + return starts_with(__self_view(__s)); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool ends_with(__self_view __sv) const noexcept - { return __self_view(data(), size()).ends_with( __sv); } + constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { + return __self_view(data(), size()).ends_with(__sv); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool ends_with(value_type __c) const noexcept - { return !empty() && _Traits::eq(back(), __c); } + constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { + return !empty() && _Traits::eq(back(), __c); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool ends_with(const value_type* __s) const noexcept - { return ends_with(__self_view(__s)); } + constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { + return ends_with(__self_view(__s)); + } #endif #if _LIBCPP_STD_VER > 20 - constexpr _LIBCPP_HIDE_FROM_ABI - bool contains(__self_view __sv) const noexcept - { return __self_view(data(), size()).contains(__sv); } + constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { + return __self_view(data(), size()).contains(__sv); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool contains(value_type __c) const noexcept - { return __self_view(data(), size()).contains(__c); } + constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { + return __self_view(data(), size()).contains(__c); + } - constexpr _LIBCPP_HIDE_FROM_ABI - bool contains(const value_type* __s) const - { return __self_view(data(), size()).contains(__s); } + constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { + return __self_view(data(), size()).contains(__s); + } #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT; #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; + 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: - template - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool friend operator==(const basic_string, _Alloc>& __lhs, - const basic_string, _Alloc>& __rhs) _NOEXCEPT; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity); - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool __is_long() const _NOEXCEPT { - if (__libcpp_is_constant_evaluated()) - return true; - return __r_.first().__s.__is_long_; - } + template + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool friend operator==( + const basic_string, _Alloc>& __lhs, + const basic_string, _Alloc>& __rhs) _NOEXCEPT; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity); - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_long() const _NOEXCEPT { + if (__libcpp_is_constant_evaluated()) + return true; + return __r_.first().__s.__is_long_; + } + + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) { #if _LIBCPP_STD_VER > 17 - if (__libcpp_is_constant_evaluated()) { - for (size_type __i = 0; __i != __n; ++__i) - std::construct_at(std::addressof(__begin[__i])); - } + if (__libcpp_is_constant_evaluated()) { + for (size_type __i = 0; __i != __n; ++__i) + std::construct_at(std::addressof(__begin[__i])); + } #else - (void)__begin; - (void)__n; + (void)__begin; + (void)__n; #endif // _LIBCPP_STD_VER > 17 - } + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() { - __zero(); - if (__libcpp_is_constant_evaluated()) { - size_type __sz = __recommend(0) + 1; - pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); - __begin_lifetime(__ptr, __sz); - __set_long_pointer(__ptr); - __set_long_cap(__sz); - __set_long_size(0); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() { + __zero(); + if (__libcpp_is_constant_evaluated()) { + size_type __sz = __recommend(0) + 1; + pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); + __begin_lifetime(__ptr, __sz); + __set_long_pointer(__ptr); + __set_long_cap(__sz); + __set_long_size(0); } + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() { - if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) - __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() { + if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) + __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); + } + + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { + // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly + return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); + } - _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { - // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly - return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); + template + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator + __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) { + size_type __sz = size(); + size_type __cap = capacity(); + value_type* __p; + if (__cap - __sz >= __n) { + __p = std::__to_address(__get_pointer()); + size_type __n_move = __sz - __ip; + if (__n_move != 0) + traits_type::move(__p + __ip + __n, __p + __ip, __n_move); + } else { + __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); + __p = std::__to_address(__get_long_pointer()); } + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + for (__p += __ip; __first != __last; ++__p, ++__first) + traits_type::assign(*__p, *__first); - template - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 - iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) { - size_type __sz = size(); - size_type __cap = capacity(); - value_type* __p; - if (__cap - __sz >= __n) - { - __p = std::__to_address(__get_pointer()); - size_type __n_move = __sz - __ip; - if (__n_move != 0) - traits_type::move(__p + __ip + __n, __p + __ip, __n_move); - } - else - { - __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); - __p = std::__to_address(__get_long_pointer()); - } - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); - for (__p += __ip; __first != __last; ++__p, ++__first) - traits_type::assign(*__p, *__first); + return begin() + __ip; + } - return begin() + __ip; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __set_short_size(size_type __s) _NOEXCEPT { + _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); + __r_.first().__s.__size_ = __s; + __r_.first().__s.__is_long_ = false; + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __set_short_size(size_type __s) _NOEXCEPT { - _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); - __r_.first().__s.__size_ = __s; - __r_.first().__s.__is_long_ = false; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __get_short_size() const _NOEXCEPT { + _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size"); + return __r_.first().__s.__size_; + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type __get_short_size() const _NOEXCEPT { - _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size"); - return __r_.first().__s.__size_; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __set_long_size(size_type __s) _NOEXCEPT { + __r_.first().__l.__size_ = __s; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __get_long_size() const _NOEXCEPT { + return __r_.first().__l.__size_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __set_size(size_type __s) _NOEXCEPT { + if (__is_long()) + __set_long_size(__s); + else + __set_short_size(__s); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __set_long_size(size_type __s) _NOEXCEPT - {__r_.first().__l.__size_ = __s;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type __get_long_size() const _NOEXCEPT - {return __r_.first().__l.__size_;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __set_size(size_type __s) _NOEXCEPT - {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __set_long_cap(size_type __s) _NOEXCEPT { - __r_.first().__l.__cap_ = __s / __endian_factor; - __r_.first().__l.__is_long_ = true; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __set_long_cap(size_type __s) _NOEXCEPT { + __r_.first().__l.__cap_ = __s / __endian_factor; + __r_.first().__l.__is_long_ = true; + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type __get_long_cap() const _NOEXCEPT { - return __r_.first().__l.__cap_ * __endian_factor; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __get_long_cap() const _NOEXCEPT { + return __r_.first().__l.__cap_ * __endian_factor; + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __set_long_pointer(pointer __p) _NOEXCEPT - {__r_.first().__l.__data_ = __p;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - pointer __get_long_pointer() _NOEXCEPT - {return __r_.first().__l.__data_;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_pointer __get_long_pointer() const _NOEXCEPT - {return __r_.first().__l.__data_;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - pointer __get_short_pointer() _NOEXCEPT - {return pointer_traits::pointer_to(__r_.first().__s.__data_[0]);} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_pointer __get_short_pointer() const _NOEXCEPT - {return pointer_traits::pointer_to(__r_.first().__s.__data_[0]);} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - pointer __get_pointer() _NOEXCEPT - {return __is_long() ? __get_long_pointer() : __get_short_pointer();} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - const_pointer __get_pointer() const _NOEXCEPT - {return __is_long() ? __get_long_pointer() : __get_short_pointer();} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __zero() _NOEXCEPT { - __r_.first() = __rep(); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __set_long_pointer(pointer __p) _NOEXCEPT { + __r_.first().__l.__data_ = __p; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __get_long_pointer() _NOEXCEPT { + return __r_.first().__l.__data_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_pointer __get_long_pointer() const _NOEXCEPT { + return __r_.first().__l.__data_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __get_short_pointer() _NOEXCEPT { + return pointer_traits::pointer_to(__r_.first().__s.__data_[0]); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_pointer __get_short_pointer() const _NOEXCEPT { + return pointer_traits::pointer_to(__r_.first().__s.__data_[0]); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __get_pointer() _NOEXCEPT { + return __is_long() ? __get_long_pointer() : __get_short_pointer(); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_pointer __get_pointer() const _NOEXCEPT { + return __is_long() ? __get_long_pointer() : __get_short_pointer(); + } - template static - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type __align_it(size_type __s) _NOEXCEPT - {return (__s + (__a-1)) & ~(__a-1);} - enum {__alignment = 16}; - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - size_type __recommend(size_type __s) _NOEXCEPT - { - if (__s < __min_cap) { - if (__libcpp_is_constant_evaluated()) - return static_cast(__min_cap); - else - return static_cast(__min_cap) - 1; - } - size_type __guess = __align_it (__s+1) - 1; - if (__guess == __min_cap) ++__guess; - return __guess; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __zero() _NOEXCEPT { __r_.first() = __rep(); } - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __init(const value_type* __s, size_type __sz, size_type __reserve); - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __init(const value_type* __s, size_type __sz); - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __init(size_type __n, value_type __c); - - // Slow path for the (inlined) copy constructor for 'long' strings. - // Always externally instantiated and not inlined. - // Requires that __s is zero terminated. - // The main reason for this function to exist is because for unstable, we - // want to allow inlining of the copy constructor. However, we don't want - // to call the __init() functions as those are marked as inline which may - // result in over-aggressive inlining by the compiler, where our aim is - // to only inline the fast path code directly in the ctor. - _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz); - - template - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_exactly_cpp17_input_iterator<_InputIterator>::value - > - __init(_InputIterator __first, _InputIterator __last); - - template - inline _LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __is_cpp17_forward_iterator<_ForwardIterator>::value - > - __init(_ForwardIterator __first, _ForwardIterator __last); - - _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, - size_type __n_copy, size_type __n_del, size_type __n_add = 0); - _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, - size_type __n_copy, size_type __n_del, - size_type __n_add, const value_type* __p_new_stuff); - - // __assign_no_alias is invoked for assignment operations where we - // have proof that the input does not alias the current instance. - // For example, operator=(basic_string) performs a 'self' check. - template - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n); - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __erase_to_end(size_type __pos); - - // __erase_external_with_move is invoked for erase() invocations where - // `n ~= npos`, likely requiring memory moves on the string data. - _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n); - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __copy_assign_alloc(const basic_string& __str) - {__copy_assign_alloc(__str, integral_constant());} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __copy_assign_alloc(const basic_string& __str, true_type) - { - if (__alloc() == __str.__alloc()) - __alloc() = __str.__alloc(); - else - { - if (!__str.__is_long()) - { - __clear_and_shrink(); - __alloc() = __str.__alloc(); - } - else - { - allocator_type __a = __str.__alloc(); - auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); - __begin_lifetime(__allocation.ptr, __allocation.count); - __clear_and_shrink(); - __alloc() = std::move(__a); - __set_long_pointer(__allocation.ptr); - __set_long_cap(__allocation.count); - __set_long_size(__str.size()); - } - } - } + template + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __align_it(size_type __s) _NOEXCEPT { + return (__s + (__a - 1)) & ~(__a - 1); + } + enum { __alignment = 16 }; + static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __s) _NOEXCEPT { + if (__s < __min_cap) { + if (__libcpp_is_constant_evaluated()) + return static_cast(__min_cap); + else + return static_cast(__min_cap) - 1; + } + size_type __guess + = __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1; + if (__guess == __min_cap) + ++__guess; + return __guess; + } + + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init(const value_type* __s, size_type __sz, size_type __reserve); + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init(const value_type* __s, size_type __sz); + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init(size_type __n, value_type __c); + + // Slow path for the (inlined) copy constructor for 'long' strings. + // Always externally instantiated and not inlined. + // Requires that __s is zero terminated. + // The main reason for this function to exist is because for unstable, we + // want to allow inlining of the copy constructor. However, we don't want + // to call the __init() functions as those are marked as inline which may + // result in over-aggressive inlining by the compiler, where our aim is + // to only inline the fast path code directly in the ctor. + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz); + + template + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __is_exactly_cpp17_input_iterator<_InputIterator>::value > + __init(_InputIterator __first, _InputIterator __last); + + template + inline _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value > + __init(_ForwardIterator __first, _ForwardIterator __last); + + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __grow_by( + size_type __old_cap, + size_type __delta_cap, + size_type __old_sz, + size_type __n_copy, + size_type __n_del, + size_type __n_add = 0); + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __grow_by_and_replace( + size_type __old_cap, + size_type __delta_cap, + size_type __old_sz, + size_type __n_copy, + size_type __n_del, + size_type __n_add, + const value_type* __p_new_stuff); + + // __assign_no_alias is invoked for assignment operations where we + // have proof that the input does not alias the current instance. + // For example, operator=(basic_string) performs a 'self' check. + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n); + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_to_end(size_type __pos); + + // __erase_external_with_move is invoked for erase() invocations where + // `n ~= npos`, likely requiring memory moves on the string data. + _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n); + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __copy_assign_alloc(const basic_string& __str) { + __copy_assign_alloc( + __str, integral_constant()); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __copy_assign_alloc(const basic_string& __str, true_type) { + if (__alloc() == __str.__alloc()) + __alloc() = __str.__alloc(); + else { + if (!__str.__is_long()) { + __clear_and_shrink(); + __alloc() = __str.__alloc(); + } else { + allocator_type __a = __str.__alloc(); + auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); + __begin_lifetime(__allocation.ptr, __allocation.count); + __clear_and_shrink(); + __alloc() = std::move(__a); + __set_long_pointer(__allocation.ptr); + __set_long_cap(__allocation.count); + __set_long_size(__str.size()); + } + } + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT - {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void + __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __move_assign(basic_string& __str, false_type) - _NOEXCEPT_(__alloc_traits::is_always_equal::value); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __move_assign(basic_string& __str, true_type) -#if _LIBCPP_STD_VER > 14 - _NOEXCEPT; -#else - _NOEXCEPT_(is_nothrow_move_assignable::value); -#endif + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void + __move_assign(basic_string& __str, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(basic_string& __str, true_type) +# if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +# else + _NOEXCEPT_(is_nothrow_move_assignable::value); +# endif #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void - __move_assign_alloc(basic_string& __str) - _NOEXCEPT_( - !__alloc_traits::propagate_on_container_move_assignment::value || - is_nothrow_move_assignable::value) - {__move_assign_alloc(__str, integral_constant());} - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __move_assign_alloc(basic_string& __c, true_type) - _NOEXCEPT_(is_nothrow_move_assignable::value) - { - __alloc() = std::move(__c.__alloc()); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign_alloc(basic_string& __str) _NOEXCEPT_( + !__alloc_traits::propagate_on_container_move_assignment::value + || is_nothrow_move_assignable::value) { + __move_assign_alloc( + __str, integral_constant()); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - void __move_assign_alloc(basic_string&, false_type) - _NOEXCEPT - {} - - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s); - _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n); - - // Assigns the value in __s, guaranteed to be __n < __min_cap in length. - inline basic_string& __assign_short(const value_type* __s, size_type __n) { - pointer __p = __is_long() - ? (__set_long_size(__n), __get_long_pointer()) - : (__set_short_size(__n), __get_short_pointer()); - traits_type::move(std::__to_address(__p), __s, __n); - traits_type::assign(__p[__n], value_type()); - return *this; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void + __move_assign_alloc(basic_string& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value) { + __alloc() = std::move(__c.__alloc()); + } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { - __set_size(__newsz); - __invalidate_iterators_past(__newsz); - traits_type::assign(__p[__newsz], value_type()); - return *this; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_all_iterators(); - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type); - - template - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - bool __addr_in_range(_Tp&& __t) const { - // assume that the ranges overlap, because we can't check during constant evaluation - if (__libcpp_is_constant_evaluated()) - return true; - const volatile void *__p = std::addressof(__t); - return data() <= __p && __p <= data() + size(); - } + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s); + _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n); - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI - void __throw_length_error() const { - std::__throw_length_error("basic_string"); - } + // Assigns the value in __s, guaranteed to be __n < __min_cap in length. + inline basic_string& __assign_short(const value_type* __s, size_type __n) { + pointer __p + = __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer()); + traits_type::move(std::__to_address(__p), __s, __n); + traits_type::assign(__p[__n], value_type()); + return *this; + } - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI - void __throw_out_of_range() const { - std::__throw_out_of_range("basic_string"); - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& + __null_terminate_at(value_type* __p, size_type __newsz) { + __set_size(__newsz); + __invalidate_iterators_past(__newsz); + traits_type::assign(__p[__newsz], value_type()); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_all_iterators(); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type); + + template + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __addr_in_range(_Tp&& __t) const { + // assume that the ranges overlap, because we can't check during constant evaluation + if (__libcpp_is_constant_evaluated()) + return true; + const volatile void* __p = std::addressof(__t); + return data() <= __p && __p <= data() + size(); + } + + _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { + std::__throw_length_error("basic_string"); + } - friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&); - friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&); - friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&); - friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*); - friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type); + _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { + std::__throw_out_of_range("basic_string"); + } + + friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&); + friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&); + friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&); + friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*); + friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type); }; // These declarations must appear before any functions are implicitly used // so that they have the correct visibility specifier. #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) -# endif +_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) +# endif #else - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) -# endif +_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) +# endif #endif - #if _LIBCPP_STD_VER >= 17 -template, - class _Allocator = allocator<_CharT>, - class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, - class = enable_if_t<__is_allocator<_Allocator>::value> - > +template < + class _InputIterator, + class _CharT = __iter_value_type<_InputIterator>, + class _Allocator = allocator<_CharT>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, + class = enable_if_t<__is_allocator<_Allocator>::value> > basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) - -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; + -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; -template, - class = enable_if_t<__is_allocator<_Allocator>::value> - > +template < + class _CharT, + class _Traits, + class _Allocator = allocator<_CharT>, + class = enable_if_t<__is_allocator<_Allocator>::value> > explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) - -> basic_string<_CharT, _Traits, _Allocator>; - -template, - class = enable_if_t<__is_allocator<_Allocator>::value>, - class _Sz = typename allocator_traits<_Allocator>::size_type - > + -> basic_string<_CharT, _Traits, _Allocator>; + +template < + class _CharT, + class _Traits, + class _Allocator = allocator<_CharT>, + class = enable_if_t<__is_allocator<_Allocator>::value>, + class _Sz = typename allocator_traits<_Allocator>::size_type > basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) - -> basic_string<_CharT, _Traits, _Allocator>; + -> basic_string<_CharT, _Traits, _Allocator>; #endif template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() -{ +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() { #if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__invalidate_all(this); + if (!__libcpp_is_constant_evaluated()) + __get_db()->__invalidate_all(this); #endif } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) -{ +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) { #if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) { - __c_node* __c = __get_db()->__find_c_and_lock(this); - if (__c) - { - const_pointer __new_last = __get_pointer() + __pos; - for (__i_node** __p = __c->end_; __p != __c->beg_; ) - { - --__p; - const_iterator* __i = static_cast((*__p)->__i_); - if (__i->base() > __new_last) - { - (*__p)->__c_ = nullptr; - if (--__c->end_ != __p) - std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); - } - } - __get_db()->unlock(); + if (!__libcpp_is_constant_evaluated()) { + __c_node* __c = __get_db()->__find_c_and_lock(this); + if (__c) { + const_pointer __new_last = __get_pointer() + __pos; + for (__i_node** __p = __c->end_; __p != __c->beg_;) { + --__p; + const_iterator* __i = static_cast((*__p)->__i_); + if (__i->base() > __new_last) { + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + std::memmove(__p, __p + 1, (__c->end_ - __p) * sizeof(__i_node*)); } + } + __get_db()->unlock(); } + } #else - (void)__pos; + (void)__pos; #endif // _LIBCPP_DEBUG_LEVEL == 2 } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string() +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __r_(__default_init_tag(), __default_init_tag()) -{ - std::__debug_db_insert_c(this); - __default_init(); + : __r_(__default_init_tag(), __default_init_tag()) { + std::__debug_db_insert_c(this); + __default_init(); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 - _NOEXCEPT_(is_nothrow_copy_constructible::value) + _NOEXCEPT_(is_nothrow_copy_constructible::value) #else - _NOEXCEPT + _NOEXCEPT #endif -: __r_(__default_init_tag(), __a) -{ - std::__debug_db_insert_c(this); - __default_init(); + : __r_(__default_init_tag(), __a) { + std::__debug_db_insert_c(this); + __default_init(); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, - size_type __sz, - size_type __reserve) -{ - if (__libcpp_is_constant_evaluated()) - __zero(); - if (__reserve > max_size()) - __throw_length_error(); - pointer __p; - if (__fits_in_sso(__reserve)) - { - __set_short_size(__sz); - __p = __get_short_pointer(); - } - else - { - auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1); - __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); - __set_long_size(__sz); - } - traits_type::copy(std::__to_address(__p), __s, __sz); - traits_type::assign(__p[__sz], value_type()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { + if (__libcpp_is_constant_evaluated()) + __zero(); + if (__reserve > max_size()) + __throw_length_error(); + pointer __p; + if (__fits_in_sso(__reserve)) { + __set_short_size(__sz); + __p = __get_short_pointer(); + } else { + auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1); + __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); + __set_long_size(__sz); + } + traits_type::copy(std::__to_address(__p), __s, __sz); + traits_type::assign(__p[__sz], value_type()); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) -{ - if (__libcpp_is_constant_evaluated()) - __zero(); - if (__sz > max_size()) - __throw_length_error(); - pointer __p; - if (__fits_in_sso(__sz)) - { - __set_short_size(__sz); - __p = __get_short_pointer(); - } - else - { - auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); - __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); - __set_long_size(__sz); - } - traits_type::copy(std::__to_address(__p), __s, __sz); - traits_type::assign(__p[__sz], value_type()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { + if (__libcpp_is_constant_evaluated()) + __zero(); + if (__sz > max_size()) + __throw_length_error(); + pointer __p; + if (__fits_in_sso(__sz)) { + __set_short_size(__sz); + __p = __get_short_pointer(); + } else { + auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); + __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); + __set_long_size(__sz); + } + traits_type::copy(std::__to_address(__p), __s, __sz); + traits_type::assign(__p[__sz], value_type()); } template template _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); - __init(__s, traits_type::length(__s)); - std::__debug_db_insert_c(this); + : __r_(__default_init_tag(), __a) { + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); + __init(__s, traits_type::length(__s)); + std::__debug_db_insert_c(this); } template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) - : __r_(__default_init_tag(), __default_init_tag()) -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); - __init(__s, __n); - std::__debug_db_insert_c(this); + : __r_(__default_init_tag(), __default_init_tag()) { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); + __init(__s, __n); + std::__debug_db_insert_c(this); } template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); - __init(__s, __n); - std::__debug_db_insert_c(this); + : __r_(__default_init_tag(), __a) { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); + __init(__s, __n); + std::__debug_db_insert_c(this); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) - : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) -{ - if (!__str.__is_long()) - __r_.first().__r = __str.__r_.first().__r; - else - __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), - __str.__get_long_size()); - std::__debug_db_insert_c(this); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) + : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { + if (!__str.__is_long()) + __r_.first().__r = __str.__r_.first().__r; + else + __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); + std::__debug_db_insert_c(this); } template _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string( - const basic_string& __str, const allocator_type& __a) - : __r_(__default_init_tag(), __a) -{ - if (!__str.__is_long()) - __r_.first().__r = __str.__r_.first().__r; - else - __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), - __str.__get_long_size()); - std::__debug_db_insert_c(this); +basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, const allocator_type& __a) + : __r_(__default_init_tag(), __a) { + if (!__str.__is_long()) + __r_.first().__r = __str.__r_.first().__r; + else + __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); + std::__debug_db_insert_c(this); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( - const value_type* __s, size_type __sz) { +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) { if (__libcpp_is_constant_evaluated()) __zero(); pointer __p; @@ -2054,7 +1876,7 @@ if (__sz > max_size()) __throw_length_error(); auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); - __p = __allocation.ptr; + __p = __allocation.ptr; __begin_lifetime(__p, __allocation.count); __set_long_pointer(__p); __set_long_cap(__allocation.count); @@ -2066,365 +1888,311 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) -#if _LIBCPP_STD_VER <= 14 - _NOEXCEPT_(is_nothrow_move_constructible::value) -#else - _NOEXCEPT -#endif - : __r_(std::move(__str.__r_)) -{ - __str.__default_init(); - std::__debug_db_insert_c(this); -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated() && __is_long()) - __get_db()->swap(this, &__str); -#endif +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) +# if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_move_constructible::value) +# else + _NOEXCEPT +# endif + : __r_(std::move(__str.__r_)) { + __str.__default_init(); + std::__debug_db_insert_c(this); +# if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated() && __is_long()) + __get_db()->swap(this, &__str); +# endif } template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) - : __r_(__default_init_tag(), __a) -{ - if (__str.__is_long() && __a != __str.__alloc()) // copy, not move - __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); - else - { - if (__libcpp_is_constant_evaluated()) { - __zero(); - __r_.first().__l = __str.__r_.first().__l; - } else { - __r_.first().__r = __str.__r_.first().__r; - } - __str.__default_init(); + : __r_(__default_init_tag(), __a) { + if (__str.__is_long() && __a != __str.__alloc()) // copy, not move + __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); + else { + if (__libcpp_is_constant_evaluated()) { + __zero(); + __r_.first().__l = __str.__r_.first().__l; + } else { + __r_.first().__r = __str.__r_.first().__r; } - std::__debug_db_insert_c(this); -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated() && __is_long()) - __get_db()->swap(this, &__str); -#endif + __str.__default_init(); + } + std::__debug_db_insert_c(this); +# if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated() && __is_long()) + __get_db()->swap(this, &__str); +# endif } #endif // _LIBCPP_CXX03_LANG template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) -{ - if (__libcpp_is_constant_evaluated()) - __zero(); - if (__n > max_size()) - __throw_length_error(); - pointer __p; - if (__fits_in_sso(__n)) - { - __set_short_size(__n); - __p = __get_short_pointer(); - } - else - { - auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1); - __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); - __set_long_size(__n); - } - traits_type::assign(std::__to_address(__p), __n, __c); - traits_type::assign(__p[__n], value_type()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { + if (__libcpp_is_constant_evaluated()) + __zero(); + if (__n > max_size()) + __throw_length_error(); + pointer __p; + if (__fits_in_sso(__n)) { + __set_short_size(__n); + __p = __get_short_pointer(); + } else { + auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1); + __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); + __set_long_size(__n); + } + traits_type::assign(std::__to_address(__p), __n, __c); + traits_type::assign(__p[__n], value_type()); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) - : __r_(__default_init_tag(), __default_init_tag()) -{ - __init(__n, __c); - std::__debug_db_insert_c(this); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) + : __r_(__default_init_tag(), __default_init_tag()) { + __init(__n, __c); + std::__debug_db_insert_c(this); } template template _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - __init(__n, __c); - std::__debug_db_insert_c(this); + : __r_(__default_init_tag(), __a) { + __init(__n, __c); + std::__debug_db_insert_c(this); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, - size_type __pos, size_type __n, - const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - size_type __str_sz = __str.size(); - if (__pos > __str_sz) - __throw_out_of_range(); - __init(__str.data() + __pos, std::min(__n, __str_sz - __pos)); - std::__debug_db_insert_c(this); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string( + const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a) + : __r_(__default_init_tag(), __a) { + size_type __str_sz = __str.size(); + if (__pos > __str_sz) + __throw_out_of_range(); + __init(__str.data() + __pos, std::min(__n, __str_sz - __pos)); + std::__debug_db_insert_c(this); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, - const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - size_type __str_sz = __str.size(); - if (__pos > __str_sz) - __throw_out_of_range(); - __init(__str.data() + __pos, __str_sz - __pos); - std::__debug_db_insert_c(this); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string( + const basic_string& __str, size_type __pos, const _Allocator& __a) + : __r_(__default_init_tag(), __a) { + size_type __str_sz = __str.size(); + if (__pos > __str_sz) + __throw_out_of_range(); + __init(__str.data() + __pos, __str_sz - __pos); + std::__debug_db_insert_c(this); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string( - const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) - : __r_(__default_init_tag(), __a) -{ - __self_view __sv0 = __t; - __self_view __sv = __sv0.substr(__pos, __n); - __init(__sv.data(), __sv.size()); - std::__debug_db_insert_c(this); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string( + const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) + : __r_(__default_init_tag(), __a) { + __self_view __sv0 = __t; + __self_view __sv = __sv0.substr(__pos, __n); + __init(__sv.data(), __sv.size()); + std::__debug_db_insert_c(this); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) - : __r_(__default_init_tag(), __default_init_tag()) -{ - __self_view __sv = __t; - __init(__sv.data(), __sv.size()); - std::__debug_db_insert_c(this); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp& __t) + : __r_(__default_init_tag(), __default_init_tag()) { + __self_view __sv = __t; + __init(__sv.data(), __sv.size()); + std::__debug_db_insert_c(this); } template template _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - __self_view __sv = __t; - __init(__sv.data(), __sv.size()); - std::__debug_db_insert_c(this); +basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp& __t, const _Allocator& __a) + : __r_(__default_init_tag(), __a) { + __self_view __sv = __t; + __init(__sv.data(), __sv.size()); + std::__debug_db_insert_c(this); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_exactly_cpp17_input_iterator<_InputIterator>::value -> -basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) -{ - __default_init(); +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __is_exactly_cpp17_input_iterator<_InputIterator>::value > +basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) { + __default_init(); #ifndef _LIBCPP_NO_EXCEPTIONS - try - { + try { #endif // _LIBCPP_NO_EXCEPTIONS for (; __first != __last; ++__first) - push_back(*__first); + push_back(*__first); #ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - if (__is_long()) - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); - throw; - } + } catch (...) { + if (__is_long()) + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); + throw; + } #endif // _LIBCPP_NO_EXCEPTIONS } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_cpp17_forward_iterator<_ForwardIterator>::value -> -basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) -{ - if (__libcpp_is_constant_evaluated()) - __zero(); - size_type __sz = static_cast(std::distance(__first, __last)); - if (__sz > max_size()) - __throw_length_error(); - pointer __p; - if (__fits_in_sso(__sz)) - { - __set_short_size(__sz); - __p = __get_short_pointer(); - } - else - { - auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); - __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); - __set_long_size(__sz); - } +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value > +basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) { + if (__libcpp_is_constant_evaluated()) + __zero(); + size_type __sz = static_cast(std::distance(__first, __last)); + if (__sz > max_size()) + __throw_length_error(); + pointer __p; + if (__fits_in_sso(__sz)) { + __set_short_size(__sz); + __p = __get_short_pointer(); + } else { + auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); + __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); + __set_long_size(__sz); + } #ifndef _LIBCPP_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_NO_EXCEPTIONS - for (; __first != __last; ++__first, (void) ++__p) - traits_type::assign(*__p, *__first); + try { +#endif // _LIBCPP_NO_EXCEPTIONS + for (; __first != __last; ++__first, (void)++__p) + traits_type::assign(*__p, *__first); traits_type::assign(*__p, value_type()); #ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - if (__is_long()) - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); - throw; - } -#endif // _LIBCPP_NO_EXCEPTIONS + } catch (...) { + if (__is_long()) + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS } template -template +template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) - : __r_(__default_init_tag(), __default_init_tag()) -{ - __init(__first, __last); - std::__debug_db_insert_c(this); + : __r_(__default_init_tag(), __default_init_tag()) { + __init(__first, __last); + std::__debug_db_insert_c(this); } template -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, - const allocator_type& __a) - : __r_(__default_init_tag(), __a) -{ - __init(__first, __last); - std::__debug_db_insert_c(this); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::basic_string( + _InputIterator __first, _InputIterator __last, const allocator_type& __a) + : __r_(__default_init_tag(), __a) { + __init(__first, __last); + std::__debug_db_insert_c(this); } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string( - initializer_list<_CharT> __il) - : __r_(__default_init_tag(), __default_init_tag()) -{ - __init(__il.begin(), __il.end()); - std::__debug_db_insert_c(this); +basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<_CharT> __il) + : __r_(__default_init_tag(), __default_init_tag()) { + __init(__il.begin(), __il.end()); + std::__debug_db_insert_c(this); } template inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::basic_string( - initializer_list<_CharT> __il, const _Allocator& __a) - : __r_(__default_init_tag(), __a) -{ - __init(__il.begin(), __il.end()); - std::__debug_db_insert_c(this); +basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<_CharT> __il, const _Allocator& __a) + : __r_(__default_init_tag(), __a) { + __init(__il.begin(), __il.end()); + std::__debug_db_insert_c(this); } #endif // _LIBCPP_CXX03_LANG template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::~basic_string() -{ +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::~basic_string() { #if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__erase_c(this); + if (!__libcpp_is_constant_evaluated()) + __get_db()->__erase_c(this); #endif - if (__is_long()) - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); -} - -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace - (size_type __old_cap, size_type __delta_cap, size_type __old_sz, - size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff) -{ - size_type __ms = max_size(); - if (__delta_cap > __ms - __old_cap - 1) - __throw_length_error(); - pointer __old_p = __get_pointer(); - size_type __cap = __old_cap < __ms / 2 - __alignment ? - __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : - __ms - 1; - auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); - pointer __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __invalidate_all_iterators(); - if (__n_copy != 0) - traits_type::copy(std::__to_address(__p), - std::__to_address(__old_p), __n_copy); - if (__n_add != 0) - traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); - size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; - if (__sec_cp_sz != 0) - traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, - std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); - if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated()) - __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); - __old_sz = __n_copy + __n_add + __sec_cp_sz; - __set_long_size(__old_sz); - traits_type::assign(__p[__old_sz], value_type()); -} - -template -void -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, - size_type __n_copy, size_type __n_del, size_type __n_add) -{ - size_type __ms = max_size(); - if (__delta_cap > __ms - __old_cap) - __throw_length_error(); - pointer __old_p = __get_pointer(); - size_type __cap = __old_cap < __ms / 2 - __alignment ? - __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : - __ms - 1; - auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); - pointer __p = __allocation.ptr; - __begin_lifetime(__p, __allocation.count); - __invalidate_all_iterators(); - if (__n_copy != 0) - traits_type::copy(std::__to_address(__p), - std::__to_address(__old_p), __n_copy); - size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; - if (__sec_cp_sz != 0) - traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, - std::__to_address(__old_p) + __n_copy + __n_del, - __sec_cp_sz); - if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap) - __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); - __set_long_pointer(__p); - __set_long_cap(__allocation.count); + if (__is_long()) + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace( + size_type __old_cap, + size_type __delta_cap, + size_type __old_sz, + size_type __n_copy, + size_type __n_del, + size_type __n_add, + const value_type* __p_new_stuff) { + size_type __ms = max_size(); + if (__delta_cap > __ms - __old_cap - 1) + __throw_length_error(); + pointer __old_p = __get_pointer(); + size_type __cap + = __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; + auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); + pointer __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __invalidate_all_iterators(); + if (__n_copy != 0) + traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); + if (__n_add != 0) + traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); + size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; + if (__sec_cp_sz != 0) + traits_type::copy( + std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); + if (__old_cap + 1 != __min_cap || __libcpp_is_constant_evaluated()) + __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); + __old_sz = __n_copy + __n_add + __sec_cp_sz; + __set_long_size(__old_sz); + traits_type::assign(__p[__old_sz], value_type()); +} + +template +void _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::__grow_by( + size_type __old_cap, + size_type __delta_cap, + size_type __old_sz, + size_type __n_copy, + size_type __n_del, + size_type __n_add) { + size_type __ms = max_size(); + if (__delta_cap > __ms - __old_cap) + __throw_length_error(); + pointer __old_p = __get_pointer(); + size_type __cap + = __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; + auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); + pointer __p = __allocation.ptr; + __begin_lifetime(__p, __allocation.count); + __invalidate_all_iterators(); + if (__n_copy != 0) + traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); + size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; + if (__sec_cp_sz != 0) + traits_type::copy( + std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); + if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap) + __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); + __set_long_pointer(__p); + __set_long_cap(__allocation.count); } // assign template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( - const value_type* __s, size_type __n) { +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) { size_type __cap = __is_short ? static_cast(__min_cap) : __get_long_cap(); if (__n < __cap) { pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); @@ -2440,10 +2208,8 @@ } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::__assign_external( - const value_type* __s, size_type __n) { +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) { size_type __cap = capacity(); if (__cap >= __n) { value_type* __p = std::__to_address(__get_pointer()); @@ -2457,59 +2223,45 @@ } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); - return (__builtin_constant_p(__n) && __fits_in_sso(__n)) - ? __assign_short(__s, __n) - : __assign_external(__s, __n); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); + return (__builtin_constant_p(__n) && __fits_in_sso(__n)) ? __assign_short(__s, __n) : __assign_external(__s, __n); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) -{ - size_type __cap = capacity(); - if (__cap < __n) - { - size_type __sz = size(); - __grow_by(__cap, __n - __cap, __sz, 0, __sz); - } - value_type* __p = std::__to_address(__get_pointer()); - traits_type::assign(__p, __n, __c); - return __null_terminate_at(__p, __n); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) { + size_type __cap = capacity(); + if (__cap < __n) { + size_type __sz = size(); + __grow_by(__cap, __n - __cap, __sz, 0, __sz); + } + value_type* __p = std::__to_address(__get_pointer()); + traits_type::assign(__p, __n, __c); + return __null_terminate_at(__p, __n); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) -{ - pointer __p; - if (__is_long()) - { - __p = __get_long_pointer(); - __set_long_size(1); - } - else - { - __p = __get_short_pointer(); - __set_short_size(1); - } - traits_type::assign(*__p, __c); - traits_type::assign(*++__p, value_type()); - __invalidate_iterators_past(1); - return *this; +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) { + pointer __p; + if (__is_long()) { + __p = __get_long_pointer(); + __set_long_size(1); + } else { + __p = __get_short_pointer(); + __set_short_size(1); + } + traits_type::assign(*__p, __c); + traits_type::assign(*++__p, value_type()); + __invalidate_iterators_past(1); + return *this; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) -{ +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) { if (this != &__str) { __copy_assign_alloc(__str); if (!__is_long()) { @@ -2528,36 +2280,32 @@ #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) - _NOEXCEPT_(__alloc_traits::is_always_equal::value) -{ - if (__alloc() != __str.__alloc()) - assign(__str); - else - __move_assign(__str, true_type()); + _NOEXCEPT_(__alloc_traits::is_always_equal::value) { + if (__alloc() != __str.__alloc()) + assign(__str); + else + __move_assign(__str, true_type()); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) -#if _LIBCPP_STD_VER > 14 +# if _LIBCPP_STD_VER > 14 _NOEXCEPT -#else +# else _NOEXCEPT_(is_nothrow_move_assignable::value) -#endif +# endif { if (__is_long()) { - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), - __get_long_cap()); -#if _LIBCPP_STD_VER <= 14 + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); +# if _LIBCPP_STD_VER <= 14 if (!is_nothrow_move_assignable::value) { __set_short_size(0); traits_type::assign(__get_short_pointer()[0], value_type()); } -#endif +# endif } __move_assign_alloc(__str); __r_.first() = __str.__r_.first(); @@ -2570,507 +2318,407 @@ } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) - _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) -{ - __move_assign(__str, integral_constant()); - return *this; + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { + __move_assign(__str, integral_constant()); + return *this; } #endif template -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_exactly_cpp17_input_iterator<_InputIterator>::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) -{ - const basic_string __temp(__first, __last, __alloc()); - assign(__temp.data(), __temp.size()); - return *this; +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __is_exactly_cpp17_input_iterator<_InputIterator>::value, + basic_string<_CharT, _Traits, _Allocator>& > +basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { + const basic_string __temp(__first, __last, __alloc()); + assign(__temp.data(), __temp.size()); + return *this; } template -template +template _LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_cpp17_forward_iterator<_ForwardIterator>::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) -{ - size_type __cap = capacity(); - size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ? - static_cast(std::distance(__first, __last)) : 0; - - if (__string_is_trivial_iterator<_ForwardIterator>::value && - (__cap >= __n || !__addr_in_range(*__first))) - { - if (__cap < __n) - { - size_type __sz = size(); - __grow_by(__cap, __n - __cap, __sz, 0, __sz); - } - pointer __p = __get_pointer(); - for (; __first != __last; ++__p, (void) ++__first) - traits_type::assign(*__p, *__first); - traits_type::assign(*__p, value_type()); - __set_size(__n); - __invalidate_iterators_past(__n); - } - else - { - const basic_string __temp(__first, __last, __alloc()); - assign(__temp.data(), __temp.size()); + __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > + basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { + size_type __cap = capacity(); + size_type __n + = __string_is_trivial_iterator<_ForwardIterator>::value + ? static_cast(std::distance(__first, __last)) + : 0; + + if (__string_is_trivial_iterator<_ForwardIterator>::value && (__cap >= __n || !__addr_in_range(*__first))) { + if (__cap < __n) { + size_type __sz = size(); + __grow_by(__cap, __n - __cap, __sz, 0, __sz); } - return *this; + pointer __p = __get_pointer(); + for (; __first != __last; ++__p, (void)++__first) + traits_type::assign(*__p, *__first); + traits_type::assign(*__p, value_type()); + __set_size(__n); + __invalidate_iterators_past(__n); + } else { + const basic_string __temp(__first, __last, __alloc()); + assign(__temp.data(), __temp.size()); + } + return *this; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) -{ - size_type __sz = __str.size(); - if (__pos > __sz) - __throw_out_of_range(); - return assign(__str.data() + __pos, std::min(__n, __sz - __pos)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) { + size_type __sz = __str.size(); + if (__pos > __sz) + __throw_out_of_range(); + return assign(__str.data() + __pos, std::min(__n, __sz - __pos)); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) -{ - __self_view __sv = __t; - size_type __sz = __sv.size(); - if (__pos > __sz) - __throw_out_of_range(); - return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); + && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, + basic_string<_CharT, _Traits, _Allocator>& > +basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp& __t, size_type __pos, size_type __n) { + __self_view __sv = __t; + size_type __sz = __sv.size(); + if (__pos > __sz) + __throw_out_of_range(); + return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); } - template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { return __assign_external(__s, traits_type::length(__s)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) -{ - _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); - return __builtin_constant_p(*__s) - ? (__fits_in_sso(traits_type::length(__s)) - ? __assign_short(__s, traits_type::length(__s)) - : __assign_external(__s, traits_type::length(__s))) - : __assign_external(__s); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { + _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); + return __builtin_constant_p(*__s) + ? (__fits_in_sso(traits_type::length(__s)) + ? __assign_short(__s, traits_type::length(__s)) + : __assign_external(__s, traits_type::length(__s))) + : __assign_external(__s); } // append template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); - size_type __cap = capacity(); - size_type __sz = size(); - if (__cap - __sz >= __n) - { - if (__n) - { - value_type* __p = std::__to_address(__get_pointer()); - traits_type::copy(__p + __sz, __s, __n); - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); - } - } - else - __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); - return *this; +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); + size_type __cap = capacity(); + size_type __sz = size(); + if (__cap - __sz >= __n) { + if (__n) { + value_type* __p = std::__to_address(__get_pointer()); + traits_type::copy(__p + __sz, __s, __n); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } + } else + __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); + return *this; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) -{ - if (__n) - { - size_type __cap = capacity(); - size_type __sz = size(); - if (__cap - __sz < __n) - __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); - pointer __p = __get_pointer(); - traits_type::assign(std::__to_address(__p) + __sz, __n, __c); - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); - } - return *this; +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) { + if (__n) { + size_type __cap = capacity(); + size_type __sz = size(); + if (__cap - __sz < __n) + __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); + pointer __p = __get_pointer(); + traits_type::assign(std::__to_address(__p) + __sz, __n, __c); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } + return *this; } template _LIBCPP_CONSTEXPR_AFTER_CXX17 inline void -basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) -{ - if (__n) - { - size_type __cap = capacity(); - size_type __sz = size(); - if (__cap - __sz < __n) - __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); - pointer __p = __get_pointer(); - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); - } +basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) { + if (__n) { + size_type __cap = capacity(); + size_type __sz = size(); + if (__cap - __sz < __n) + __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); + pointer __p = __get_pointer(); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) -{ - bool __is_short = !__is_long(); - size_type __cap; - size_type __sz; - if (__is_short) - { - __cap = __min_cap - 1; - __sz = __get_short_size(); - } - else - { - __cap = __get_long_cap() - 1; - __sz = __get_long_size(); - } - if (__sz == __cap) - { - __grow_by(__cap, 1, __sz, __sz, 0); - __is_short = false; // the string is always long after __grow_by - } - pointer __p = __get_pointer(); - if (__is_short) - { - __p = __get_short_pointer() + __sz; - __set_short_size(__sz+1); - } - else - { - __p = __get_long_pointer() + __sz; - __set_long_size(__sz+1); - } - traits_type::assign(*__p, __c); - traits_type::assign(*++__p, value_type()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) { + bool __is_short = !__is_long(); + size_type __cap; + size_type __sz; + if (__is_short) { + __cap = __min_cap - 1; + __sz = __get_short_size(); + } else { + __cap = __get_long_cap() - 1; + __sz = __get_long_size(); + } + if (__sz == __cap) { + __grow_by(__cap, 1, __sz, __sz, 0); + __is_short = false; // the string is always long after __grow_by + } + pointer __p = __get_pointer(); + if (__is_short) { + __p = __get_short_pointer() + __sz; + __set_short_size(__sz + 1); + } else { + __p = __get_long_pointer() + __sz; + __set_long_size(__sz + 1); + } + traits_type::assign(*__p, __c); + traits_type::assign(*++__p, value_type()); } template -template +template _LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_cpp17_forward_iterator<_ForwardIterator>::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::append( - _ForwardIterator __first, _ForwardIterator __last) -{ - size_type __sz = size(); - size_type __cap = capacity(); - size_type __n = static_cast(std::distance(__first, __last)); - if (__n) - { - if (__string_is_trivial_iterator<_ForwardIterator>::value && - !__addr_in_range(*__first)) - { - if (__cap - __sz < __n) - __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); - pointer __p = __get_pointer() + __sz; - for (; __first != __last; ++__p, (void) ++__first) - traits_type::assign(*__p, *__first); - traits_type::assign(*__p, value_type()); - __set_size(__sz + __n); - } - else - { - const basic_string __temp(__first, __last, __alloc()); - append(__temp.data(), __temp.size()); - } + __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > + basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) { + size_type __sz = size(); + size_type __cap = capacity(); + size_type __n = static_cast(std::distance(__first, __last)); + if (__n) { + if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { + if (__cap - __sz < __n) + __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); + pointer __p = __get_pointer() + __sz; + for (; __first != __last; ++__p, (void)++__first) + traits_type::assign(*__p, *__first); + traits_type::assign(*__p, value_type()); + __set_size(__sz + __n); + } else { + const basic_string __temp(__first, __last, __alloc()); + append(__temp.data(), __temp.size()); } - return *this; + } + return *this; } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) -{ - return append(__str.data(), __str.size()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) { + return append(__str.data(), __str.size()); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) -{ - size_type __sz = __str.size(); - if (__pos > __sz) - __throw_out_of_range(); - return append(__str.data() + __pos, std::min(__n, __sz - __pos)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) { + size_type __sz = __str.size(); + if (__pos > __sz) + __throw_out_of_range(); + return append(__str.data() + __pos, std::min(__n, __sz - __pos)); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 - __enable_if_t - < - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - basic_string<_CharT, _Traits, _Allocator>& - > -basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) -{ - __self_view __sv = __t; - size_type __sz = __sv.size(); - if (__pos > __sz) - __throw_out_of_range(); - return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, + basic_string<_CharT, _Traits, _Allocator>& > +basic_string<_CharT, _Traits, _Allocator>::append(const _Tp& __t, size_type __pos, size_type __n) { + __self_view __sv = __t; + size_type __sz = __sv.size(); + if (__pos > __sz) + __throw_out_of_range(); + return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) -{ - _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); - return append(__s, traits_type::length(__s)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { + _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); + return append(__s, traits_type::length(__s)); } // insert template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); - size_type __sz = size(); - if (__pos > __sz) - __throw_out_of_range(); - size_type __cap = capacity(); - if (__libcpp_is_constant_evaluated()) { - if (__cap - __sz >= __n) - __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s); - else - __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); - return *this; - } +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); + size_type __sz = size(); + if (__pos > __sz) + __throw_out_of_range(); + size_type __cap = capacity(); + if (__libcpp_is_constant_evaluated()) { if (__cap - __sz >= __n) - { - if (__n) - { - value_type* __p = std::__to_address(__get_pointer()); - size_type __n_move = __sz - __pos; - if (__n_move != 0) - { - if (__p + __pos <= __s && __s < __p + __sz) - __s += __n; - traits_type::move(__p + __pos + __n, __p + __pos, __n_move); - } - traits_type::move(__p + __pos, __s, __n); - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); - } - } + __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s); else - __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); + __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); return *this; + } + if (__cap - __sz >= __n) { + if (__n) { + value_type* __p = std::__to_address(__get_pointer()); + size_type __n_move = __sz - __pos; + if (__n_move != 0) { + if (__p + __pos <= __s && __s < __p + __sz) + __s += __n; + traits_type::move(__p + __pos + __n, __p + __pos, __n_move); + } + traits_type::move(__p + __pos, __s, __n); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } + } else + __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); + return *this; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) -{ - size_type __sz = size(); - if (__pos > __sz) - __throw_out_of_range(); - if (__n) - { - size_type __cap = capacity(); - value_type* __p; - if (__cap - __sz >= __n) - { - __p = std::__to_address(__get_pointer()); - size_type __n_move = __sz - __pos; - if (__n_move != 0) - traits_type::move(__p + __pos + __n, __p + __pos, __n_move); - } - else - { - __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); - __p = std::__to_address(__get_long_pointer()); - } - traits_type::assign(__p + __pos, __n, __c); - __sz += __n; - __set_size(__sz); - traits_type::assign(__p[__sz], value_type()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) { + size_type __sz = size(); + if (__pos > __sz) + __throw_out_of_range(); + if (__n) { + size_type __cap = capacity(); + value_type* __p; + if (__cap - __sz >= __n) { + __p = std::__to_address(__get_pointer()); + size_type __n_move = __sz - __pos; + if (__n_move != 0) + traits_type::move(__p + __pos + __n, __p + __pos, __n_move); + } else { + __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); + __p = std::__to_address(__get_long_pointer()); } - return *this; + traits_type::assign(__p + __pos, __n, __c); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } + return *this; } template -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_exactly_cpp17_input_iterator<_InputIterator>::value, - typename basic_string<_CharT, _Traits, _Allocator>::iterator -> -basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, - "string::insert(iterator, range) called with an iterator not" - " referring to this string"); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __is_exactly_cpp17_input_iterator<_InputIterator>::value, + typename basic_string<_CharT, _Traits, _Allocator>::iterator > +basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); const basic_string __temp(__first, __last, __alloc()); return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } template -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __is_cpp17_forward_iterator<_ForwardIterator>::value, - typename basic_string<_CharT, _Traits, _Allocator>::iterator -> -basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, - "string::insert(iterator, range) called with an iterator not referring to this string"); - - size_type __ip = static_cast(__pos - begin()); - size_type __n = static_cast(std::distance(__first, __last)); - if (__n == 0) - return begin() + __ip; - - if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) - { - return __insert_from_safe_copy(__n, __ip, __first, __last); - } - else - { - const basic_string __temp(__first, __last, __alloc()); - return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end()); - } + typename basic_string<_CharT, _Traits, _Allocator>::iterator > +basic_string<_CharT, _Traits, _Allocator>::insert( + const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not referring to this string"); + + size_type __ip = static_cast(__pos - begin()); + size_type __n = static_cast(std::distance(__first, __last)); + if (__n == 0) + return begin() + __ip; + + if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) { + return __insert_from_safe_copy(__n, __ip, __first, __last); + } else { + const basic_string __temp(__first, __last, __alloc()); + return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end()); + } } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) -{ - return insert(__pos1, __str.data(), __str.size()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) { + return insert(__pos1, __str.data(), __str.size()); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, - size_type __pos2, size_type __n) -{ - size_type __str_sz = __str.size(); - if (__pos2 > __str_sz) - __throw_out_of_range(); - return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::insert( + size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) { + size_type __str_sz = __str.size(); + if (__pos2 > __str_sz) + __throw_out_of_range(); + return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2)); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, - size_type __pos2, size_type __n) -{ - __self_view __sv = __t; - size_type __str_sz = __sv.size(); - if (__pos2 > __str_sz) - __throw_out_of_range(); - return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, + basic_string<_CharT, _Traits, _Allocator>& > +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n) { + __self_view __sv = __t; + size_type __str_sz = __sv.size(); + if (__pos2 > __str_sz) + __throw_out_of_range(); + return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) -{ - _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); - return insert(__pos, __s, traits_type::length(__s)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { + _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); + return insert(__pos, __s, traits_type::length(__s)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::iterator -basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, - "string::insert(iterator, character) called with an iterator not" - " referring to this string"); +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::iterator +basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, character) called with an iterator not" + " referring to this string"); - size_type __ip = static_cast(__pos - begin()); - size_type __sz = size(); - size_type __cap = capacity(); - value_type* __p; - if (__cap == __sz) - { - __grow_by(__cap, 1, __sz, __ip, 0, 1); - __p = std::__to_address(__get_long_pointer()); - } - else - { - __p = std::__to_address(__get_pointer()); - size_type __n_move = __sz - __ip; - if (__n_move != 0) - traits_type::move(__p + __ip + 1, __p + __ip, __n_move); - } - traits_type::assign(__p[__ip], __c); - traits_type::assign(__p[++__sz], value_type()); - __set_size(__sz); - return begin() + static_cast(__ip); + size_type __ip = static_cast(__pos - begin()); + size_type __sz = size(); + size_type __cap = capacity(); + value_type* __p; + if (__cap == __sz) { + __grow_by(__cap, 1, __sz, __ip, 0, 1); + __p = std::__to_address(__get_long_pointer()); + } else { + __p = std::__to_address(__get_pointer()); + size_type __n_move = __sz - __ip; + if (__n_move != 0) + traits_type::move(__p + __ip + 1, __p + __ip, __n_move); + } + traits_type::assign(__p[__ip], __c); + traits_type::assign(__p[++__sz], value_type()); + __set_size(__sz); + return begin() + static_cast(__ip); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::iterator -basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, - "string::insert(iterator, n, value) called with an iterator not" - " referring to this string"); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::iterator +basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, n, value) called with an iterator not" + " referring to this string"); difference_type __p = __pos - begin(); insert(static_cast(__p), __n, __c); return begin() + __p; @@ -3079,182 +2727,150 @@ // replace template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) - _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK -{ - _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); - size_type __sz = size(); - if (__pos > __sz) - __throw_out_of_range(); - __n1 = std::min(__n1, __sz - __pos); - size_type __cap = capacity(); - if (__cap - __sz + __n1 >= __n2) - { - if (__libcpp_is_constant_evaluated()) { - __grow_by_and_replace(__cap, 0, __sz, __pos, __n1, __n2, __s); - return *this; +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace( + size_type __pos, size_type __n1, const value_type* __s, size_type __n2) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); + size_type __sz = size(); + if (__pos > __sz) + __throw_out_of_range(); + __n1 = std::min(__n1, __sz - __pos); + size_type __cap = capacity(); + if (__cap - __sz + __n1 >= __n2) { + if (__libcpp_is_constant_evaluated()) { + __grow_by_and_replace(__cap, 0, __sz, __pos, __n1, __n2, __s); + return *this; + } + value_type* __p = std::__to_address(__get_pointer()); + if (__n1 != __n2) { + size_type __n_move = __sz - __pos - __n1; + if (__n_move != 0) { + if (__n1 > __n2) { + traits_type::move(__p + __pos, __s, __n2); + traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); + return __null_terminate_at(__p, __sz + (__n2 - __n1)); } - value_type* __p = std::__to_address(__get_pointer()); - if (__n1 != __n2) - { - size_type __n_move = __sz - __pos - __n1; - if (__n_move != 0) - { - if (__n1 > __n2) - { - traits_type::move(__p + __pos, __s, __n2); - traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); - return __null_terminate_at(__p, __sz + (__n2 - __n1)); - } - if (__p + __pos < __s && __s < __p + __sz) - { - if (__p + __pos + __n1 <= __s) - __s += __n2 - __n1; - else // __p + __pos < __s < __p + __pos + __n1 - { - traits_type::move(__p + __pos, __s, __n1); - __pos += __n1; - __s += __n2; - __n2 -= __n1; - __n1 = 0; - } - } - traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); - } + if (__p + __pos < __s && __s < __p + __sz) { + if (__p + __pos + __n1 <= __s) + __s += __n2 - __n1; + else // __p + __pos < __s < __p + __pos + __n1 + { + traits_type::move(__p + __pos, __s, __n1); + __pos += __n1; + __s += __n2; + __n2 -= __n1; + __n1 = 0; + } } - traits_type::move(__p + __pos, __s, __n2); - return __null_terminate_at(__p, __sz + (__n2 - __n1)); + traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); + } } - else - __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); - return *this; + traits_type::move(__p + __pos, __s, __n2); + return __null_terminate_at(__p, __sz + (__n2 - __n1)); + } else + __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); + return *this; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) -{ - size_type __sz = size(); - if (__pos > __sz) - __throw_out_of_range(); - __n1 = std::min(__n1, __sz - __pos); - size_type __cap = capacity(); - value_type* __p; - if (__cap - __sz + __n1 >= __n2) - { - __p = std::__to_address(__get_pointer()); - if (__n1 != __n2) - { - size_type __n_move = __sz - __pos - __n1; - if (__n_move != 0) - traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); - } - } - else - { - __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); - __p = std::__to_address(__get_long_pointer()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) { + size_type __sz = size(); + if (__pos > __sz) + __throw_out_of_range(); + __n1 = std::min(__n1, __sz - __pos); + size_type __cap = capacity(); + value_type* __p; + if (__cap - __sz + __n1 >= __n2) { + __p = std::__to_address(__get_pointer()); + if (__n1 != __n2) { + size_type __n_move = __sz - __pos - __n1; + if (__n_move != 0) + traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); } - traits_type::assign(__p + __pos, __n2, __c); - return __null_terminate_at(__p, __sz - (__n1 - __n2)); + } else { + __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); + __p = std::__to_address(__get_long_pointer()); + } + traits_type::assign(__p + __pos, __n2, __c); + return __null_terminate_at(__p, __sz - (__n1 - __n2)); } template -template +template _LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __is_cpp17_input_iterator<_InputIterator>::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, - _InputIterator __j1, _InputIterator __j2) -{ - const basic_string __temp(__j1, __j2, __alloc()); - return replace(__i1, __i2, __temp); + __enable_if_t< __is_cpp17_input_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& > + basic_string<_CharT, _Traits, _Allocator>::replace( + const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { + const basic_string __temp(__j1, __j2, __alloc()); + return replace(__i1, __i2, __temp); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) -{ - return replace(__pos1, __n1, __str.data(), __str.size()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) { + return replace(__pos1, __n1, __str.data(), __str.size()); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, - size_type __pos2, size_type __n2) -{ - size_type __str_sz = __str.size(); - if (__pos2 > __str_sz) - __throw_out_of_range(); - return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace( + size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) { + size_type __str_sz = __str.size(); + if (__pos2 > __str_sz) + __throw_out_of_range(); + return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2)); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - basic_string<_CharT, _Traits, _Allocator>& -> -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, - size_type __pos2, size_type __n2) -{ - __self_view __sv = __t; - size_type __str_sz = __sv.size(); - if (__pos2 > __str_sz) - __throw_out_of_range(); - return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< + __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value + && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, + basic_string<_CharT, _Traits, _Allocator>& > +basic_string<_CharT, _Traits, _Allocator>::replace( + size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) { + __self_view __sv = __t; + size_type __str_sz = __sv.size(); + if (__pos2 > __str_sz) + __throw_out_of_range(); + return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) -{ - _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); - return replace(__pos, __n1, __s, traits_type::length(__s)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { + _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); + return replace(__pos, __n1, __s, traits_type::length(__s)); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) -{ - return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), - __str.data(), __str.size()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace( + const_iterator __i1, const_iterator __i2, const basic_string& __str) { + return replace( + static_cast(__i1 - begin()), static_cast(__i2 - __i1), __str.data(), __str.size()); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) -{ - return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s, __n); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace( + const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) { + return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s, __n); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) -{ - return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) { + return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __s); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) -{ - return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __n, __c); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::replace( + const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) { + return replace(static_cast(__i1 - begin()), static_cast(__i2 - __i1), __n, __c); } // erase @@ -3262,28 +2878,22 @@ // 'externally instantiated' erase() implementation, called when __n != npos. // Does not check __pos against size() template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( - size_type __pos, size_type __n) -{ - if (__n) - { - size_type __sz = size(); - value_type* __p = std::__to_address(__get_pointer()); - __n = std::min(__n, __sz - __pos); - size_type __n_move = __sz - __pos - __n; - if (__n_move != 0) - traits_type::move(__p + __pos, __p + __pos + __n, __n_move); - __null_terminate_at(__p, __sz - __n); - } +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type __pos, size_type __n) { + if (__n) { + size_type __sz = size(); + value_type* __p = std::__to_address(__get_pointer()); + __n = std::min(__n, __sz - __pos); + size_type __n_move = __sz - __pos - __n; + if (__n_move != 0) + traits_type::move(__p + __pos, __p + __pos + __n, __n_move); + __null_terminate_at(__p, __sz - __n); + } } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator>& -basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, - size_type __n) { +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>& +basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) { if (__pos > size()) __throw_out_of_range(); if (__n == npos) { @@ -3295,1246 +2905,940 @@ } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::iterator -basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, - "string::erase(iterator) called with an iterator not" - " referring to this string"); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::iterator +basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__pos) == this, + "string::erase(iterator) called with an iterator not" + " referring to this string"); _LIBCPP_ASSERT(__pos != end(), "string::erase(iterator) called with a non-dereferenceable iterator"); - iterator __b = begin(); + iterator __b = begin(); size_type __r = static_cast(__pos - __b); erase(__r, 1); return __b + static_cast(__r); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::iterator -basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) -{ - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, - "string::erase(iterator, iterator) called with an iterator not" - " referring to this string"); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::iterator +basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) { + _LIBCPP_DEBUG_ASSERT( + __get_const_db()->__find_c_from_i(&__first) == this, + "string::erase(iterator, iterator) called with an iterator not" + " referring to this string"); _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); - iterator __b = begin(); + iterator __b = begin(); size_type __r = static_cast(__first - __b); erase(__r, static_cast(__last - __first)); return __b + static_cast(__r); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::pop_back() -{ - _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); - __erase_to_end(size() - 1); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::pop_back() { + _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); + __erase_to_end(size() - 1); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT -{ - __invalidate_all_iterators(); - if (__is_long()) - { - traits_type::assign(*__get_long_pointer(), value_type()); - __set_long_size(0); - } - else - { - traits_type::assign(*__get_short_pointer(), value_type()); - __set_short_size(0); - } +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { + __invalidate_all_iterators(); + if (__is_long()) { + traits_type::assign(*__get_long_pointer(), value_type()); + __set_long_size(0); + } else { + traits_type::assign(*__get_short_pointer(), value_type()); + __set_short_size(0); + } } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) -{ +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) { __null_terminate_at(std::__to_address(__get_pointer()), __pos); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) -{ - size_type __sz = size(); - if (__n > __sz) - append(__n - __sz, __c); - else - __erase_to_end(__n); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) { + size_type __sz = size(); + if (__n > __sz) + append(__n - __sz, __c); + else + __erase_to_end(__n); } template _LIBCPP_CONSTEXPR_AFTER_CXX17 inline void -basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) -{ - size_type __sz = size(); - if (__n > __sz) { - __append_default_init(__n - __sz); - } else - __erase_to_end(__n); +basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) { + size_type __sz = size(); + if (__n > __sz) { + __append_default_init(__n - __sz); + } else + __erase_to_end(__n); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT -{ - size_type __m = __alloc_traits::max_size(__alloc()); - if (__m <= std::numeric_limits::max() / 2) { - return __m - __alignment; - } else { - bool __uses_lsb = __endian_factor == 2; - return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment; - } +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT { + size_type __m = __alloc_traits::max_size(__alloc()); + if (__m <= std::numeric_limits::max() / 2) { + return __m - __alignment; + } else { + bool __uses_lsb = __endian_factor == 2; + return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment; + } } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) -{ - if (__requested_capacity > max_size()) - __throw_length_error(); +_LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) { + if (__requested_capacity > max_size()) + __throw_length_error(); - // Make sure reserve(n) never shrinks. This is technically only required in C++20 - // and later (since P0966R1), however we provide consistent behavior in all Standard - // modes because this function is instantiated in the shared library. - if (__requested_capacity <= capacity()) - return; + // Make sure reserve(n) never shrinks. This is technically only required in C++20 + // and later (since P0966R1), however we provide consistent behavior in all Standard + // modes because this function is instantiated in the shared library. + if (__requested_capacity <= capacity()) + return; - size_type __target_capacity = std::max(__requested_capacity, size()); - __target_capacity = __recommend(__target_capacity); - if (__target_capacity == capacity()) return; + size_type __target_capacity = std::max(__requested_capacity, size()); + __target_capacity = __recommend(__target_capacity); + if (__target_capacity == capacity()) + return; - __shrink_or_extend(__target_capacity); + __shrink_or_extend(__target_capacity); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT -{ - size_type __target_capacity = __recommend(size()); - if (__target_capacity == capacity()) return; +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT { + size_type __target_capacity = __recommend(size()); + if (__target_capacity == capacity()) + return; - __shrink_or_extend(__target_capacity); + __shrink_or_extend(__target_capacity); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) -{ - size_type __cap = capacity(); - size_type __sz = size(); - - pointer __new_data, __p; - bool __was_long, __now_long; - if (__fits_in_sso(__target_capacity)) - { - __was_long = true; - __now_long = false; - __new_data = __get_short_pointer(); - __p = __get_long_pointer(); - } - else - { - if (__target_capacity > __cap) { - auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); - __new_data = __allocation.ptr; - __target_capacity = __allocation.count - 1; - } - else - { - #ifndef _LIBCPP_NO_EXCEPTIONS - try - { - #endif // _LIBCPP_NO_EXCEPTIONS - auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); - __new_data = __allocation.ptr; - __target_capacity = __allocation.count - 1; - #ifndef _LIBCPP_NO_EXCEPTIONS - } - catch (...) - { - return; - } - #else // _LIBCPP_NO_EXCEPTIONS - if (__new_data == nullptr) - return; - #endif // _LIBCPP_NO_EXCEPTIONS - } - __begin_lifetime(__new_data, __target_capacity + 1); - __now_long = true; - __was_long = __is_long(); - __p = __get_pointer(); - } - traits_type::copy(std::__to_address(__new_data), - std::__to_address(__p), size()+1); - if (__was_long) - __alloc_traits::deallocate(__alloc(), __p, __cap+1); - if (__now_long) - { - __set_long_cap(__target_capacity+1); - __set_long_size(__sz); - __set_long_pointer(__new_data); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) { + size_type __cap = capacity(); + size_type __sz = size(); + + pointer __new_data, __p; + bool __was_long, __now_long; + if (__fits_in_sso(__target_capacity)) { + __was_long = true; + __now_long = false; + __new_data = __get_short_pointer(); + __p = __get_long_pointer(); + } else { + if (__target_capacity > __cap) { + auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); + __new_data = __allocation.ptr; + __target_capacity = __allocation.count - 1; + } else { +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif // _LIBCPP_NO_EXCEPTIONS + auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); + __new_data = __allocation.ptr; + __target_capacity = __allocation.count - 1; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + return; + } +#else // _LIBCPP_NO_EXCEPTIONS + if (__new_data == nullptr) + return; +#endif // _LIBCPP_NO_EXCEPTIONS } - else - __set_short_size(__sz); - __invalidate_all_iterators(); + __begin_lifetime(__new_data, __target_capacity + 1); + __now_long = true; + __was_long = __is_long(); + __p = __get_pointer(); + } + traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1); + if (__was_long) + __alloc_traits::deallocate(__alloc(), __p, __cap + 1); + if (__now_long) { + __set_long_cap(__target_capacity + 1); + __set_long_size(__sz); + __set_long_pointer(__new_data); + } else + __set_short_size(__sz); + __invalidate_all_iterators(); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::const_reference -basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); - return *(data() + __pos); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::const_reference +basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); + return *(data() + __pos); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::reference -basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT -{ - _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); - return *(__get_pointer() + __pos); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::reference +basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT { + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); + return *(__get_pointer() + __pos); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::const_reference -basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const -{ - if (__n >= size()) - __throw_out_of_range(); - return (*this)[__n]; +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::const_reference +basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const { + if (__n >= size()) + __throw_out_of_range(); + return (*this)[__n]; } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::reference -basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) -{ - if (__n >= size()) - __throw_out_of_range(); - return (*this)[__n]; +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::reference +basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) { + if (__n >= size()) + __throw_out_of_range(); + return (*this)[__n]; } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::reference -basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT -{ - _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); - return *__get_pointer(); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::reference +basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT { + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); + return *__get_pointer(); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::const_reference -basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT -{ - _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); - return *data(); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::const_reference +basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT { + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); + return *data(); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::reference -basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT -{ - _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); - return *(__get_pointer() + size() - 1); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::reference +basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT { + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); + return *(__get_pointer() + size() - 1); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::const_reference -basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT -{ - _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); - return *(data() + size() - 1); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::const_reference +basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT { + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); + return *(data() + size() - 1); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const -{ - size_type __sz = size(); - if (__pos > __sz) - __throw_out_of_range(); - size_type __rlen = std::min(__n, __sz - __pos); - traits_type::copy(__s, data() + __pos, __rlen); - return __rlen; +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const { + size_type __sz = size(); + if (__pos > __sz) + __throw_out_of_range(); + size_type __rlen = std::min(__n, __sz - __pos); + traits_type::copy(__s, data() + __pos, __rlen); + return __rlen; } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const -{ - return basic_string(*this, __pos, __n, __alloc()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const { + return basic_string(*this, __pos, __n, __alloc()); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) #if _LIBCPP_STD_VER >= 14 - _NOEXCEPT + _NOEXCEPT #else - _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || - __is_nothrow_swappable::value) + _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value) #endif { #if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) { - if (!__is_long()) - __get_db()->__invalidate_all(this); - if (!__str.__is_long()) - __get_db()->__invalidate_all(&__str); - __get_db()->swap(this, &__str); - } + if (!__libcpp_is_constant_evaluated()) { + if (!__is_long()) + __get_db()->__invalidate_all(this); + if (!__str.__is_long()) + __get_db()->__invalidate_all(&__str); + __get_db()->swap(this, &__str); + } #endif - _LIBCPP_ASSERT( - __alloc_traits::propagate_on_container_swap::value || - __alloc_traits::is_always_equal::value || - __alloc() == __str.__alloc(), "swapping non-equal allocators"); - std::swap(__r_.first(), __str.__r_.first()); - std::__swap_allocator(__alloc(), __str.__alloc()); + _LIBCPP_ASSERT( + __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value + || __alloc() == __str.__alloc(), + "swapping non-equal allocators"); + std::swap(__r_.first(), __str.__r_.first()); + std::__swap_allocator(__alloc(), __str.__alloc()); } // find template -struct _LIBCPP_HIDDEN __traits_eq -{ - typedef typename _Traits::char_type char_type; - _LIBCPP_HIDE_FROM_ABI - bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT - {return _Traits::eq(__x, __y);} +struct _LIBCPP_HIDDEN __traits_eq { + typedef typename _Traits::char_type char_type; + _LIBCPP_HIDE_FROM_ABI bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT { + return _Traits::eq(__x, __y); + } }; -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); - return __str_find - (data(), size(), __s, __pos, __n); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); + return __str_find(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_find - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_find(data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_find - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::find(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_find(data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); - return __str_find - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); + return __str_find(data(), size(), __s, __pos, traits_type::length(__s)); } -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return __str_find - (data(), size(), __c, __pos); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT { + return __str_find(data(), size(), __c, __pos); } // rfind -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); - return __str_rfind - (data(), size(), __s, __pos, __n); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::rfind( + const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); + return __str_rfind(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_rfind - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_rfind(data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_rfind - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_rfind(data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); - return __str_rfind - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); + return __str_rfind(data(), size(), __s, __pos, traits_type::length(__s)); } -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return __str_rfind - (data(), size(), __c, __pos); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT { + return __str_rfind(data(), size(), __c, __pos); } // find_first_of -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); - return __str_find_first_of - (data(), size(), __s, __pos, __n); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_of( + const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); + return __str_find_first_of(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_find_first_of - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_find_first_of( + data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_find_first_of - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_find_first_of(data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); - return __str_find_first_of - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); + return __str_find_first_of( + data(), size(), __s, __pos, traits_type::length(__s)); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return find(__c, __pos); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT { + return find(__c, __pos); } // find_last_of -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); - return __str_find_last_of - (data(), size(), __s, __pos, __n); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_of( + const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); + return __str_find_last_of(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_find_last_of - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_find_last_of( + data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_find_last_of - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_find_last_of(data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); - return __str_find_last_of - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); + return __str_find_last_of( + data(), size(), __s, __pos, traits_type::length(__s)); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return rfind(__c, __pos); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT { + return rfind(__c, __pos); } // find_first_not_of -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); - return __str_find_first_not_of - (data(), size(), __s, __pos, __n); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( + const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); + return __str_find_first_not_of(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_find_first_not_of - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of( + const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_find_first_not_of( + data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_find_first_not_of - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_find_first_not_of( + data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); - return __str_find_first_not_of - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); + return __str_find_first_not_of( + data(), size(), __s, __pos, traits_type::length(__s)); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return __str_find_first_not_of - (data(), size(), __c, __pos); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT { + return __str_find_first_not_of(data(), size(), __c, __pos); } // find_last_not_of -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, - size_type __pos, - size_type __n) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); - return __str_find_last_not_of - (data(), size(), __s, __pos, __n); +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( + const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); + return __str_find_last_not_of(data(), size(), __s, __pos, __n); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, - size_type __pos) const _NOEXCEPT -{ - return __str_find_last_not_of - (data(), size(), __str.data(), __pos, __str.size()); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of( + const basic_string& __str, size_type __pos) const _NOEXCEPT { + return __str_find_last_not_of( + data(), size(), __str.data(), __pos, __str.size()); } -template +template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - typename basic_string<_CharT, _Traits, _Allocator>::size_type -> -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, - size_type __pos) const _NOEXCEPT -{ - __self_view __sv = __t; - return __str_find_last_not_of - (data(), size(), __sv.data(), __pos, __sv.size()); + typename basic_string<_CharT, _Traits, _Allocator>::size_type > +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT { + __self_view __sv = __t; + return __str_find_last_not_of( + data(), size(), __sv.data(), __pos, __sv.size()); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, - size_type __pos) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); - return __str_find_last_not_of - (data(), size(), __s, __pos, traits_type::length(__s)); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); + return __str_find_last_not_of( + data(), size(), __s, __pos, traits_type::length(__s)); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -typename basic_string<_CharT, _Traits, _Allocator>::size_type -basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, - size_type __pos) const _NOEXCEPT -{ - return __str_find_last_not_of - (data(), size(), __c, __pos); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 typename basic_string<_CharT, _Traits, _Allocator>::size_type +basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT { + return __str_find_last_not_of(data(), size(), __c, __pos); } // compare template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - int -> -basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT -{ - __self_view __sv = __t; - size_t __lhs_sz = size(); - size_t __rhs_sz = __sv.size(); - int __result = traits_type::compare(data(), __sv.data(), - std::min(__lhs_sz, __rhs_sz)); - if (__result != 0) - return __result; - if (__lhs_sz < __rhs_sz) - return -1; - if (__lhs_sz > __rhs_sz) - return 1; - return 0; +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > +basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT { + __self_view __sv = __t; + size_t __lhs_sz = size(); + size_t __rhs_sz = __sv.size(); + int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz)); + if (__result != 0) + return __result; + if (__lhs_sz < __rhs_sz) + return -1; + if (__lhs_sz > __rhs_sz) + return 1; + return 0; } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT -{ - return compare(__self_view(__str)); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 int +basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { + return compare(__self_view(__str)); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const value_type* __s, - size_type __n2) const -{ - _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); - size_type __sz = size(); - if (__pos1 > __sz || __n2 == npos) - __throw_out_of_range(); - size_type __rlen = std::min(__n1, __sz - __pos1); - int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2)); - if (__r == 0) - { - if (__rlen < __n2) - __r = -1; - else if (__rlen > __n2) - __r = 1; - } - return __r; +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 int basic_string<_CharT, _Traits, _Allocator>::compare( + size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const { + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); + size_type __sz = size(); + if (__pos1 > __sz || __n2 == npos) + __throw_out_of_range(); + size_type __rlen = std::min(__n1, __sz - __pos1); + int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2)); + if (__r == 0) { + if (__rlen < __n2) + __r = -1; + else if (__rlen > __n2) + __r = 1; + } + return __r; } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< - __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, - int -> -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const _Tp& __t) const -{ - __self_view __sv = __t; - return compare(__pos1, __n1, __sv.data(), __sv.size()); +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int > +basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const { + __self_view __sv = __t; + return compare(__pos1, __n1, __sv.data(), __sv.size()); } template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const basic_string& __str) const -{ - return compare(__pos1, __n1, __str.data(), __str.size()); +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 int +basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const { + return compare(__pos1, __n1, __str.data(), __str.size()); } template template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -__enable_if_t -< +_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t< __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value - && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, - int -> -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const _Tp& __t, - size_type __pos2, - size_type __n2) const -{ - __self_view __sv = __t; - return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); + && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, + int > +basic_string<_CharT, _Traits, _Allocator>::compare( + size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const { + __self_view __sv = __t; + return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const basic_string& __str, - size_type __pos2, - size_type __n2) const -{ - return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); +_LIBCPP_CONSTEXPR_AFTER_CXX17 int basic_string<_CharT, _Traits, _Allocator>::compare( + size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const { + return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT -{ - _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); - return compare(0, npos, __s, traits_type::length(__s)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 int +basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); + return compare(0, npos, __s, traits_type::length(__s)); } template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -int -basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, - size_type __n1, - const value_type* __s) const -{ - _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); - return compare(__pos1, __n1, __s, traits_type::length(__s)); +_LIBCPP_CONSTEXPR_AFTER_CXX17 int +basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); + return compare(__pos1, __n1, __s, traits_type::length(__s)); } // __invariants -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -bool -basic_string<_CharT, _Traits, _Allocator>::__invariants() const -{ - if (size() > capacity()) - return false; - if (capacity() < __min_cap - 1) - return false; - if (data() == nullptr) - return false; - if (data()[size()] != value_type()) - return false; - return true; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const { + if (size() > capacity()) + return false; + if (capacity() < __min_cap - 1) + return false; + if (data() == nullptr) + return false; + if (data()[size()] != value_type()) + return false; + return true; } // __clear_and_shrink -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT -{ - clear(); - if(__is_long()) - { - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); - __set_long_cap(0); - __set_short_size(0); - traits_type::assign(*__get_short_pointer(), value_type()); - } +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT { + clear(); + if (__is_long()) { + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); + __set_long_cap(0); + __set_short_size(0); + traits_type::assign(*__get_short_pointer(), value_type()); + } } // operator== -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - size_t __lhs_sz = __lhs.size(); - return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), - __rhs.data(), - __lhs_sz) == 0; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator==( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + size_t __lhs_sz = __lhs.size(); + return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator==(const basic_string, _Allocator>& __lhs, - const basic_string, _Allocator>& __rhs) _NOEXCEPT -{ - size_t __lhs_sz = __lhs.size(); - if (__lhs_sz != __rhs.size()) - return false; - const char* __lp = __lhs.data(); - const char* __rp = __rhs.data(); - if (__lhs.__is_long()) - return char_traits::compare(__lp, __rp, __lhs_sz) == 0; - for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) - if (*__lp != *__rp) - return false; - return true; -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator==(const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - typedef basic_string<_CharT, _Traits, _Allocator> _String; - _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); - size_t __lhs_len = _Traits::length(__lhs); - if (__lhs_len != __rhs.size()) return false; - return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - typedef basic_string<_CharT, _Traits, _Allocator> _String; - _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); - size_t __rhs_len = _Traits::length(__rhs); - if (__rhs_len != __lhs.size()) return false; - return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__lhs == __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator==( + const basic_string, _Allocator>& __lhs, + const basic_string, _Allocator>& __rhs) _NOEXCEPT { + size_t __lhs_sz = __lhs.size(); + if (__lhs_sz != __rhs.size()) + return false; + const char* __lp = __lhs.data(); + const char* __rp = __rhs.data(); + if (__lhs.__is_long()) + return char_traits::compare(__lp, __rp, __lhs_sz) == 0; + for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) + if (*__lp != *__rp) + return false; + return true; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator!=(const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__lhs == __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); + size_t __lhs_len = _Traits::length(__lhs); + if (__lhs_len != __rhs.size()) + return false; + return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - return !(__lhs == __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); + size_t __rhs_len = _Traits::length(__rhs); + if (__rhs_len != __lhs.size()) + return false; + return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; +} + +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator!=( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__lhs == __rhs); +} + +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__lhs == __rhs); +} + +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + return !(__lhs == __rhs); } // operator< -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return __lhs.compare(__rhs) < 0; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator<( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return __lhs.compare(__rhs) < 0; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - return __lhs.compare(__rhs) < 0; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator<(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + return __lhs.compare(__rhs) < 0; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator< (const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return __rhs.compare(__lhs) > 0; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator<(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return __rhs.compare(__lhs) > 0; } // operator> -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return __rhs < __lhs; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator>( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return __rhs < __lhs; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - return __rhs < __lhs; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + return __rhs < __lhs; } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator> (const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return __rhs < __lhs; +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator>(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return __rhs < __lhs; } // operator<= -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__rhs < __lhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator<=( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__rhs < __lhs); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - return !(__rhs < __lhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + return !(__rhs < __lhs); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator<=(const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__rhs < __lhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__rhs < __lhs); } // operator>= -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__lhs < __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool operator>=( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__lhs < __rhs); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const _CharT* __rhs) _NOEXCEPT -{ - return !(__lhs < __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { + return !(__lhs < __rhs); } -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI -bool -operator>=(const _CharT* __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT -{ - return !(__lhs < __rhs); +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool +operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { + return !(__lhs < __rhs); } // operator + -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, - const basic_string<_CharT, _Traits, _Allocator>& __rhs) -{ - using _String = basic_string<_CharT, _Traits, _Allocator>; - auto __lhs_sz = __lhs.size(); - auto __rhs_sz = __rhs.size(); - _String __r(__uninitialized_size_tag(), - __lhs_sz + __rhs_sz, - _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); - auto __ptr = std::__to_address(__r.__get_pointer()); - _Traits::copy(__ptr, __lhs.data(), __lhs_sz); - _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); - _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); - return __r; -} - -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) -{ - using _String = basic_string<_CharT, _Traits, _Allocator>; - auto __lhs_sz = _Traits::length(__lhs); - auto __rhs_sz = __rhs.size(); - _String __r(__uninitialized_size_tag(), - __lhs_sz + __rhs_sz, - _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); - auto __ptr = std::__to_address(__r.__get_pointer()); - _Traits::copy(__ptr, __lhs, __lhs_sz); - _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); - _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); - return __r; -} - -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) -{ - using _String = basic_string<_CharT, _Traits, _Allocator>; - typename _String::size_type __rhs_sz = __rhs.size(); - _String __r(__uninitialized_size_tag(), - __rhs_sz + 1, - _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); - auto __ptr = std::__to_address(__r.__get_pointer()); - _Traits::assign(__ptr, 1, __lhs); - _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz); - _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT()); - return __r; -} - -template -inline _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) -{ - using _String = basic_string<_CharT, _Traits, _Allocator>; - typename _String::size_type __lhs_sz = __lhs.size(); - typename _String::size_type __rhs_sz = _Traits::length(__rhs); - _String __r(__uninitialized_size_tag(), - __lhs_sz + __rhs_sz, - _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); - auto __ptr = std::__to_address(__r.__get_pointer()); - _Traits::copy(__ptr, __lhs.data(), __lhs_sz); - _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz); - _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); - return __r; -} - -template -_LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) -{ - using _String = basic_string<_CharT, _Traits, _Allocator>; - typename _String::size_type __lhs_sz = __lhs.size(); - _String __r(__uninitialized_size_tag(), - __lhs_sz + 1, - _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); - auto __ptr = std::__to_address(__r.__get_pointer()); - _Traits::copy(__ptr, __lhs.data(), __lhs_sz); - _Traits::assign(__ptr + __lhs_sz, 1, __rhs); - _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT()); - return __r; +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> operator+( + const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + auto __lhs_sz = __lhs.size(); + auto __rhs_sz = __rhs.size(); + _String __r( + __uninitialized_size_tag(), + __lhs_sz + __rhs_sz, + _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs.data(), __lhs_sz); + _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); + _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); + return __r; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + auto __lhs_sz = _Traits::length(__lhs); + auto __rhs_sz = __rhs.size(); + _String __r( + __uninitialized_size_tag(), + __lhs_sz + __rhs_sz, + _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs, __lhs_sz); + _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); + _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); + return __r; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + typename _String::size_type __rhs_sz = __rhs.size(); + _String __r( + __uninitialized_size_tag(), + __rhs_sz + 1, + _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::assign(__ptr, 1, __lhs); + _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz); + _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT()); + return __r; +} + +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + typename _String::size_type __lhs_sz = __lhs.size(); + typename _String::size_type __rhs_sz = _Traits::length(__rhs); + _String __r( + __uninitialized_size_tag(), + __lhs_sz + __rhs_sz, + _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs.data(), __lhs_sz); + _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz); + _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); + return __r; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { + using _String = basic_string<_CharT, _Traits, _Allocator>; + typename _String::size_type __lhs_sz = __lhs.size(); + _String __r( + __uninitialized_size_tag(), + __lhs_sz + 1, + _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + auto __ptr = std::__to_address(__r.__get_pointer()); + _Traits::copy(__ptr, __lhs.data(), __lhs_sz); + _Traits::assign(__ptr + __lhs_sz, 1, __rhs); + _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT()); + return __r; } #ifndef _LIBCPP_CXX03_LANG -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) -{ - return std::move(__lhs.append(__rhs)); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { + return std::move(__lhs.append(__rhs)); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) -{ - return std::move(__rhs.insert(0, __lhs)); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { + return std::move(__rhs.insert(0, __lhs)); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) -{ - return std::move(__lhs.append(__rhs)); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { + return std::move(__lhs.append(__rhs)); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) -{ - return std::move(__rhs.insert(0, __lhs)); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(const _CharT* __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { + return std::move(__rhs.insert(0, __lhs)); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) -{ - __rhs.insert(__rhs.begin(), __lhs); - return std::move(__rhs); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(_CharT __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { + __rhs.insert(__rhs.begin(), __lhs); + return std::move(__rhs); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) -{ - return std::move(__lhs.append(__rhs)); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { + return std::move(__lhs.append(__rhs)); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) -{ - __lhs.push_back(__rhs); - return std::move(__lhs); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator> +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { + __lhs.push_back(__rhs); + return std::move(__lhs); } #endif // _LIBCPP_CXX03_LANG // swap -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 -void -swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, - basic_string<_CharT, _Traits, _Allocator>& __rhs) - _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) -{ - __lhs.swap(__rhs); +template +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void +swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) + _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) { + __lhs.swap(__rhs); } -_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS int stoi(const string& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long stol(const string& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul(const string& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll(const string& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS float stof(const string& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS double stod(const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS string to_string(int __val); @@ -4548,14 +3852,14 @@ _LIBCPP_FUNC_VIS string to_string(long double __val); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll(const wstring& __str, size_t* __idx = nullptr, int __base = 10); _LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = nullptr, int __base = 10); -_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = nullptr); -_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS float stof(const wstring& __str, size_t* __idx = nullptr); +_LIBCPP_FUNC_VIS double stod(const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = nullptr); _LIBCPP_FUNC_VIS wstring to_wstring(int __val); @@ -4569,164 +3873,129 @@ _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -template -_LIBCPP_TEMPLATE_DATA_VIS -const typename basic_string<_CharT, _Traits, _Allocator>::size_type - basic_string<_CharT, _Traits, _Allocator>::npos; +template +_LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type + basic_string<_CharT, _Traits, _Allocator>::npos; template -struct _LIBCPP_TEMPLATE_VIS - hash, _Allocator> > - : public unary_function< - basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> -{ - size_t - operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT - { return __do_string_hash(__val.data(), __val.data() + __val.size()); } +struct _LIBCPP_TEMPLATE_VIS hash, _Allocator> > + : public unary_function< basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> { + size_t operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT { + return __do_string_hash(__val.data(), __val.data() + __val.size()); + } }; - -template +template basic_ostream<_CharT, _Traits>& -operator<<(basic_ostream<_CharT, _Traits>& __os, - const basic_string<_CharT, _Traits, _Allocator>& __str); +operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str); -template +template basic_istream<_CharT, _Traits>& -operator>>(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT, _Traits, _Allocator>& __str); +operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str); -template +template basic_istream<_CharT, _Traits>& -getline(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); +getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); -template -inline _LIBCPP_HIDE_FROM_ABI -basic_istream<_CharT, _Traits>& -getline(basic_istream<_CharT, _Traits>& __is, - basic_string<_CharT, _Traits, _Allocator>& __str); +template +inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& +getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str); -template -inline _LIBCPP_HIDE_FROM_ABI -basic_istream<_CharT, _Traits>& -getline(basic_istream<_CharT, _Traits>&& __is, - basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); +template +inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& +getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); -template -inline _LIBCPP_HIDE_FROM_ABI -basic_istream<_CharT, _Traits>& -getline(basic_istream<_CharT, _Traits>&& __is, - basic_string<_CharT, _Traits, _Allocator>& __str); +template +inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& +getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str); #if _LIBCPP_STD_VER > 17 template -inline _LIBCPP_HIDE_FROM_ABI - typename basic_string<_CharT, _Traits, _Allocator>::size_type - erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { +inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type +erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { auto __old_size = __str.size(); __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end()); return __old_size - __str.size(); } template -inline _LIBCPP_HIDE_FROM_ABI - typename basic_string<_CharT, _Traits, _Allocator>::size_type - erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, - _Predicate __pred) { +inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type +erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { auto __old_size = __str.size(); - __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), - __str.end()); + __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end()); return __old_size - __str.size(); } #endif #if _LIBCPP_DEBUG_LEVEL == 2 -template -bool -basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const -{ - return data() <= std::__to_address(__i->base()) && - std::__to_address(__i->base()) < data() + size(); +template +bool basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const { + return data() <= std::__to_address(__i->base()) && std::__to_address(__i->base()) < data() + size(); } -template -bool -basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const -{ - return data() < std::__to_address(__i->base()) && - std::__to_address(__i->base()) <= data() + size(); +template +bool basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const { + return data() < std::__to_address(__i->base()) && std::__to_address(__i->base()) <= data() + size(); } -template -bool -basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const -{ - const value_type* __p = std::__to_address(__i->base()) + __n; - return data() <= __p && __p <= data() + size(); +template +bool basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const { + const value_type* __p = std::__to_address(__i->base()) + __n; + return data() <= __p && __p <= data() + size(); } -template -bool -basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const -{ - const value_type* __p = std::__to_address(__i->base()) + __n; - return data() <= __p && __p < data() + size(); +template +bool basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const { + const value_type* __p = std::__to_address(__i->base()) + __n; + return data() <= __p && __p < data() + size(); } #endif // _LIBCPP_DEBUG_LEVEL == 2 #if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] -inline namespace literals -{ - inline namespace string_literals - { - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string operator "" s( const char *__str, size_t __len ) - { - return basic_string (__str, __len); - } +inline namespace literals { +inline namespace string_literals { + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string + operator"" s(const char* __str, size_t __len) { + return basic_string(__str, __len); + } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string operator "" s( const wchar_t *__str, size_t __len ) - { - return basic_string (__str, __len); - } -#endif +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string + operator"" s(const wchar_t* __str, size_t __len) { + return basic_string(__str, __len); + } +# endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T - inline _LIBCPP_HIDE_FROM_ABI constexpr - basic_string operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT - { - return basic_string (__str, __len); - } -#endif +# ifndef _LIBCPP_HAS_NO_CHAR8_T + inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string + operator"" s(const char8_t* __str, size_t __len) _NOEXCEPT { + return basic_string(__str, __len); + } +# endif - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string operator "" s( const char16_t *__str, size_t __len ) - { - return basic_string (__str, __len); - } + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string + operator"" s(const char16_t* __str, size_t __len) { + return basic_string(__str, __len); + } - inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 - basic_string operator "" s( const char32_t *__str, size_t __len ) - { - return basic_string (__str, __len); - } - } // namespace string_literals + inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string + operator"" s(const char32_t* __str, size_t __len) { + return basic_string(__str, __len); + } +} // namespace string_literals } // namespace literals -#if _LIBCPP_STD_VER > 17 +# if _LIBCPP_STD_VER > 17 template <> inline constexpr bool __format::__enable_insertable> = true; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> inline constexpr bool __format::__enable_insertable> = true; -#endif -#endif +# endif +# endif #endif diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml --- a/libcxx/utils/ci/buildkite-pipeline.yml +++ b/libcxx/utils/ci/buildkite-pipeline.yml @@ -33,8 +33,6 @@ automatic: - exit_status: -1 # Agent was lost limit: 2 - soft_fail: - - exit_status: 1 timeout_in_minutes: 120 - label: "Generated output"