diff --git a/.arcconfig b/.arcconfig deleted file mode 100644 index b7486508b..000000000 --- a/.arcconfig +++ /dev/null @@ -1,4 +0,0 @@ -{ - "repository.callsign" : "CXX", - "conduit_uri" : "https://reviews.llvm.org/" -} diff --git a/.clang-format b/.clang-format index dd596813f..cfa0c2896 100644 --- a/.clang-format +++ b/.clang-format @@ -10,4 +10,7 @@ PointerAlignment: Left # Disable formatting options which may break tests. SortIncludes: false ReflowComments: false + +# libc++ has some long names so we need more than the 80 column limit imposed by LLVM style, for sensible formatting +ColumnLimit: 120 --- diff --git a/.gitignore b/.gitignore index 49657ed81..4b214ca4b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,12 +22,6 @@ var/ .installed.cfg *.egg -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - # Installer logs pip-log.txt pip-delete-this-directory.txt diff --git a/CMakeLists.txt.old b/CMakeLists.txt.old index 358bd62d3..5ef0a7727 100644 --- a/CMakeLists.txt.old +++ b/CMakeLists.txt.old @@ -10,14 +10,11 @@ endif() #=============================================================================== cmake_minimum_required(VERSION 3.13.4) -set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") - # Add path for custom modules -list(INSERT CMAKE_MODULE_PATH 0 +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" - "${LLVM_COMMON_CMAKE_UTILS}" - "${LLVM_COMMON_CMAKE_UTILS}/Modules" + ${CMAKE_MODULE_PATH} ) set(CMAKE_FOLDER "libc++") @@ -27,32 +24,37 @@ set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) - message(WARNING "The Standalone build is deprecated in this release. Please use one of the ways " - "described at https://libcxx.llvm.org/BuildingLibcxx.html for building libc++.") project(libcxx CXX C) set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION 14.0.6) + set(PACKAGE_VERSION 13.0.1) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") # In a standalone build, we don't have llvm to automatically generate the # llvm-lit script for us. So we need to provide an explicit directory that # the configurator should write the script into. - set(LIBCXX_STANDALONE_BUILD TRUE) + set(LIBCXX_STANDALONE_BUILD 1) set(LLVM_LIT_OUTPUT_DIR "${LIBCXX_BINARY_DIR}/bin") -endif() -# Must go below project(..) -include(GNUInstallDirs) - -if (LIBCXX_STANDALONE_BUILD) # Find the LLVM sources and simulate LLVM CMake options. include(HandleOutOfTreeLLVM) +endif() +if (LIBCXX_STANDALONE_BUILD) find_package(Python3 COMPONENTS Interpreter) if(NOT Python3_Interpreter_FOUND) - message(SEND_ERROR "Python3 not found. Python3 is required") + message(WARNING "Python3 not found, using python2 as a fallback") + find_package(Python2 COMPONENTS Interpreter REQUIRED) + if(Python2_VERSION VERSION_LESS 2.7) + message(SEND_ERROR "Python 2.7 or newer is required") + endif() + + # Treat python2 as python3 + add_executable(Python3::Interpreter IMPORTED) + set_target_properties(Python3::Interpreter PROPERTIES + IMPORTED_LOCATION ${Python2_EXECUTABLE}) + set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) endif() endif() @@ -114,16 +116,6 @@ option(LIBCXX_ENABLE_LOCALIZATION the C locale API (e.g. embedded). When localization is not supported, several parts of the library will be disabled: , , will be completely unusable, and other parts may be only partly available." ON) -option(LIBCXX_ENABLE_UNICODE - "Whether to include support for Unicode in the library. Disabling Unicode can - be useful when porting to platforms that don't support UTF-8 encoding (e.g. - embedded)." ON) -option(LIBCXX_ENABLE_WIDE_CHARACTERS - "Whether to include support for wide characters in the library. Disabling - wide character support can be useful when porting to platforms that don't - support the C functionality for wide characters. When wide characters are - not supported, several parts of the library will be disabled, notably the - wide character specializations of std::basic_string." ON) option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS "Whether to turn on vendor availability annotations on declarations that depend on definitions in a shared library. By default, we assume that we're not building @@ -135,13 +127,9 @@ option(LIBCXX_ENABLE_INCOMPLETE_FEATURES "Whether to enable support for incomplete library features. Incomplete features are new library features under development. These features don't guarantee ABI stability nor the quality of completed library features. Vendors - shipping the library may want to disable this option." OFF) -set(LIBCXX_TEST_CONFIG "legacy.cfg.in" CACHE STRING - "The path to the Lit testing configuration to use when running the tests. - If a relative path is provided, it is assumed to be relative to '/libcxx/test/configs'.") -if (NOT IS_ABSOLUTE "${LIBCXX_TEST_CONFIG}") - set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXX_TEST_CONFIG}") -endif() + shipping the library may want to disable this option." ON) +set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/legacy.cfg.in" CACHE STRING + "The Lit testing configuration to use when running the tests.") set(LIBCXX_TEST_PARAMS "" CACHE STRING "A list of parameters to run the Lit test suite with.") @@ -202,7 +190,6 @@ endif() option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF) set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.") -option(LIBCXX_EXTRA_SITE_DEFINES "Extra defines to add into __config_site") option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) set(LIBCXX_LIBCPPABI_VERSION "2" CACHE STRING "Version of libc++abi's ABI to re-export from libc++ when re-exporting is enabled. Note that this is not related to the version of libc++'s ABI itself!") @@ -268,20 +255,7 @@ option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) # Target options -------------------------------------------------------------- -option(LIBCXX_BUILD_32_BITS "Build 32 bit multilib libc++. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${LLVM_BUILD_32_BITS}) -if (LIBCXX_BUILD_32_BITS) - message(FATAL_ERROR "LIBCXX_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead.") -endif() - -if(NOT CMAKE_SYSROOT AND LIBCXX_SYSROOT) - message(WARNING "LIBCXX_SYSROOT is deprecated, please use CMAKE_SYSROOT instead") -endif() -if(NOT CMAKE_CXX_COMPILER_TARGET AND LIBCXX_TARGET_TRIPLE) - message(WARNING "LIBCXX_TARGET_TRIPLE is deprecated, please use CMAKE_CXX_COMPILER_TARGET instead") -endif() -if(NOT CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN AND LIBCXX_GCC_TOOLCHAIN) - message(WARNING "LIBCXX_GCC_TOOLCHAIN is deprecated, please use CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN instead") -endif() +option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) if(CMAKE_CXX_COMPILER_TARGET) set(LIBCXX_DEFAULT_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") @@ -295,7 +269,11 @@ set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}" CACHE STRING # Feature options ------------------------------------------------------------- option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) +option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) +option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) +option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) +option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) option(LIBCXX_ENABLE_MONOTONIC_CLOCK "Build libc++ with support for a monotonic clock. This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) @@ -393,6 +371,16 @@ if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") endif() +# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) +# and check that we can build with 32 bits if requested. +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) + if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM + message(STATUS "Building 32 bits executables and libraries.") + endif() +elseif(LIBCXX_BUILD_32_BITS) + message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") +endif() + # Warn users that LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option. if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") @@ -426,35 +414,38 @@ endif () # TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR # instead of hard-coding include/c++/v1. - -set(LIBCXX_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1" CACHE PATH - "Path where target-agnostic libc++ headers should be installed.") -set(LIBCXX_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH - "Path where built libc++ runtime libraries should be installed.") - if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH "Path where built libc++ libraries should be installed.") - set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH "Path where target-specific libc++ headers should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) endif() -else() - if(LLVM_LIBRARY_OUTPUT_INTDIR) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") - else() - set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") - endif() +elseif(LLVM_LIBRARY_OUTPUT_INTDIR) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH "Path where built libc++ libraries should be installed.") + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") +else() + set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++ libraries should be installed.") + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH "Path where target-specific libc++ headers should be installed.") endif() @@ -482,9 +473,7 @@ include(HandleLibcxxFlags) # These flags get added to CMAKE_CXX_FLAGS and CMAKE_C_FLAGS so that # 'config-ix' use them during feature checks. It also adds them to both # 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS' -if(ZOS) - add_target_flags_if_supported("-fzos-le-char-mode=ebcdic") -endif() +add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") if(LIBCXX_TARGET_TRIPLE) add_target_flags_if_supported("--target=${LIBCXX_TARGET_TRIPLE}") endif() @@ -541,7 +530,7 @@ function(cxx_add_basic_build_flags target) # in the dylib. C++20 is needed to use char8_t. set_target_properties(${target} PROPERTIES CXX_STANDARD 20 - CXX_STANDARD_REQUIRED YES + CXX_STANDARD_REQUIRED NO CXX_EXTENSIONS NO) # When building the dylib, don't warn for unavailable aligned allocation @@ -607,13 +596,13 @@ function(cxx_add_warning_flags target) endif() target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long - -Werror=return-type -Wextra-semi -Wundef - -Wformat-nonliteral) + -Werror=return-type -Wextra-semi -Wundef) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") target_add_compile_flags_if_supported(${target} PRIVATE -Wno-user-defined-literals -Wno-covered-switch-default -Wno-suggest-override + -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs ) if (LIBCXX_TARGETING_CLANG_CL) target_add_compile_flags_if_supported(${target} PRIVATE @@ -776,13 +765,6 @@ function(cxx_link_system_libraries target) target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") endif() - if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG AND LIBCXXABI_USE_LLVM_UNWINDER) - # If we're linking directly against the libunwind that we're building - # in the same invocation, don't try to link in the toolchain's - # default libunwind (which may be missing still). - target_add_link_flags_if_supported(${target} PRIVATE "--unwindlib=none") - endif() - if (LIBCXX_HAS_SYSTEM_LIB) target_link_libraries(${target} PRIVATE System) endif() @@ -885,8 +867,12 @@ config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM) config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT) config_define_if(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT) +config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) +config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) +config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) +config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default") config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION) endif() @@ -900,8 +886,6 @@ config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITH config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE) config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION) -config_define_if_not(LIBCXX_ENABLE_UNICODE _LIBCPP_HAS_NO_UNICODE) -config_define_if_not(LIBCXX_ENABLE_WIDE_CHARACTERS _LIBCPP_HAS_NO_WIDE_CHARACTERS) config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) # Incomplete features get their own specific disabling flags. This makes it # easier to grep for target specific flags once the feature is complete. @@ -920,17 +904,6 @@ if (LIBCXX_ABI_DEFINES) config_define(${abi_defines} _LIBCPP_ABI_DEFINES) endif() -if (LIBCXX_EXTRA_SITE_DEFINES) - set(extra_site_defines) - foreach (extra_site_define ${LIBCXX_EXTRA_SITE_DEFINES}) - # Allow defines such as DEFINE=VAL, transformed into "#define DEFINE VAL". - string(REPLACE "=" " " extra_site_define "${extra_site_define}") - list(APPEND extra_site_defines "#define ${extra_site_define}") - endforeach() - string(REPLACE ";" "\n" extra_site_defines "${extra_site_defines}") - config_define(${extra_site_defines} _LIBCPP_EXTRA_SITE_DEFINES) -endif() - # By default libc++ on Windows expects to use a shared library, which requires # the headers to use DLL import/export semantics. However when building a # static library only we modify the headers to disable DLL import/export. diff --git a/CREDITS.TXT b/CREDITS.TXT index cd5bc08a6..49f095d29 100644 --- a/CREDITS.TXT +++ b/CREDITS.TXT @@ -12,13 +12,6 @@ N: Saleem Abdulrasool E: compnerd@compnerd.org D: Minor patches and Linux fixes. -N: Ulf Adams -D: Invented the Ryu and Ryu Printf algorithms used in floating-point to_chars, and wrote the initial code. - -N: Muiez Ahmed -E: muiez@ibm.com -D: z/OS port. - N: Dan Albert E: danalbert@google.com D: Android support and test runner improvements. @@ -31,8 +24,9 @@ N: Holger Arnold E: holgerar@gmail.com D: Minor fix. -N: Jorg Brown -D: Ported floating-point to_chars from MSVC to libc++. +N: Ruben Van Boxem +E: vanboxem dot ruben at gmail dot com +D: Initial Windows patches. N: David Chisnall E: theraven at theravensnest dot org @@ -47,10 +41,6 @@ N: Jonathan B Coe E: jbcoe@me.com D: Implementation of propagate_const. -N: Matthew Dempsky -E: matthew@dempsky.org -D: Minor patches and bug fixes. - N: Christopher Di Bella E: cjdb@google.com E: cjdb.ns@gmail.com @@ -68,6 +58,10 @@ N: Bill Fisher E: william.w.fisher@gmail.com D: Regex bug fixes. +N: Matthew Dempsky +E: matthew@dempsky.org +D: Minor patches and bug fixes. + N: Google Inc. D: Copyright owner and contributor of the CityHash algorithm @@ -87,14 +81,6 @@ N: Argyrios Kyrtzidis E: kyrtzidis@apple.com D: Bug fixes. -N: Stephan T. Lavavej -E: stl@microsoft.com -E: stl@nuwen.net -D: Implemented floating-point to_chars. - -N: Microsoft Corporation -D: Contributed floating-point to_chars. - N: Bruce Mitchener, Jr. E: bruce.mitchener@gmail.com D: Emscripten-related changes. @@ -127,10 +113,6 @@ N: Jon Roelofs E: jroelofS@jroelofs.com D: Remote testing, Newlib port, baremetal/single-threaded support. -N: Kent Ross -E: k@mad.cash -D: Patches for operator<=> support - N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -149,10 +131,6 @@ N: Stephan Tolksdorf E: st@quanttec.com D: Minor fix -N: Ruben Van Boxem -E: vanboxem dot ruben at gmail dot com -D: Initial Windows patches. - N: Michael van der Westhuizen E: r1mikey at gmail dot com @@ -163,11 +141,6 @@ N: Klaas de Vries E: klaas at klaasgaaf dot nl D: Minor bug fix. -N: Mark de Wever -E: koraq at xs4all dot nl -D: Format library support. -D: Finalized the porting of MSVC's to_chars to libc++. - N: Zhang Xiongpang E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. @@ -176,11 +149,11 @@ N: Xing Xue E: xingxue@ca.ibm.com D: AIX port +N: Zhihao Yuan +E: lichray@gmail.com +D: Standard compatibility fixes. + N: Jeffrey Yasskin E: jyasskin@gmail.com E: jyasskin@google.com D: Linux fixes. - -N: Zhihao Yuan -E: lichray@gmail.com -D: Standard compatibility fixes. diff --git a/TODO.TXT b/TODO.TXT index bc785546b..cf489d291 100644 --- a/TODO.TXT +++ b/TODO.TXT @@ -16,8 +16,60 @@ Test Suite Tasks * Improve the quality and portability of the locale test data. * Convert failure tests to use Clang Verify. +Filesystem Tasks +================ +* P0492r2 - Implement National body comments for Filesystem + * INCOMPLETE - US 25: has_filename() is equivalent to just !empty() + * INCOMPLETE - US 31: Everything is defined in terms of one implicit host system + * INCOMPLETE - US 32: Meaning of 27.10.2.1 unclear + * INCOMPLETE - US 33: Definition of canonical path problematic + * INCOMPLETE - US 34: Are there attributes of a file that are not an aspect of the file system? + * INCOMPLETE - US 35: What synchronization is required to avoid a file system race? + * INCOMPLETE - US 36: Symbolic links themselves are attached to a directory via (hard) links + * INCOMPLETE - US 37: The term “redundant current directory (dot) elements” is not defined + * INCOMPLETE - US 38: Duplicates §17.3.16 + * INCOMPLETE - US 39: Remove note: Dot and dot-dot are not directories + * INCOMPLETE - US 40: Not all directories have a parent. + * INCOMPLETE - US 41: The term “parent directory” for a (non-directory) file is unusual + * INCOMPLETE - US 42: Pathname resolution does not always resolve a symlink + * INCOMPLETE - US 43: Concerns about encoded character types + * INCOMPLETE - US 44: Definition of path in terms of a string requires leaky abstraction + * INCOMPLETE - US 45: Generic format portability compromised by unspecified root-name + * INCOMPLETE - US 46: filename can be empty so productions for relative-path are redundant + * INCOMPLETE - US 47: “.” and “..” already match the name production + * INCOMPLETE - US 48: Multiple separators are often meaningful in a root-name + * INCOMPLETE - US 49: What does “method of conversion method” mean? + * INCOMPLETE - US 50: 27.10.8.1 ¶ 1.4 largely redundant with ¶ 1.3 + * INCOMPLETE - US 51: Failing to add / when appending empty string prevents useful apps + * INCOMPLETE - US 52: remove_filename() postcondition is not by itself a definition + * INCOMPLETE - US 53: remove_filename()'s name does not correspond to its behavior + * INCOMPLETE - US 54: remove_filename() is broken + * INCOMPLETE - US 55: replace_extension()'s use of path as parameter is inappropriate + * INCOMPLETE - US 56: Remove replace_extension()'s conditional addition of period + * INCOMPLETE - US 57: On Windows, absolute paths will sort in among relative paths + * INCOMPLETE - US 58: parent_path() behavior for root paths is useless + * INCOMPLETE - US 59: filename() returning path for single path components is bizarre + * INCOMPLETE - US 60: path("/foo/").filename()==path(".") is surprising + * INCOMPLETE - US 61: Leading dots in filename() should not begin an extension + * INCOMPLETE - US 62: It is important that stem()+extension()==filename() + * INCOMPLETE - US 63: lexically_normal() inconsistently treats trailing "/" but not "/.." as directory + * INCOMPLETE - US 73, CA 2: root-name is effectively implementation defined + * INCOMPLETE - US 74, CA 3: The term “pathname” is ambiguous in some contexts + * INCOMPLETE - US 75, CA 4: Extra flag in path constructors is needed + * INCOMPLETE - US 76, CA 5: root-name definition is over-specified. + * INCOMPLETE - US 77, CA 6: operator/ and other appends not useful if arg has root-name + * INCOMPLETE - US 78, CA 7: Member absolute() in 27.10.4.1 is overspecified for non-POSIX-like O/S + * INCOMPLETE - US 79, CA 8: Some operation functions are overspecified for implementation-defined file types + * INCOMPLETE - US 185: Fold error_code and non-error_code signatures into one signature + * INCOMPLETE - FI 14: directory_entry comparisons are members + * INCOMPLETE - Late 36: permissions() error_code overload should be noexcept + * INCOMPLETE - Late 37: permissions() actions should be separate parameter + * INCOMPLETE - Late 42: resize_file() Postcondition missing argument + Misc Tasks ========== * Find all sequences of >2 underscores and eradicate them. * run clang-tidy on libc++ * Document the "conditionally-supported" bits of libc++ +* Look at basic_string's move assignment operator, re LWG 2063 and POCMA +* Put a static_assert in std::allocator to deny const/volatile types (LWG 2447) diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index 95e28618b..c4b8247da 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -1,14 +1,3 @@ -if (CMAKE_VERSION VERSION_LESS 3.17) - message(WARNING "The libc++ benchmarks won't be available because the version of CMake is too old to support them.") - return() -endif() - -if (LIBCXX_STANDALONE_BUILD) - message(WARNING "The libc++ benchmarks are not available in a standalone build. Please migrate to an official build " - "as documented in https://libcxx.llvm.org/BuildingLibcxx.html.") - return() -endif() - include(ExternalProject) include(CheckCXXCompilerFlag) @@ -41,7 +30,7 @@ ExternalProject_Add(google-benchmark-libcxx EXCLUDE_FROM_ALL ON DEPENDS cxx cxx-headers PREFIX benchmark-libcxx - SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark + SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} @@ -58,7 +47,7 @@ ExternalProject_Add(google-benchmark-libcxx set(BENCHMARK_NATIVE_TARGET_FLAGS) if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN) set(BENCHMARK_NATIVE_TARGET_FLAGS - --gcc-toolchain=${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN}) + -gcc-toolchain ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN}) endif() split_list(BENCHMARK_NATIVE_TARGET_FLAGS) @@ -66,7 +55,7 @@ if (LIBCXX_BENCHMARK_NATIVE_STDLIB) ExternalProject_Add(google-benchmark-native EXCLUDE_FROM_ALL ON PREFIX benchmark-native - SOURCE_DIR ${LLVM_THIRD_PARTY_DIR}/benchmark + SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER} @@ -86,42 +75,56 @@ set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx) set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) -add_library( cxx-benchmarks-flags INTERFACE) -target_compile_features( cxx-benchmarks-flags INTERFACE cxx_std_20) -target_compile_options( cxx-benchmarks-flags INTERFACE -O2 -fsized-deallocation -nostdinc++) -target_include_directories(cxx-benchmarks-flags INTERFACE "${LIBCXX_GENERATED_INCLUDE_DIR}" - INTERFACE "${BENCHMARK_LIBCXX_INSTALL}/include" - INTERFACE "${LIBCXX_SOURCE_DIR}/test/support") -add_library( cxx-benchmarks-flags-native INTERFACE) -target_link_libraries( cxx-benchmarks-flags-native INTERFACE cxx-benchmarks-flags) -target_compile_options(cxx-benchmarks-flags-native INTERFACE ${BENCHMARK_NATIVE_TARGET_FLAGS}) -target_link_options( cxx-benchmarks-flags-native INTERFACE ${BENCHMARK_NATIVE_TARGET_FLAGS} "-L${BENCHMARK_NATIVE_INSTALL}/lib") +set(BENCHMARK_TEST_COMPILE_FLAGS + -O2 + -fsized-deallocation + -I${BENCHMARK_LIBCXX_INSTALL}/include + -I${LIBCXX_SOURCE_DIR}/test/support +) +set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS + ${BENCHMARK_TEST_COMPILE_FLAGS} + ${SANITIZER_FLAGS} + -Wno-user-defined-literals + -Wno-suggest-override +) + +set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS + -nodefaultlibs + -L${BENCHMARK_LIBCXX_INSTALL}/lib/ + ${SANITIZER_FLAGS} +) +set(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS + ${BENCHMARK_NATIVE_TARGET_FLAGS} + ${BENCHMARK_TEST_COMPILE_FLAGS} +) +set(BENCHMARK_TEST_NATIVE_LINK_FLAGS + ${BENCHMARK_NATIVE_TARGET_FLAGS} + -L${BENCHMARK_NATIVE_INSTALL}/lib +) +split_list(BENCHMARK_TEST_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_LIBCXX_LINK_FLAGS) +split_list(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS) +split_list(BENCHMARK_TEST_NATIVE_LINK_FLAGS) + if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++") find_library(LIBSTDCXX_FILESYSTEM_TEST stdc++fs PATHS ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN} PATH_SUFFIXES lib lib64 DOC "The libstdc++ filesystem library used by the benchmarks" ) - if (LIBSTDCXX_FILESYSTEM_TEST) - target_link_libraries(cxx-benchmarks-flags-native INTERFACE -lstdc++fs) - endif() -else() - target_link_libraries(cxx-benchmarks-flags-native INTERFACE -lc++fs -lc++experimental) + if (NOT "${LIBSTDCXX_FILESYSTEM_TEST}" STREQUAL "LIBSTDCXX_FILESYSTEM_TEST-NOTFOUND") + set(LIBSTDCXX_FILESYSTEM_LIB "stdc++fs") + endif() endif() -add_library( cxx-benchmarks-flags-libcxx INTERFACE) -target_link_libraries( cxx-benchmarks-flags-libcxx INTERFACE cxx-benchmarks-flags) -target_compile_options(cxx-benchmarks-flags-libcxx INTERFACE ${SANITIZER_FLAGS} -Wno-user-defined-literals -Wno-suggest-override) -target_link_options( cxx-benchmarks-flags-libcxx INTERFACE -nodefaultlibs "-L${BENCHMARK_LIBCXX_INSTALL}/lib" ${SANITIZER_FLAGS}) - set(libcxx_benchmark_targets) function(add_benchmark_test name source_file) set(libcxx_target ${name}_libcxx) list(APPEND libcxx_benchmark_targets ${libcxx_target}) add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file}) - target_link_libraries(${libcxx_target} PRIVATE cxx-benchmarks-flags-libcxx) add_dependencies(${libcxx_target} cxx google-benchmark-libcxx) add_dependencies(cxx-benchmarks ${libcxx_target}) if (LIBCXX_ENABLE_SHARED) @@ -140,15 +143,27 @@ function(add_benchmark_test name source_file) PROPERTIES OUTPUT_NAME "${name}.libcxx.out" RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" + COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}" + LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) cxx_link_system_libraries(${libcxx_target}) if (LIBCXX_BENCHMARK_NATIVE_STDLIB) + if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++" AND NOT DEFINED LIBSTDCXX_FILESYSTEM_LIB + AND "${name}" STREQUAL "filesystem") + return() + endif() set(native_target ${name}_native) add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file}) - target_link_libraries(${native_target} PRIVATE cxx-benchmarks-flags-native) add_dependencies(${native_target} google-benchmark-native google-benchmark-libcxx) target_link_libraries(${native_target} PRIVATE -lbenchmark) + if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++") + target_link_libraries(${native_target} PRIVATE ${LIBSTDCXX_FILESYSTEM_LIB}) + elseif (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++") + target_link_libraries(${native_target} PRIVATE -lc++fs -lc++experimental) + endif() if (LIBCXX_HAS_PTHREAD_LIB) target_link_libraries(${native_target} PRIVATE -pthread) endif() @@ -157,6 +172,11 @@ function(add_benchmark_test name source_file) PROPERTIES OUTPUT_NAME "${name}.native.out" RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" + INCLUDE_DIRECTORIES "" + COMPILE_FLAGS "${BENCHMARK_TEST_NATIVE_COMPILE_FLAGS}" + LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO) endif() endfunction() @@ -166,11 +186,6 @@ endfunction() # Register Benchmark tests #============================================================================== file(GLOB BENCHMARK_TESTS "*.bench.cpp") - -if (NOT LIBCXX_ENABLE_INCOMPLETE_FEATURES) - list(FILTER BENCHMARK_TESTS EXCLUDE REGEX "(format_to_n|format_to|format|formatted_size|formatter_float|std_format_spec_string_unicode).bench.cpp") -endif() - foreach(test_path ${BENCHMARK_TESTS}) get_filename_component(test_file "${test_path}" NAME) string(REPLACE ".bench.cpp" "" test_name "${test_file}") diff --git a/benchmarks/GenerateInput.h b/benchmarks/GenerateInput.h index 3e63f8413..e4f131c62 100644 --- a/benchmarks/GenerateInput.h +++ b/benchmarks/GenerateInput.h @@ -36,9 +36,10 @@ inline char getRandomChar() { } template -inline IntT getRandomInteger(IntT Min, IntT Max) { - std::uniform_int_distribution dist(Min, Max); - return static_cast(dist(getRandomEngine())); +inline IntT getRandomInteger(IntT Min = 0, + IntT Max = std::numeric_limits::max()) { + std::uniform_int_distribution dist(Min, Max); + return dist(getRandomEngine()); } inline std::string getRandomString(std::size_t Len) { @@ -101,7 +102,7 @@ template std::vector getRandomIntegerInputs(size_t N) { std::vector inputs; for (size_t i=0; i < N; ++i) { - inputs.push_back(getRandomInteger(0, std::numeric_limits::max())); + inputs.push_back(getRandomInteger()); } return inputs; } diff --git a/benchmarks/algorithms.bench.cpp b/benchmarks/algorithms.bench.cpp index e5dd37f06..93383e2b9 100644 --- a/benchmarks/algorithms.bench.cpp +++ b/benchmarks/algorithms.bench.cpp @@ -38,65 +38,18 @@ enum class Order { Descending, SingleElement, PipeOrgan, - Heap, - QuickSortAdversary, + Heap }; -struct AllOrders : EnumValuesAsTuple { +struct AllOrders : EnumValuesAsTuple { static constexpr const char* Names[] = {"Random", "Ascending", "Descending", "SingleElement", - "PipeOrgan", "Heap", - "QuickSortAdversary"}; + "PipeOrgan", "Heap"}; }; -// fillAdversarialQuickSortInput fills the input vector with N int-like values. -// These values are arranged in such a way that they would invoke O(N^2) -// behavior on any quick sort implementation that satisifies certain conditions. -// Details are available in the following paper: -// "A Killer Adversary for Quicksort", M. D. McIlroy, Software—Practice & -// ExperienceVolume 29 Issue 4 April 10, 1999 pp 341–344. -// https://dl.acm.org/doi/10.5555/311868.311871. -template -void fillAdversarialQuickSortInput(T& V, size_t N) { - assert(N > 0); - // If an element is equal to gas, it indicates that the value of the element - // is still to be decided and may change over the course of time. - const int gas = N - 1; - V.resize(N); - for (int i = 0; i < N; ++i) { - V[i] = gas; - } - // Candidate for the pivot position. - int candidate = 0; - int nsolid = 0; - // Populate all positions in the generated input to gas. - std::vector ascVals(V.size()); - // Fill up with ascending values from 0 to V.size()-1. These will act as - // indices into V. - std::iota(ascVals.begin(), ascVals.end(), 0); - std::sort(ascVals.begin(), ascVals.end(), [&](int x, int y) { - if (V[x] == gas && V[y] == gas) { - // We are comparing two inputs whose value is still to be decided. - if (x == candidate) { - V[x] = nsolid++; - } else { - V[y] = nsolid++; - } - } - if (V[x] == gas) { - candidate = x; - } else if (V[y] == gas) { - candidate = y; - } - return V[x] < V[y]; - }); -} - template void fillValues(std::vector& V, size_t N, Order O) { if (O == Order::SingleElement) { V.resize(N, 0); - } else if (O == Order::QuickSortAdversary) { - fillAdversarialQuickSortInput(V, N); } else { while (V.size() < N) V.push_back(V.size()); @@ -175,9 +128,6 @@ void sortValues(T& V, Order O) { case Order::Heap: std::make_heap(V.begin(), V.end()); break; - case Order::QuickSortAdversary: - // Nothing to do - break; } } @@ -384,4 +334,4 @@ int main(int argc, char** argv) { makeCartesianProductBenchmark(Quantities); makeCartesianProductBenchmark(Quantities); benchmark::RunSpecifiedBenchmarks(); -} +} \ No newline at end of file diff --git a/benchmarks/algorithms.partition_point.bench.cpp b/benchmarks/algorithms.partition_point.bench.cpp index 8192f9720..840cf0391 100644 --- a/benchmarks/algorithms.partition_point.bench.cpp +++ b/benchmarks/algorithms.partition_point.bench.cpp @@ -30,7 +30,7 @@ struct TestIntBase { static std::vector generateInput(size_t size) { std::vector Res(size); std::generate(Res.begin(), Res.end(), - [] { return getRandomInteger(0, std::numeric_limits::max()); }); + [] { return getRandomInteger(); }); return Res; } }; diff --git a/benchmarks/allocation.bench.cpp b/benchmarks/allocation.bench.cpp index ad962de5b..236e74044 100644 --- a/benchmarks/allocation.bench.cpp +++ b/benchmarks/allocation.bench.cpp @@ -97,6 +97,7 @@ static void BM_DeallocateOnly(benchmark::State& st) { const size_t alloc_size = st.range(0); const auto NumAllocs = st.max_iterations; + using PtrT = void*; std::vector Pointers(NumAllocs); for (auto& p : Pointers) { p = AllocWrapper::Allocate(alloc_size); diff --git a/benchmarks/deque.bench.cpp b/benchmarks/deque.bench.cpp index 61b45cbf4..0025a335c 100644 --- a/benchmarks/deque.bench.cpp +++ b/benchmarks/deque.bench.cpp @@ -1,3 +1,4 @@ +// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/benchmarks/filesystem.bench.cpp b/benchmarks/filesystem.bench.cpp index 4fe4fc503..95aecd504 100644 --- a/benchmarks/filesystem.bench.cpp +++ b/benchmarks/filesystem.bench.cpp @@ -83,7 +83,7 @@ void BM_PathIterateMultipleTimes(benchmark::State &st, GenInputs gen) { PP /= Part; benchmark::DoNotOptimize(PP.native().data()); while (st.KeepRunning()) { - for (auto const& E : PP) { + for (auto &E : PP) { benchmark::DoNotOptimize(E.native().data()); } benchmark::ClobberMemory(); @@ -104,7 +104,7 @@ void BM_PathIterateOnce(benchmark::State &st, GenInputs gen) { benchmark::DoNotOptimize(PP.native().data()); while (st.KeepRunning()) { const path P = PP.native(); - for (auto const& E : P) { + for (auto &E : P) { benchmark::DoNotOptimize(E.native().data()); } benchmark::ClobberMemory(); diff --git a/benchmarks/format.bench.cpp b/benchmarks/format.bench.cpp deleted file mode 100644 index 89f113253..000000000 --- a/benchmarks/format.bench.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include - -#include "benchmark/benchmark.h" -#include "make_string.h" - -#define CSTR(S) MAKE_CSTRING(CharT, S) - -template -static void BM_format_string(benchmark::State& state) { - size_t size = state.range(0); - std::basic_string str(size, CharT('*')); - - while (state.KeepRunningBatch(str.size())) - benchmark::DoNotOptimize(std::format(CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} -BENCHMARK_TEMPLATE(BM_format_string, char)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_string, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - benchmark::RunSpecifiedBenchmarks(); -} diff --git a/benchmarks/format_to.bench.cpp b/benchmarks/format_to.bench.cpp deleted file mode 100644 index 4d6489786..000000000 --- a/benchmarks/format_to.bench.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//===----------------------------------------------------------------------===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "benchmark/benchmark.h" -#include "make_string.h" - -#define CSTR(S) MAKE_CSTRING(CharT, S) - -/*** Back inserter ***/ - -template -static void BM_format_to_string_back_inserter(benchmark::State& state) { - using CharT = typename Container::value_type; - size_t size = state.range(0); - auto str = std::basic_string(size, CharT('*')); - - for (auto _ : state) { - Container output; - benchmark::DoNotOptimize(std::format_to(std::back_inserter(output), CSTR("{}"), str)); - } - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Begin ***/ - -template -static void BM_format_to_string_begin(benchmark::State& state) { - using CharT = typename Container::value_type; - size_t size = state.range(0); - auto str = std::basic_string(size, CharT('*')); - - Container output(size, CharT('-')); - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to(std::begin(output), CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Pointer ***/ - -template -static void BM_format_to_string_span(benchmark::State& state) { - size_t size = state.range(0); - auto str = std::basic_string(size, CharT('*')); - - auto buffer = std::basic_string(size, CharT('-')); - std::span output{buffer}; - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to(std::begin(output), CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -template -static void BM_format_to_string_pointer(benchmark::State& state) { - size_t size = state.range(0); - auto str = std::basic_string(size, CharT('*')); - - auto buffer = std::basic_string(size, CharT('-')); - CharT* output = buffer.data(); - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to(output, CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Main ***/ - -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::string)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::string)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_span, char)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_pointer, char)->RangeMultiplier(2)->Range(1, 1 << 20); - -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::wstring)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_back_inserter, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::wstring)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_begin, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_span, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_string_pointer, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - benchmark::RunSpecifiedBenchmarks(); -} diff --git a/benchmarks/format_to_n.bench.cpp b/benchmarks/format_to_n.bench.cpp deleted file mode 100644 index c1e52b010..000000000 --- a/benchmarks/format_to_n.bench.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//===----------------------------------------------------------------------===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "benchmark/benchmark.h" -#include "make_string.h" - -#define CSTR(S) MAKE_CSTRING(CharT, S) - -/*** Back inserter ***/ - -template -static void BM_format_to_n_string_back_inserter(benchmark::State& state) { - using CharT = typename Container::value_type; - size_t size = state.range(0); - auto str = std::basic_string(2 * size, CharT('*')); - - for (auto _ : state) { - Container output; - benchmark::DoNotOptimize(std::format_to_n(std::back_inserter(output), size, CSTR("{}"), str)); - } - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Begin ***/ - -template -static void BM_format_to_n_string_begin(benchmark::State& state) { - using CharT = typename Container::value_type; - size_t size = state.range(0); - auto str = std::basic_string(2 * size, CharT('*')); - - Container output(size, CharT('-')); - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to_n(std::begin(output), size, CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Pointer ***/ - -template -static void BM_format_to_n_string_span(benchmark::State& state) { - size_t size = state.range(0); - auto str = std::basic_string(2 * size, CharT('*')); - - auto buffer = std::basic_string(size, CharT('-')); - std::span output{buffer}; - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to_n(std::begin(output), size, CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -template -static void BM_format_to_n_string_pointer(benchmark::State& state) { - size_t size = state.range(0); - auto str = std::basic_string(2 * size, CharT('*')); - - auto buffer = std::basic_string(size, CharT('-')); - CharT* output = buffer.data(); - for (auto _ : state) - benchmark::DoNotOptimize(std::format_to_n(output, size, CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} - -/*** Main ***/ - -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::string)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::string)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_span, char)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_pointer, char)->RangeMultiplier(2)->Range(1, 1 << 20); - -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::wstring)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_back_inserter, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::wstring)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::vector)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_begin, std::list)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_span, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_format_to_n_string_pointer, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - benchmark::RunSpecifiedBenchmarks(); -} diff --git a/benchmarks/formatted_size.bench.cpp b/benchmarks/formatted_size.bench.cpp deleted file mode 100644 index de67dae71..000000000 --- a/benchmarks/formatted_size.bench.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include - -#include "benchmark/benchmark.h" -#include "make_string.h" - -#define CSTR(S) MAKE_CSTRING(CharT, S) - -template -static void BM_formatted_size_string(benchmark::State& state) { - size_t size = state.range(0); - std::basic_string str(size, CharT('*')); - - while (state.KeepRunningBatch(str.size())) - benchmark::DoNotOptimize(std::formatted_size(CSTR("{}"), str)); - - state.SetBytesProcessed(state.iterations() * size * sizeof(CharT)); -} -BENCHMARK_TEMPLATE(BM_formatted_size_string, char)->RangeMultiplier(2)->Range(1, 1 << 20); -BENCHMARK_TEMPLATE(BM_formatted_size_string, wchar_t)->RangeMultiplier(2)->Range(1, 1 << 20); - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - benchmark::RunSpecifiedBenchmarks(); -} diff --git a/benchmarks/formatter_float.bench.cpp b/benchmarks/formatter_float.bench.cpp deleted file mode 100644 index 3190b3779..000000000 --- a/benchmarks/formatter_float.bench.cpp +++ /dev/null @@ -1,241 +0,0 @@ -//===----------------------------------------------------------------------===// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include - -#include "CartesianBenchmarks.h" -#include "benchmark/benchmark.h" - -// *** Localization *** -enum class LocalizationE { False, True }; -struct AllLocalizations : EnumValuesAsTuple { - static constexpr const char* Names[] = {"LocFalse", "LocTrue"}; -}; - -template -struct Localization {}; - -template <> -struct Localization { - static constexpr const char* fmt = ""; -}; - -template <> -struct Localization { - static constexpr const char* fmt = "L"; -}; - -// *** Types *** -enum class TypeE { Float, Double, LongDouble }; -// TODO FMT Set to 3 after to_chars has long double suport. -struct AllTypes : EnumValuesAsTuple { - static constexpr const char* Names[] = {"Float", "Double", "LongDouble"}; -}; - -template -struct Type {}; - -template <> -struct Type { - using type = float; -}; - -template <> -struct Type { - using type = double; -}; - -template <> -struct Type { - using type = long double; -}; - -// *** Values *** -enum class ValueE { Inf, Random }; -struct AllValues : EnumValuesAsTuple { - static constexpr const char* Names[] = {"Inf", "Random"}; -}; - -template -struct Value {}; - -template <> -struct Value { - template - static std::array make_data() { - std::array result; - std::fill(result.begin(), result.end(), -std::numeric_limits::infinity()); - return result; - } -}; - -template <> -struct Value { - template - static std::array make_data() { - std::random_device seed; - std::mt19937 generator(seed()); - std::uniform_int_distribution> distribution; - - std::array result; - std::generate(result.begin(), result.end(), [&] { - while (true) { - auto result = std::bit_cast(distribution(generator)); - if (std::isfinite(result)) - return result; - } - }); - return result; - } -}; - -// *** Display Type *** -enum class DisplayTypeE { - Default, - Hex, - Scientific, - Fixed, - General, -}; -struct AllDisplayTypes : EnumValuesAsTuple { - static constexpr const char* Names[] = {"DisplayDefault", "DisplayHex", "DisplayScientific", "DisplayFixed", - "DisplayGeneral"}; -}; - -template -struct DisplayType {}; - -template <> -struct DisplayType { - static constexpr const char* fmt = ""; -}; - -template <> -struct DisplayType { - static constexpr const char* fmt = "a"; -}; - -template <> -struct DisplayType { - static constexpr const char* fmt = "e"; -}; - -template <> -struct DisplayType { - static constexpr const char* fmt = "f"; -}; - -template <> -struct DisplayType { - static constexpr const char* fmt = "g"; -}; - -// *** Alignment *** -enum class AlignmentE { None, Left, Center, Right, ZeroPadding }; -struct AllAlignments : EnumValuesAsTuple { - static constexpr const char* Names[] = {"AlignNone", "AlignmentLeft", "AlignmentCenter", "AlignmentRight", - "ZeroPadding"}; -}; - -template -struct Alignment {}; - -template <> -struct Alignment { - static constexpr const char* fmt = ""; -}; - -template <> -struct Alignment { - // Width > PrecisionE::Huge - static constexpr const char* fmt = "0<17500"; -}; - -template <> -struct Alignment { - // Width > PrecisionE::Huge - static constexpr const char* fmt = "0^17500"; -}; - -template <> -struct Alignment { - // Width > PrecisionE::Huge - static constexpr const char* fmt = "0>17500"; -}; - -template <> -struct Alignment { - // Width > PrecisionE::Huge - static constexpr const char* fmt = "017500"; -}; - -enum class PrecisionE { None, Zero, Small, Huge }; -struct AllPrecisions : EnumValuesAsTuple { - static constexpr const char* Names[] = {"PrecNone", "PrecZero", "PrecSmall", "PrecHuge"}; -}; - -template -struct Precision {}; - -template <> -struct Precision { - static constexpr const char* fmt = ""; -}; - -template <> -struct Precision { - static constexpr const char* fmt = ".0"; -}; - -template <> -struct Precision { - static constexpr const char* fmt = ".10"; -}; - -template <> -struct Precision { - // The maximum precision for a minimal sub normal long double is ±0x1p-16494. - // This value is always larger than that value forcing the trailing zero path - // to be executed. - static constexpr const char* fmt = ".17000"; -}; - -template -struct FloatingPoint { - using F = typename Type::type; - - void run(benchmark::State& state) const { - std::array data{Value::template make_data()}; - std::array output; - std::string fmt{std::string("{:") + Alignment::fmt + Precision::fmt + - Localization::fmt + DisplayType::fmt + "}"}; - - while (state.KeepRunningBatch(1000)) - for (F value : data) - benchmark::DoNotOptimize(std::format_to(output.begin(), fmt, value)); - } - - std::string name() const { - return "FloatingPoint" + L::name() + DT::name() + T::name() + V::name() + A::name() + P::name(); - } -}; - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - makeCartesianProductBenchmark(); - - benchmark::RunSpecifiedBenchmarks(); -} diff --git a/benchmarks/std_format_spec_string_unicode.bench.cpp b/benchmarks/std_format_spec_string_unicode.bench.cpp deleted file mode 100644 index 156eaebd4..000000000 --- a/benchmarks/std_format_spec_string_unicode.bench.cpp +++ /dev/null @@ -1,196 +0,0 @@ -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_HAS_NO_UNICODE - -#include -#include - -#include "benchmark/benchmark.h" - -#include "test_macros.h" - -template -class tester { - static constexpr size_t size_ = N - 1; - std::array data_; - -public: - explicit constexpr tester(const CharT (&input)[N]) { - auto it = data_.begin(); - for (int i = 0; i < 100; ++i) - it = std::copy_n(input, size_, it); - } - - constexpr size_t size() const noexcept { return data_.size(); } - constexpr const CharT* begin() const noexcept { return data_.begin(); } - constexpr const CharT* end() const noexcept { return data_.end(); } - - void test(benchmark::State& state) const { - for (auto _ : state) - benchmark::DoNotOptimize(std::__format_spec::__get_string_alignment( - begin(), end(), 1'000'000, 1'000'000)); - state.SetItemsProcessed(state.iterations() * size()); - } -}; - -#define TEST(u8) \ - if constexpr (std::same_as) { \ - constexpr auto p = tester{u8}; \ - p.test(state); \ - } else if constexpr (std::same_as) { \ - constexpr auto p = tester{TEST_CONCAT(u, u8)}; \ - p.test(state); \ - } else { \ - constexpr auto p = tester{TEST_CONCAT(U, u8)}; \ - p.test(state); \ - } - -template -static void BM_EstimateLengthNoMultiByte(benchmark::State& state) { - TEST("The quick brown fox jumps over the lazy dog"); -} - -template -static void BM_EstimateLengthTwoByteDE(benchmark::State& state) { - static_assert(sizeof("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich") == 67); - - // https://en.wikipedia.org/wiki/Pangram - TEST("Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich"); -} - -template -static void BM_EstimateLengthTwoBytePL(benchmark::State& state) { - static_assert(sizeof("Stróż pchnął kość w quiz gędźb vel fax myjń") == 53); - - // https://en.wikipedia.org/wiki/Pangram - TEST("Stróż pchnął kość w quiz gędźb vel fax myjń"); -} - -// All values below are 1100, which is is the first multi column sequence. -template -static void BM_EstimateLengthThreeByteSingleColumnLow(benchmark::State& state) { - static_assert(sizeof("\u0800\u0801\u0802\u0803\u0804\u0805\u0806\u0807" - "\u0808\u0809\u080a\u080b\u080c\u080d\u080e\u080f") == - 49); - - TEST("\u0800\u0801\u0802\u0803\u0804\u0805\u0806\u0807" - "\u0808\u0809\u080a\u080b\u080c\u080d\u080e\u080f"); -} - -template -static void -BM_EstimateLengthThreeByteSingleColumnHigh(benchmark::State& state) { - static_assert(sizeof("\u1800\u1801\u1802\u1803\u1804\u1805\u1806\u1807" - "\u1808\u1809\u180a\u180b\u180c\u180d\u180e\u180f") == - 49); - - TEST("\u1800\u1801\u1802\u1803\u1804\u1805\u1806\u1807" - "\u1808\u1809\u180a\u180b\u180c\u180d\u180e\u180f"); -} - -template -static void BM_EstimateLengthThreeByteDoubleColumn(benchmark::State& state) { - static_assert(sizeof("\u1100\u0801\u0802\u0803\u0804\u0805\u0806\u0807" - "\u1108\u0809\u080a\u080b\u080c\u080d\u080e\u080f") == - 49); - - TEST("\u1100\u0801\u0802\u0803\u0804\u0805\u0806\u0807" - "\u1108\u0809\u080a\u080b\u080c\u080d\u080e\u080f"); -} - -template -static void BM_EstimateLengthThreeByte(benchmark::State& state) { - static_assert(sizeof("\u1400\u1501\ubbbb\uff00\u0800\u4099\uabcd\u4000" - "\u8ead\ubeef\u1111\u4987\u4321\uffff\u357a\ud50e") == - 49); - - TEST("\u1400\u1501\ubbbb\uff00\u0800\u4099\uabcd\u4000" - "\u8ead\ubeef\u1111\u4987\u4321\uffff\u357a\ud50e"); -} - -template -static void BM_EstimateLengthFourByteSingleColumn(benchmark::State& state) { - static_assert(sizeof("\U00010000\U00010001\U00010002\U00010003" - "\U00010004\U00010005\U00010006\U00010007" - "\U00010008\U00010009\U0001000a\U0001000b" - "\U0001000c\U0001000d\U0001000e\U0001000f") == 65); - - TEST("\U00010000\U00010001\U00010002\U00010003" - "\U00010004\U00010005\U00010006\U00010007" - "\U00010008\U00010009\U0001000a\U0001000b" - "\U0001000c\U0001000d\U0001000e\U0001000f"); -} - -template -static void BM_EstimateLengthFourByteDoubleColumn(benchmark::State& state) { - static_assert(sizeof("\U00020000\U00020002\U00020002\U00020003" - "\U00020004\U00020005\U00020006\U00020007" - "\U00020008\U00020009\U0002000a\U0002000b" - "\U0002000c\U0002000d\U0002000e\U0002000f") == 65); - - TEST("\U00020000\U00020002\U00020002\U00020003" - "\U00020004\U00020005\U00020006\U00020007" - "\U00020008\U00020009\U0002000a\U0002000b" - "\U0002000c\U0002000d\U0002000e\U0002000f"); -} - -template -static void BM_EstimateLengthFourByte(benchmark::State& state) { - static_assert(sizeof("\U00010000\U00010001\U00010002\U00010003" - "\U00020004\U00020005\U00020006\U00020007" - "\U00010008\U00010009\U0001000a\U0001000b" - "\U0002000c\U0002000d\U0002000e\U0002000f") == 65); - - TEST("\U00010000\U00010001\U00010002\U00010003" - "\U00020004\U00020005\U00020006\U00020007" - "\U00010008\U00010009\U0001000a\U0001000b" - "\U0002000c\U0002000d\U0002000e\U0002000f"); -} - -BENCHMARK_TEMPLATE(BM_EstimateLengthNoMultiByte, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoByteDE, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoBytePL, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnLow, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnHigh, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteDoubleColumn, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByte, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteSingleColumn, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteDoubleColumn, char); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByte, char); - -BENCHMARK_TEMPLATE(BM_EstimateLengthNoMultiByte, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoByteDE, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoBytePL, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnLow, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnHigh, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteDoubleColumn, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByte, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteSingleColumn, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteDoubleColumn, char16_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByte, char16_t); - -BENCHMARK_TEMPLATE(BM_EstimateLengthNoMultiByte, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoByteDE, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthTwoBytePL, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnLow, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteSingleColumnHigh, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByteDoubleColumn, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthThreeByte, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteSingleColumn, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByteDoubleColumn, char32_t); -BENCHMARK_TEMPLATE(BM_EstimateLengthFourByte, char32_t); - -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - if (benchmark::ReportUnrecognizedArguments(argc, argv)) - return 1; - - benchmark::RunSpecifiedBenchmarks(); -} -#else -int main(int, char**) { return 0; } -#endif diff --git a/cmake/Modules/DefineLinkerScript.cmake b/cmake/Modules/DefineLinkerScript.cmake index 71a430867..be7f026af 100644 --- a/cmake/Modules/DefineLinkerScript.cmake +++ b/cmake/Modules/DefineLinkerScript.cmake @@ -31,7 +31,7 @@ function(define_linker_script target) set(link_libraries) if (interface_libs) foreach(lib IN LISTS interface_libs) - if ("${lib}" MATCHES "cxx-headers|ParallelSTL") + if ("${lib}" STREQUAL "cxx-headers") continue() endif() # If ${lib} is not a target, we use a dummy target which we know will diff --git a/cmake/Modules/HandleCompilerRT.cmake b/cmake/Modules/HandleCompilerRT.cmake new file mode 100644 index 000000000..1ce256574 --- /dev/null +++ b/cmake/Modules/HandleCompilerRT.cmake @@ -0,0 +1,64 @@ +function(find_compiler_rt_library name dest) + if (NOT DEFINED LIBCXX_COMPILE_FLAGS) + message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function") + endif() + set(dest "" PARENT_SCOPE) + set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS} + "--rtlib=compiler-rt" "--print-libgcc-file-name") + if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_TARGET) + list(APPEND CLANG_COMMAND "--target=${CMAKE_CXX_COMPILER_TARGET}") + endif() + get_property(LIBCXX_CXX_FLAGS CACHE CMAKE_CXX_FLAGS PROPERTY VALUE) + string(REPLACE " " ";" LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}") + list(APPEND CLANG_COMMAND ${LIBCXX_CXX_FLAGS}) + execute_process( + COMMAND ${CLANG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LIBRARY_FILE + ) + string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE) + file(TO_CMAKE_PATH "${LIBRARY_FILE}" LIBRARY_FILE) + string(REPLACE "builtins" "${name}" LIBRARY_FILE "${LIBRARY_FILE}") + if (NOT HAD_ERROR AND EXISTS "${LIBRARY_FILE}") + message(STATUS "Found compiler-rt library: ${LIBRARY_FILE}") + set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE) + else() + message(STATUS "Failed to find compiler-rt library") + endif() +endfunction() + +function(find_compiler_rt_dir dest) + if (NOT DEFINED LIBCXX_COMPILE_FLAGS) + message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this function") + endif() + set(dest "" PARENT_SCOPE) + if (APPLE) + set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS} + "-print-file-name=lib") + execute_process( + COMMAND ${CLANG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LIBRARY_DIR + ) + string(STRIP "${LIBRARY_DIR}" LIBRARY_DIR) + file(TO_CMAKE_PATH "${LIBRARY_DIR}" LIBRARY_DIR) + set(LIBRARY_DIR "${LIBRARY_DIR}/darwin") + else() + set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS} + "--rtlib=compiler-rt" "--print-libgcc-file-name") + execute_process( + COMMAND ${CLANG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE LIBRARY_FILE + ) + string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE) + file(TO_CMAKE_PATH "${LIBRARY_FILE}" LIBRARY_FILE) + get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY) + endif() + if (NOT HAD_ERROR AND EXISTS "${LIBRARY_DIR}") + message(STATUS "Found compiler-rt directory: ${LIBRARY_DIR}") + set(${dest} "${LIBRARY_DIR}" PARENT_SCOPE) + else() + message(STATUS "Failed to find compiler-rt directory") + endif() +endfunction() diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake index 9b5df6e01..5a8a4a270 100644 --- a/cmake/Modules/HandleLibCXXABI.cmake +++ b/cmake/Modules/HandleLibCXXABI.cmake @@ -1,9 +1,8 @@ + #=============================================================================== # Add an ABI library if appropriate #=============================================================================== -include(GNUInstallDirs) - # # _setup_abi: Set up the build to use an ABI library # @@ -64,7 +63,7 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) if (LIBCXX_INSTALL_HEADERS) install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}" + DESTINATION include/c++/v1/${dstdir} COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) @@ -118,10 +117,6 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") setup_abi_lib( "-DLIBCXX_BUILDING_LIBCXXABI" "${shared}" "${static}" "cxxabi.h;__cxxabi_config.h" "") -elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "system-libcxxabi") - setup_abi_lib( - "-DLIBCXX_BUILDING_LIBCXXABI" - "c++abi" "c++abi" "cxxabi.h;__cxxabi_config.h" "") elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS) set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1") diff --git a/cmake/Modules/HandleOutOfTreeLLVM.cmake b/cmake/Modules/HandleOutOfTreeLLVM.cmake new file mode 100644 index 000000000..ad2820b32 --- /dev/null +++ b/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -0,0 +1,78 @@ +if (NOT DEFINED LLVM_PATH) + set(LLVM_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../llvm CACHE PATH "" FORCE) +endif() + +if(NOT IS_DIRECTORY ${LLVM_PATH}) + message(FATAL_ERROR + "The provided LLVM_PATH (${LLVM_PATH}) is not a valid directory. Note that " + "building libc++ outside of the monorepo is not supported anymore. Please " + "use a Standalone build against the monorepo, a Runtimes build or a classic " + "monorepo build.") +endif() + +set(LLVM_INCLUDE_DIR ${LLVM_PATH}/include CACHE PATH "Path to llvm/include") +set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree") +set(LLVM_MAIN_SRC_DIR ${LLVM_PATH}) +set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") + +if (EXISTS "${LLVM_CMAKE_PATH}") + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") +elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules") + list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") +else() + message(FATAL_ERROR "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found. " + "This is not a supported configuration.") +endif() + +message(STATUS "Configuring for standalone build.") + +# By default, we target the host, but this can be overridden at CMake invocation time. +include(GetHostTriple) +get_host_triple(LLVM_INFERRED_HOST_TRIPLE) +set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING "Host on which LLVM binaries will run") +set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING "Target triple used by default.") + +# Add LLVM Functions -------------------------------------------------------- +if (WIN32) + set(LLVM_ON_UNIX 0) + set(LLVM_ON_WIN32 1) +else() + set(LLVM_ON_UNIX 1) + set(LLVM_ON_WIN32 0) +endif() + +include(AddLLVM OPTIONAL) + +# LLVM Options -------------------------------------------------------------- +if (NOT DEFINED LLVM_INCLUDE_TESTS) + set(LLVM_INCLUDE_TESTS ON) +endif() +if (NOT DEFINED LLVM_INCLUDE_DOCS) + set(LLVM_INCLUDE_DOCS ON) +endif() +if (NOT DEFINED LLVM_ENABLE_SPHINX) + set(LLVM_ENABLE_SPHINX OFF) +endif() + +if (LLVM_INCLUDE_TESTS) + # Required LIT Configuration ------------------------------------------------ + # Define the default arguments to use with 'lit', and an option for the user + # to override. + set(LLVM_DEFAULT_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py") + set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported") + if (MSVC OR XCODE) + set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") + endif() + set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") +endif() + +# Required doc configuration +if (LLVM_ENABLE_SPHINX) + find_package(Sphinx REQUIRED) +endif() + +if (LLVM_ON_UNIX AND NOT APPLE) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) +else() + set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) +endif() diff --git a/cmake/caches/AIX.cmake b/cmake/caches/AIX.cmake deleted file mode 100644 index 029b8deae..000000000 --- a/cmake/caches/AIX.cmake +++ /dev/null @@ -1,16 +0,0 @@ -set(CMAKE_BUILD_TYPE Release CACHE STRING "") -set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "") -set(CMAKE_C_FLAGS "-D__LIBC_NO_CPP_MATH_OVERLOADS__" CACHE STRING "") -set(CMAKE_CXX_FLAGS "-D__LIBC_NO_CPP_MATH_OVERLOADS__" CACHE STRING "") -set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-G -Wl,-bcdtors:all:-2147483548:s" CACHE STRING "") - -set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") -set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "") -set(LIBCXX_ABI_VERSION "1" CACHE STRING "") -set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "") -set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") -set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "") -set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") -set(LIBCXXABI_ENABLE_SHARED ON CACHE BOOL "") -set(LIBCXXABI_ENABLE_STATIC OFF CACHE BOOL "") -set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") diff --git a/cmake/caches/Apple.cmake b/cmake/caches/Apple.cmake index 6f4030ec0..c884eb561 100644 --- a/cmake/caches/Apple.cmake +++ b/cmake/caches/Apple.cmake @@ -18,6 +18,3 @@ set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "") set(LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") set(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST ON CACHE BOOL "") - -set(LIBCXX_TEST_PARAMS "stdlib=apple-libc++" CACHE STRING "") -set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/cmake/caches/Armv7Arm.cmake b/cmake/caches/Armv7Arm.cmake index 0e9dc10e9..8b2b54eba 100644 --- a/cmake/caches/Armv7Arm.cmake +++ b/cmake/caches/Armv7Arm.cmake @@ -1,4 +1,4 @@ set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") -set(LIBCXX_TARGET_TRIPLE "armv7l-linux-gnueabihf" CACHE STRING "") +set(LIBCXX_TARGET_TRIPLE "armv7-linux-gnueabihf" CACHE STRING "") set(CMAKE_CXX_FLAGS "-marm" CACHE STRING "") set(CMAKE_C_FLAGS "-marm" CACHE STRING "") diff --git a/cmake/caches/Armv7Thumb-noexceptions.cmake b/cmake/caches/Armv7Thumb-noexceptions.cmake index 61cd3bf73..67ec43b93 100644 --- a/cmake/caches/Armv7Thumb-noexceptions.cmake +++ b/cmake/caches/Armv7Thumb-noexceptions.cmake @@ -1,5 +1,5 @@ set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") -set(LIBCXX_TARGET_TRIPLE "armv7l-linux-gnueabihf" CACHE STRING "") +set(LIBCXX_TARGET_TRIPLE "armv7-linux-gnueabihf" CACHE STRING "") set(CMAKE_CXX_FLAGS "-mthumb" CACHE STRING "") set(CMAKE_C_FLAGS "-mthumb" CACHE STRING "") set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") diff --git a/cmake/caches/Armv8Arm.cmake b/cmake/caches/Armv8Arm.cmake index eee2eb46d..55dfa908b 100644 --- a/cmake/caches/Armv8Arm.cmake +++ b/cmake/caches/Armv8Arm.cmake @@ -1,4 +1,4 @@ set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") -set(LIBCXX_TARGET_TRIPLE "armv8l-linux-gnueabihf" CACHE STRING "") +set(LIBCXX_TARGET_TRIPLE "armv8-linux-gnueabihf" CACHE STRING "") set(CMAKE_CXX_FLAGS "-marm" CACHE STRING "") set(CMAKE_C_FLAGS "-marm" CACHE STRING "") diff --git a/cmake/caches/Armv8Thumb-noexceptions.cmake b/cmake/caches/Armv8Thumb-noexceptions.cmake index 9c2f90661..fb1d10efa 100644 --- a/cmake/caches/Armv8Thumb-noexceptions.cmake +++ b/cmake/caches/Armv8Thumb-noexceptions.cmake @@ -1,5 +1,5 @@ set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") -set(LIBCXX_TARGET_TRIPLE "armv8l-linux-gnueabihf" CACHE STRING "") +set(LIBCXX_TARGET_TRIPLE "armv8-linux-gnueabihf" CACHE STRING "") set(CMAKE_CXX_FLAGS "-mthumb" CACHE STRING "") set(CMAKE_C_FLAGS "-mthumb" CACHE STRING "") set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") diff --git a/cmake/caches/Generic-32bits.cmake b/cmake/caches/Generic-32bits.cmake new file mode 100644 index 000000000..ae7b2ac3e --- /dev/null +++ b/cmake/caches/Generic-32bits.cmake @@ -0,0 +1 @@ +set(LLVM_BUILD_32_BITS ON CACHE BOOL "") diff --git a/cmake/caches/Generic-asan.cmake b/cmake/caches/Generic-asan.cmake index a86b34748..cf919765c 100644 --- a/cmake/caches/Generic-asan.cmake +++ b/cmake/caches/Generic-asan.cmake @@ -1,3 +1 @@ set(LLVM_USE_SANITIZER "Address" CACHE STRING "") -# This is a temporary (hopefully) workaround for an ASan issue (see https://llvm.org/D119410). -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm -asan-use-private-alias=1" CACHE INTERNAL "") diff --git a/cmake/caches/Generic-debug-iterators.cmake b/cmake/caches/Generic-debug-iterators.cmake index a43f27c02..2e9cbf77a 100644 --- a/cmake/caches/Generic-debug-iterators.cmake +++ b/cmake/caches/Generic-debug-iterators.cmake @@ -1,2 +1,2 @@ -set(LIBCXX_TEST_PARAMS "debug_level=1" CACHE STRING "") +set(LIBCXX_TEST_PARAMS "debug_level=1" "additional_features=LIBCXX-DEBUG-FIXME" CACHE STRING "") set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/cmake/caches/Generic-no-experimental.cmake b/cmake/caches/Generic-no-experimental.cmake deleted file mode 100644 index 0f055f4a9..000000000 --- a/cmake/caches/Generic-no-experimental.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") -set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "") diff --git a/cmake/caches/Generic-no-unicode.cmake b/cmake/caches/Generic-no-unicode.cmake deleted file mode 100644 index 01160bf21..000000000 --- a/cmake/caches/Generic-no-unicode.cmake +++ /dev/null @@ -1 +0,0 @@ -set(LIBCXX_ENABLE_UNICODE OFF CACHE BOOL "") diff --git a/cmake/caches/Generic-no-wide-characters.cmake b/cmake/caches/Generic-no-wide-characters.cmake deleted file mode 100644 index 728d41086..000000000 --- a/cmake/caches/Generic-no-wide-characters.cmake +++ /dev/null @@ -1 +0,0 @@ -set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "") diff --git a/cmake/caches/MinGW.cmake b/cmake/caches/MinGW.cmake deleted file mode 100644 index b9ac28006..000000000 --- a/cmake/caches/MinGW.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") -set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "") - -set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") -set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") - -set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") -set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") - -set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") -set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") -set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "") - -set(LIBCXX_TARGET_INFO "libcxx.test.target_info.MingwLocalTI" CACHE STRING "") - -# Without this flag, 'long double' (which is 80 bit on x86 mingw, but -# 64 bit in MSVC) isn't handled correctly in printf. -set(LIBCXX_EXTRA_SITE_DEFINES "__USE_MINGW_ANSI_STDIO=1" CACHE STRING "") diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 868bb89d8..a2f1ff9f1 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -1,22 +1,9 @@ include(CMakePushCheckState) include(CheckLibraryExists) -include(LLVMCheckCompilerLinkerFlag) include(CheckCCompilerFlag) include(CheckCXXCompilerFlag) include(CheckCSourceCompiles) -# The compiler driver may be implicitly trying to link against libunwind. -# This is normally ok (libcxx relies on an unwinder), but if libunwind is -# built in the same cmake invocation as libcxx and we've got -# LIBCXXABI_USE_LLVM_UNWINDER set, we'd be linking against the just-built -# libunwind (and the compiler implicit -lunwind wouldn't succeed as the newly -# built libunwind isn't installed yet). For those cases, it'd be good to -# link with --uwnindlib=none. Check if that option works. -llvm_check_compiler_linker_flag(C "--unwindlib=none" LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG) -if (LIBCXX_SUPPORTS_UNWINDLIB_NONE_FLAG) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --unwindlib=none") -endif() - if(WIN32 AND NOT MINGW) # NOTE(compnerd) this is technically a lie, there is msvcrt, but for now, lets # let the default linking take care of that. @@ -61,9 +48,8 @@ if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () if (LIBCXX_USE_COMPILER_RT) - include(HandleCompilerRT) - find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY - FLAGS ${LIBCXX_COMPILE_FLAGS}) + list(APPEND CMAKE_REQUIRED_FLAGS -rtlib=compiler-rt) + find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBCXX_BUILTINS_LIBRARY}") elseif (LIBCXX_HAS_GCC_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES gcc) @@ -87,7 +73,7 @@ if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all") endif () if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize-coverage=0") + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters") endif () endif () diff --git a/docs/AddingNewCIJobs.rst b/docs/AddingNewCIJobs.rst index 613929ae1..bd94a9d70 100644 --- a/docs/AddingNewCIJobs.rst +++ b/docs/AddingNewCIJobs.rst @@ -34,7 +34,9 @@ An example of a job definition is: queue: "libcxx-builders" os: "linux" retry: - [...] + automatic: + - exit_status: -1 # Agent was lost + limit: 2 If you create your own agents, put them in the ``libcxx-builders`` queue and use agent tags to allow targetting your agents from the Buildkite pipeline diff --git a/docs/BuildingLibcxx.rst b/docs/BuildingLibcxx.rst index 544d06cc8..a29a05b8f 100644 --- a/docs/BuildingLibcxx.rst +++ b/docs/BuildingLibcxx.rst @@ -25,58 +25,50 @@ libc++ :ref:`here `. The default build ================= -The default way of building libc++, libc++abi and libunwind is to root the CMake -invocation at ``/runtimes``. While those projects are under the LLVM -umbrella, they are different in nature from other build tools, so it makes sense -to treat them as a separate set of entities. The default build can be achieved -with the following CMake invocation: +By default, libc++ and libc++abi are built as sub-projects of the LLVM project. +This can be achieved with the usual CMake invocation: .. code-block:: bash $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build - $ cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" # Configure - $ ninja -C build cxx cxxabi unwind # Build - $ ninja -C build check-cxx check-cxxabi check-unwind # Test - $ ninja -C build install-cxx install-cxxabi install-unwind # Install + $ cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" # Configure + $ ninja -C build cxx cxxabi # Build + $ ninja -C build check-cxx check-cxxabi # Test + $ ninja -C build install-cxx install-cxxabi # Install .. note:: See :ref:`CMake Options` below for more configuration options. -After building the various ``install-XXX`` targets, shared libraries for libc++, libc++abi and -libunwind should now be present in ``/lib``, and headers in -``/include/c++/v1``. See :ref:`using an alternate libc++ installation -` for information on how to use this libc++ over the default one. +After building the ``install-cxx`` and ``install-cxxabi`` targets, shared libraries +for libc++ and libc++abi should now be present in ``/lib``, and +headers in ``/include/c++/v1``. See :ref:`using an alternate +libc++ installation ` for information on how to use this libc++ over +the default one. -In the default configuration, the runtimes will be built using the compiler available by default -on your system. Of course, you can change what compiler is being used with the usual CMake -variables. If you wish to build the runtimes from a just-built Clang, the bootstrapping build -explained below makes this task easy. +In the default configuration, libc++ and libc++abi will be built using the compiler available +by default on your system. It is also possible to bootstrap Clang and build libc++ with it. Bootstrapping build =================== -It is possible to build Clang and then build the runtimes using that just-built compiler in a -single CMake invocation. This is usually the correct way to build the runtimes when putting together -a toolchain, or when the system compiler is not adequate to build them (too old, unsupported, etc.). -To do this, use the following CMake invocation, and in particular notice how we're now rooting the -CMake invocation at ``/llvm``: +It is also possible to build Clang and then build libc++ and libc++abi using that +just-built compiler. This is the correct way to build libc++ when putting together +a toolchain, or when the system compiler is not adequate to build libc++ (too old, +unsupported, etc.). This type of build is also commonly called a "Runtimes build": .. code-block:: bash $ mkdir build - $ cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS="clang" \ # Configure - -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \ + $ cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS="clang" \ # Configure + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ -DLLVM_RUNTIME_TARGETS="" - $ ninja -C build runtimes # Build - $ ninja -C build check-runtimes # Test - $ ninja -C build install-runtimes # Install + $ ninja -C build runtimes # Build + $ ninja -C build check-runtimes # Test + $ ninja -C build install-runtimes # Install -.. note:: - This type of build is also commonly called a "Runtimes build", but we would like to move - away from that terminology, which is too confusing. Support for Windows =================== @@ -218,6 +210,12 @@ libc++ specific options Build libc++ with assertions enabled. +.. option:: LIBCXX_BUILD_32_BITS:BOOL + + **Default**: ``OFF`` + + Build libc++ as a 32 bit library. Also see `LLVM_BUILD_32_BITS`. + .. option:: LIBCXX_ENABLE_SHARED:BOOL **Default**: ``ON`` @@ -253,15 +251,6 @@ libc++ specific options This option can be used to enable or disable the filesystem components on platforms that may not support them. For example on Windows when using MSVC. -.. option:: LIBCXX_ENABLE_WIDE_CHARACTERS:BOOL - - **Default**: ``ON`` - - This option can be used to disable support for ``wchar_t`` in the library. It also - allows the library to work on top of a C Standard Library that does not provide - support for ``wchar_t``. This is especially useful in embedded settings where - C Standard Libraries don't always provide all the usual bells and whistles. - .. option:: LIBCXX_ENABLE_INCOMPLETE_FEATURES:BOOL **Default**: ``ON`` @@ -318,7 +307,7 @@ ABI Library Specific Options .. option:: LIBCXX_CXX_ABI:STRING - **Values**: ``none``, ``libcxxabi``, ``system-libcxxabi``, ``libcxxrt``, ``libstdc++``, ``libsupc++``. + **Values**: ``none``, ``libcxxabi``, ``libcxxrt``, ``libstdc++``, ``libsupc++``. Select the ABI library to build libc++ against. @@ -523,8 +512,8 @@ We can now run CMake: .. code-block:: bash - $ cmake -G Ninja -S runtimes -B build \ - -DLLVM_ENABLE_RUNTIMES="libcxx" \ + $ cmake -G Ninja -S llvm -B build \ + -DLLVM_ENABLE_PROJECTS="libcxx" \ -DLIBCXX_CXX_ABI=libstdc++ \ -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" $ ninja -C build install-cxx @@ -549,8 +538,8 @@ We can now run CMake like: .. code-block:: bash - $ cmake -G Ninja -S runtimes -B build \ - -DLLVM_ENABLE_RUNTIMES="libcxx" \ + $ cmake -G Ninja -S llvm -B build \ + -DLLVM_ENABLE_PROJECTS="libcxx" \ -DLIBCXX_CXX_ABI=libcxxrt \ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src $ ninja -C build install-cxx diff --git a/docs/Contributing.rst b/docs/Contributing.rst index 3f9ea9c3a..9d52445c3 100644 --- a/docs/Contributing.rst +++ b/docs/Contributing.rst @@ -12,9 +12,6 @@ For libc++, please make sure you follow `these instructions `__. - Looking for pre-existing reviews ================================ @@ -45,22 +42,6 @@ sure you don't forget anything: - Did you add the relevant feature test macro(s) for your feature? Did you update the ``generate_feature_test_macro_components.py`` script with it? - Did you run the ``libcxx-generate-files`` target and verify its output? -The review process -================== - -After uploading your patch, you should see that the "libc++" review group is automatically -added as a reviewer for your patch. Once the group is marked as having approved your patch, -you can commit it. However, if you get an approval very quickly for a significant patch, -please try to wait a couple of business days before committing to give the opportunity for -other reviewers to chime in. If you need someone else to commit the patch for you, please -mention it and provide your ``Name `` for us to attribute the commit properly. - -Note that the rule for accepting as the "libc++" review group is to wait for two members -of the group to have approved the patch, excluding the patch author. This is not a hard -rule -- for very simple patches, use your judgement. The `"libc++" review group `__ -consists of frequent libc++ contributors with a good understanding of the project's -guidelines -- if you would like to be added to it, please reach out on Discord. - Post-release check list ======================= @@ -85,97 +66,3 @@ abilist for the platform, e.g.: * C++20 for the Linux platform. * MacOS C++20 for the Apple platform. - -Working on large features -========================= - -Libc++ makes no guarantees about the implementation status or the ABI stability -of features that have not yet been ratified in the C++ Standard. After the C++ -Standard is ratified libc++ promises a conforming and ABI-stable -implementation. When working on a large new feature in the ratified version of -the C++ Standard that can't be finished before the next release branch is -created, we can't honor this promise. Another reason for not being able to -promise ABI stability happens when the C++ Standard committee retroactively -accepts ABI breaking papers as defect reports against the ratified C++ -Standard. - -When working on these features it should be possible for libc++ vendors to -disable these incomplete features, so they can promise ABI stability to their -customers. This is done by the CMake option -``LIBCXX_ENABLE_INCOMPLETE_FEATURES``. When start working on a large feature -the following steps are required to guard the new library with the CMake -option. - -* ``libcxx/CMakeLists.txt``: Add - - .. code-block:: cmake - - config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FOO) - -* ``libcxx/include/__config_site.in``: Add - - .. code-block:: c++ - - #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FOO - -* ``libcxx/include/foo``: The contents of the file should be guarded in an - ``ifdef`` and always include ```` - - .. code-block:: c++ - - #ifndef _LIBCPP_FOO - #define _LIBCPP_FOO - - // Make sure all feature-test macros are available. - #include - // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. - #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FOO) - - ... - - #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FO0) - #endif // _LIBCPP_FOO - -* ``libcxx/src/CMakeLists.txt``: When the library has a file ``foo.cpp`` it - should only be added when ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` is enabled - - .. code-block:: cmake - - if(LIBCXX_ENABLE_INCOMPLETE_FEATURES) - list(APPEND LIBCXX_SOURCES - foo.cpp - ) - endif() - -* ``libcxx/utils/generate_feature_test_macro_components.py``: Add to - ``lit_markup`` - - .. code-block:: python - - "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"], - -* ``libcxx/utils/generate_header_inclusion_tests.py``: Add to ``lit_markup`` - - .. code-block:: python - - "foo": ["UNSUPPORTED: libcpp-has-no-incomplete-foo"], - -* ``libcxx/utils/generate_header_tests.py``: Add to ``header_markup`` - - .. code-block:: python - - "foo": ["ifndef _LIBCPP_HAS_NO_INCOMPLETE_FOO"], - -* ``libcxx/utils/libcxx/test/features.py``: Add to ``macros`` - - .. code-block:: python - - '_LIBCPP_HAS_NO_INCOMPLETE_FOO': 'libcpp-has-no-incomplete-foo', - -* All tests that include ```` should contain - - .. code-block:: c++ - - // UNSUPPORTED: libcpp-has-no-incomplete-foo - -Once the library is complete these changes and guards should be removed. diff --git a/docs/DesignDocs/CapturingConfigInfo.rst b/docs/DesignDocs/CapturingConfigInfo.rst index 3ab078e07..8f2d0cd2d 100644 --- a/docs/DesignDocs/CapturingConfigInfo.rst +++ b/docs/DesignDocs/CapturingConfigInfo.rst @@ -65,12 +65,16 @@ configuration all together. An example "__config" header generated when #ifndef _LIBCPP_CONFIG_SITE #define _LIBCPP_CONFIG_SITE + /* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */ + /* #undef _LIBCPP_HAS_NO_STDIN */ + /* #undef _LIBCPP_HAS_NO_STDOUT */ #define _LIBCPP_HAS_NO_THREADS /* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */ + /* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */ #endif // -*- C++ -*- - //===----------------------------------------------------------------------===// + //===--------------------------- __config ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/docs/DesignDocs/DebugMode.rst b/docs/DesignDocs/DebugMode.rst index faf7b8e1b..abcd5e5c8 100644 --- a/docs/DesignDocs/DebugMode.rst +++ b/docs/DesignDocs/DebugMode.rst @@ -58,15 +58,6 @@ The following containers and classes support iterator debugging: The remaining containers do not currently support iterator debugging. Patches welcome. -Randomizing Unspecified Behavior (``_LIBCPP_DEBUG == 1``) ---------------------------------------------------------- -This also enables the randomization of unspecified behavior, for -example, for equal elements in ``std::sort`` or randomizing both parts of -the partition after ``std::nth_element`` call. This effort helps you to migrate -to potential future faster versions of these algorithms and deflake your tests -which depend on such behavior. To fix the seed, use -``_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED=seed`` definition. - Handling Assertion Failures =========================== When a debug assertion fails the assertion handler is called via the diff --git a/docs/DesignDocs/UniquePtrTrivialAbi.rst b/docs/DesignDocs/UniquePtrTrivialAbi.rst index 1af0b3426..a0f260a44 100644 --- a/docs/DesignDocs/UniquePtrTrivialAbi.rst +++ b/docs/DesignDocs/UniquePtrTrivialAbi.rst @@ -36,7 +36,7 @@ Design ====== * Annotate the two definitions of ``std::unique_ptr`` with ``clang::trivial_abi`` attribute. -* Put the attribute behind a flag because this change has potential compilation and runtime breakages. +* Put the attribuate behind a flag because this change has potential compilation and runtime breakages. This comes with some side effects: diff --git a/docs/DesignDocs/UnspecifiedBehaviorRandomization.rst b/docs/DesignDocs/UnspecifiedBehaviorRandomization.rst deleted file mode 100644 index 783950b3b..000000000 --- a/docs/DesignDocs/UnspecifiedBehaviorRandomization.rst +++ /dev/null @@ -1,86 +0,0 @@ -================================== -Unspecified Behavior Randomization -================================== - -Background -========== - -Consider the follow snippet which steadily happens in tests: - - -.. code-block:: cpp - - std::vector> v(SomeData()); - std::sort(v.begin(), v.end(), [](const auto& lhs, const auto& rhs) { - return lhs.first < rhs.first; - }); - -Under this assumption all elements in the vector whose first elements are equal -do not guarantee any order. Unfortunately, this prevents libcxx introducing -other implementatiosn because tests might silently fail and the users might -heavily depend on the stability of implementations. - -Goal -=================== - -Provide functionality for randomizing the unspecified behavior so that the users -can test and migrate their components and libcxx can introduce new sorting -algorithms and optimizations to the containers. - -For example, as of LLVM version 13, libcxx sorting algorithm takes -`O(n^2) worst case `_ but according -to the standard its worst case should be `O(n log n)`. This effort helps users -to gradually fix their tests while updating to new faster algorithms. - -Design -====== - -* Introduce new macro `_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY` which should - be a part of the libcxx config. -* This macro randomizes the unspecified behavior of algorithms and containers. - For example, for sorting algorithm the input range is shuffled and then - sorted. -* This macro is off by default because users should enable it only for testing - purposes and/or migrations if they happen to libcxx. -* This feature is only available for C++11 and further because of - `std::shuffle` availability. -* We may use `ASLR `_ or - static `std::random_device` for seeding the random number generator. This - guarantees the same stability guarantee within a run but not through different - runs, for example, for tests become flaky and eventually be seen as broken. - For platforms which do not support ASLR, the seed is fixed during build. -* The users can fix the seed of the random number generator by providing - `_LIBCPP_RANDOMIZE_UNSPECIFIED_STABILITY_SEED=seed` definition. - -This comes with some side effects if any of the flags is on: - -* Computation penalty, we think users are OK with that if they use this feature. -* Non reproducible results if they don't use the fixed seed. - - -Impact ------------------- - -Google has measured couple of thousands of tests to be dependent on the -stability of sorting and selection algorithms. As we also plan on updating -(or least, providing under flag more) sorting algorithms, this effort helps -doing it gradually and sustainably. This is also bad for users to depend on the -unspecified behavior in their tests, this effort helps to turn this flag in -debug mode. - -Potential breakages -------------------- - -None if the flag is off. If the flag is on, it may lead to some non-reproducible -results, for example, for caching. - -Currently supported randomization ---------------------------------- - -* `std::sort`, there is no guarantee on the order of equal elements -* `std::partial_sort`, there is no guarantee on the order of equal elements and - on the order of the remaining part -* `std::nth_element`, there is no guarantee on the order from both sides of the - partition - -Patches welcome. diff --git a/docs/FeatureTestMacroTable.rst b/docs/FeatureTestMacroTable.rst index 3cfcaa662..c2690e72e 100644 --- a/docs/FeatureTestMacroTable.rst +++ b/docs/FeatureTestMacroTable.rst @@ -18,8 +18,8 @@ Status ====== .. table:: Current Status - :name: feature-status-table - :widths: auto + :name: feature-status-table + :widths: auto ================================================= ================= Macro Name Value @@ -190,7 +190,7 @@ Status ------------------------------------------------- ----------------- ``__cpp_lib_bind_front`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_bit_cast`` ``201806L`` + ``__cpp_lib_bit_cast`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_bitops`` *unimplemented* ------------------------------------------------- ----------------- @@ -224,7 +224,7 @@ Status ------------------------------------------------- ----------------- ``__cpp_lib_constexpr_vector`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_coroutine`` ``201902L`` + ``__cpp_lib_coroutine`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_destroying_delete`` ``201806L`` ------------------------------------------------- ----------------- @@ -290,46 +290,18 @@ Status ------------------------------------------------- ----------------- ``__cpp_lib_to_array`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_type_identity`` ``201806L`` - ------------------------------------------------- ----------------- ``__cpp_lib_unwrap_ref`` ``201811L`` ------------------------------------------------- ----------------- **C++ 2b** ------------------------------------------------------------------- - ``__cpp_lib_adaptor_iterator_pair_constructor`` ``202106L`` - ------------------------------------------------- ----------------- - ``__cpp_lib_allocate_at_least`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_associative_heterogeneous_erasure`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_byteswap`` ``202110L`` - ------------------------------------------------- ----------------- - ``__cpp_lib_constexpr_typeinfo`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_invoke_r`` *unimplemented* - ------------------------------------------------- ----------------- ``__cpp_lib_is_scoped_enum`` ``202011L`` ------------------------------------------------- ----------------- - ``__cpp_lib_monadic_optional`` ``202110L`` - ------------------------------------------------- ----------------- - ``__cpp_lib_move_only_function`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_out_ptr`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_ranges_starts_ends_with`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_ranges_zip`` *unimplemented* - ------------------------------------------------- ----------------- - ``__cpp_lib_spanstream`` *unimplemented* - ------------------------------------------------- ----------------- ``__cpp_lib_stacktrace`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_stdatomic_h`` *unimplemented* ------------------------------------------------- ----------------- ``__cpp_lib_string_contains`` ``202011L`` ------------------------------------------------- ----------------- - ``__cpp_lib_string_resize_and_overwrite`` ``202110L`` - ------------------------------------------------- ----------------- ``__cpp_lib_to_underlying`` ``202102L`` ================================================= ================= diff --git a/docs/Helpers/Styles.rst b/docs/Helpers/Styles.rst index 6291d4df7..9bba3bf69 100644 --- a/docs/Helpers/Styles.rst +++ b/docs/Helpers/Styles.rst @@ -1,51 +1,31 @@ -.. raw:: html - - - -.. role:: notstarted -.. role:: nothingtodo -.. role:: inprogress -.. role:: inreview -.. role:: partial -.. role:: complete - -.. |Not Started| replace:: :notstarted:`Not Started` -.. |Nothing To Do| replace:: :nothingtodo:`Nothing To Do` -.. |In Progress| replace:: :inprogress:`In Progress` -.. |Review| replace:: :inreview:`Review` -.. |Partial| replace:: :partial:`Partial` -.. |Complete| replace:: :complete:`Complete` - -.. role:: chrono -.. role:: format -.. role:: ranges -.. role:: spaceship - -.. |chrono| replace:: :chrono:`chrono` -.. |format| replace:: :format:`format` -.. |ranges| replace:: :ranges:`ranges` -.. |spaceship| replace:: :spaceship:`spaceship` - -.. |sect| unicode:: U+00A7 -.. |hellip| unicode:: U+2026 +.. raw:: html + + + +.. role:: nothingtodo +.. role:: inprogress +.. role:: partial +.. role:: complete + + +.. |Nothing To Do| replace:: :nothingtodo:`Nothing To Do` +.. |In Progress| replace:: :inprogress:`In Progress` +.. |Partial| replace:: :partial:`Partial` +.. |Complete| replace:: :complete:`Complete` + +.. |sect| unicode:: U+00A7 +.. |hellip| unicode:: U+2026 diff --git a/docs/Makefile.sphinx b/docs/Makefile.sphinx new file mode 100644 index 000000000..a34f0cc0b --- /dev/null +++ b/docs/Makefile.sphinx @@ -0,0 +1,37 @@ +# Makefile for Sphinx documentation +# +# FIXME: This hack is only in place to allow the libcxx.llvm.org/docs builder +# to work with libcxx. This should be removed when that builder supports +# out-of-tree builds. + +# You can set these variables from the command line. +SPHINXOPTS = -n -W -v +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext default + +default: html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @# FIXME: Remove this `cp` once HTML->Sphinx transition is completed. + @# Kind of a hack, but HTML-formatted docs are on the way out anyway. + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 20303382d..6763ddb36 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -1,5 +1,5 @@ ========================================= -Libc++ 14.0.0 (In-Progress) Release Notes +Libc++ 13.0.0 Release Notes ========================================= .. contents:: @@ -8,17 +8,11 @@ Libc++ 14.0.0 (In-Progress) Release Notes Written by the `Libc++ Team `_ -.. warning:: - - These are in-progress notes for the upcoming libc++ 14 release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ This document contains the release notes for the libc++ C++ Standard Library, -part of the LLVM Compiler Infrastructure, release 14.0.0. Here we describe the +part of the LLVM Compiler Infrastructure, release 13.0.0. Here we describe the status of libc++ in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see `the LLVM documentation `_. All LLVM releases may @@ -32,214 +26,79 @@ main Libc++ web page, this document applies to the *next* release, not the current one. To see the release notes for a specific release, please see the `releases page `_. -What's New in Libc++ 14.0.0? +What's New in Libc++ 13.0.0? ============================ +- Support for older compilers has been removed. Several additional platforms + are now officially supported. :ref:`platform_and_compiler_support` contains + the complete overview of platforms and compilers supported by libc++. +- The large headers ````, ````, and ```` have + been split in more granular headers. This reduces the size of included code + when using libc++. This may lead to missing includes after upgrading to + libc++13. + New Features ------------ -- There's support for the C++20 header ````. Some parts are still - missing, most notably the compile-time format string validation. Some - functions are known to be inefficient, both in memory usage and performance. - The implementation isn't API- or ABI-stable and therefore considered - experimental. (Some not-yet-implemented papers require an API-break.) - As a result, it is disabled by default, however vendors can enable the - header by using ``-DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON`` when - configuring their build. +- ``std::filesystem`` is now feature complete for the Windows platform using + MinGW. MSVC isn't supported since it lacks 128-bit integer support. +- The implementation of the C++20 concepts library has been completed. +- Several C++20 ``constexpr`` papers have been completed: -- More parts of ```` have been implemented. Since we still expect to make - some API and ABI breaking changes, those are disabled by default. However, - vendors that wish to enable ```` in their distribution may do so - by defining ``-DLIBCXX_ENABLE_INCOMPLETE_FEATURES=ON`` when configuring - their build. - -- There's a new CMake option ``LIBCXX_ENABLE_UNICODE`` to disable Unicode - support in the ```` header. This only affects the estimation of the - output width of the format functions. - -- Support for building libc++ on top of a C Standard Library that does not support ``wchar_t`` was - added. This is useful for building libc++ in an embedded setting, and it adds itself to the various - freestanding-friendly options provided by libc++. - -- Defining ``_LIBCPP_DEBUG`` to ``1`` enables the randomization of unspecified - behavior in standard algorithms (e.g. the ordering of equal elements in ``std::sort``, or - the ordering of both sides of the partition in ``std::nth_element``). - -- Floating-point support for ``std::to_chars`` support has been added. - Thanks to Stephan T. Lavavej and Microsoft for providing their implementation - to libc++. - -- The C++20 ```` implementation has been completed. + - `P0879R0 `_ ``constexpr`` for ``std::swap()`` + and swap related functions + - `P1032R1 `_ Misc ``constexpr`` bits + - `P0883 `_ Fixing Atomic Initialization - More C++20 features have been implemented. :doc:`Status/Cxx20` has the full overview of libc++'s C++20 implementation status. +- More C++2b features have been implemented. :doc:`Status/Cxx2b` has the + full overview of libc++'s C++2b implementation status. +- The CMake option ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` has been added. This + option allows libc++ vendors to disable headers that aren't production + quality yet. Currently, turning the option off disables the headers + ```` and ````. +- The documentation conversion from html to restructured text has been + completed. -- More C++2b features have been implemented. :doc:`Status/Cxx2b` has the full - overview of libc++'s C++2b implementation status. +API and ABI Changes +------------------- -- 16-bit ``wchar_t`` handling added for ``codecvt_utf8``, ``codecvt_utf16`` and - ``codecvt_utf8_utf16``. +- There has been several changes in the tuple constructors provided by libc++. + Those changes were made as part of an effort to regularize libc++'s tuple + implementation, which contained several subtle bugs due to these extensions. + If you notice a build breakage when initializing a tuple, make sure you + properly initialize all the tuple elements - this is probably the culprit. -API Changes ------------ + In particular, the extension allowing tuples to be constructed from fewer + elements than the number of elements in the tuple (in which case the remaining + elements would be default-constructed) has been removed. See https://godbolt.org/z/sqozjd. -- The functions ``std::atomic::fetch_(add|sub)`` and - ``std::atomic_fetch_(add|sub)`` no longer accept a function pointer. While - this is technically an API break, the invalid syntax isn't supported by - libstdc++ and MSVC STL. See https://godbolt.org/z/49fvzz98d. + Also, the extension allowing a tuple to be constructed from an array has been + removed. See https://godbolt.org/z/5esqbW. -- The call of the functions ``std::atomic_(add|sub)(std::atomic*, ...)`` - with the explicit template argument ``T`` are now ill-formed. While this is - technically an API break, the invalid syntax isn't supported by libstdc++ and - MSVC STL. See https://godbolt.org/z/v9959re3v. +- The ``std::pointer_safety`` utility and related functions are not available + in C++03 anymore. Furthermore, in other standard modes, it has changed from + a struct to a scoped enumeration, which is an ABI break. Finally, the + ``std::get_pointer_safety`` function was previously in the dylib, but it + is now defined as inline in the headers. - Due to this change it's now possible to call these functions with the - explicit template argument ``T*``. This allows using the same syntax on the - major Standard library implementations. - See https://godbolt.org/z/oEfzPhTTb. + While this is technically both an API and an ABI break, we do not expect + ``std::pointer_safety`` to have been used at all in real code, since we + never implemented the underlying support for garbage collection. - Calls to these functions where the template argument was deduced by the - compiler are unaffected by this change. +- The `LIBCXXABI_ENABLE_PIC` CMake option was removed. If you are building your + own libc++abi from source and were using `LIBCXXABI_ENABLE_PIC`, please use + `CMAKE_POSITION_INDEPENDENT_CODE=ON` instead. -- The functions ``std::allocator::allocate`` and - ``std::experimental::pmr::polymorphic_allocator::allocate`` now throw - an exception of type ``std::bad_array_new_length`` when the requested size - exceeds the maximum supported size, as required by the C++ standard. - Previously the type ``std::length_error`` was used. +- When the header is included, it will no longer include transitively. -- Removed the nonstandard methods ``std::chrono::file_clock::to_time_t`` and - ``std::chrono::file_clock::from_time_t``; neither libstdc++ nor MSVC STL - had such methods. Instead, in C++20, you can use ``std::chrono::file_clock::from_sys`` - and ``std::chrono::file_clock::to_sys``, which are specified in the Standard. - If you are not using C++20, you should move to it. +- The ``std::result_of`` and ``std::is_literal_type`` type traits have been removed in + C++20 mode. -- The declarations of functions ``declare_reachable``, ``undeclare_reachable``, ``declare_no_pointers``, - ``undeclare_no_pointers``, and ``get_pointer_safety`` have been removed not only from C++2b but - from all modes. Their symbols are still provided by the dynamic library for the benefit of - existing compiled code. All of these functions have always behaved as no-ops. - -- ``std::filesystem::path::iterator``, which (in our implementation) stashes - a ``path`` value inside itself similar to ``istream_iterator``, now sets its - ``reference`` type to ``path`` and its ``iterator_category`` to ``input_iterator_tag``, - so that it is a conforming input iterator in C++17 and a conforming - ``std::bidirectional_iterator`` in C++20. Before this release, it had set its - ``reference`` type to ``const path&`` and its ``iterator_category`` to - ``bidirectional_iterator_tag``, making it a non-conforming bidirectional iterator. - After this change, ``for`` loops of the form ``for (auto& c : path)`` must be rewritten - as either ``for (auto&& c : path)`` or ``for (const auto& c : path)``. - ``std::reverse_iterator`` is no longer rejected. - -- Removed the nonstandard default constructor from ``std::chrono::month_weekday``. - You must now explicitly initialize with a ``chrono::month`` and - ``chrono::weekday_indexed`` instead of "meh, whenever". - -- C++20 requires that ``std::basic_string::reserve(n)`` never reduce the capacity - of the string. (For that, use ``shrink_to_fit()``.) Prior to this release, libc++'s - ``std::basic_string::reserve(n)`` could reduce capacity in C++17 and before, but - not in C++20 and later. This caused ODR violations when mixing code compiled under - different Standard modes. After this change, libc++'s ``std::basic_string::reserve(n)`` - never reduces capacity, even in C++17 and before. - C++20 deprecates the zero-argument overload of ``std::basic_string::reserve()``, - but specifically permits it to reduce capacity. To avoid breaking existing code - assuming that ``std::basic_string::reserve()`` will shrink, libc++ maintains - the behavior to shrink, even though that makes ``std::basic_string::reserve()`` not - a synonym for ``std::basic_string::reserve(0)`` in any Standard mode anymore. - -- The ```` header is deprecated, as is any - use of coroutines without C++20. Use C++20's ```` header - instead. The ```` header will be removed - in LLVM 16. - -- ``_VSTD`` is now an alias for ``std`` instead of ``std::_LIBCPP_ABI_NAMESPACE``. - This is technically not a functional change, except for folks that might have been - using ``_VSTD`` in creative ways (which has never been officially supported). - -ABI Changes ------------ - -- The C++17 variable templates ``is_error_code_enum_v`` and - ``is_error_condition_enum_v`` are now of type ``bool`` instead of ``size_t``. - -- The C++03 emulation type for ``std::nullptr_t`` has been removed in favor of - using ``decltype(nullptr)`` in all standard modes. This is an ABI break for - anyone compiling in C++03 mode and who has ``std::nullptr_t`` as part of their - ABI. However, previously, these users' ABI would be incompatible with any other - binary or static archive compiled with C++11 or later. If you start seeing linker - errors involving ``std::nullptr_t`` against previously compiled binaries, this may - be the cause. You can define the ``_LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION`` macro - to return to the previous behavior. That macro will be removed in LLVM 15. Please - comment `on D109459 `_ if you are broken by this change - and need to define the macro. - -- On Apple platforms, ``std::random_device`` is now implemented on top of ``arc4random()`` - instead of reading from ``/dev/urandom``. Any implementation-defined token used when - constructing a ``std::random_device`` will now be ignored instead of interpreted as a - file to read entropy from. - -- ``std::lognormal_distribution::param_type`` used to store a data member of type - ``std::normal_distribution``; now this member is stored in the ``lognormal_distribution`` - class itself, and the ``param_type`` stores only the mean and standard deviation, - as required by the Standard. This changes ``sizeof(std::lognormal_distribution::param_type)``. - You can define the ``_LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION`` macro to return to the - previous behavior. That macro will be removed in LLVM 15. Please comment - `on PR52906 `_ if you are broken by this change and need to - define the macro. - -Build System Changes --------------------- - -- Building the libc++ shared or static library requires a C++ 20 capable compiler. - Consider using a Bootstrapping build to build libc++ with a fresh Clang if you - can't use the system compiler to build libc++ anymore. - -- Historically, there have been numerous ways of building libc++, libc++abi, and libunwind. - This has led to at least 5 different ways to build the runtimes, which was impossible to - maintain with a good level of support. Starting with this release, libc++, libc++abi, and - libunwind support exactly two ways of being built, which should cater to all use-cases. - Furthermore, these builds are as lightweight as possible and will work consistently even - when targeting embedded platforms, which used not to be the case. :doc:`BuildingLibcxx` - describes those two ways of building. Please migrate over to the appropriate build - instructions as soon as possible. - - All other ways to build are deprecated and will not be supported in the next release. - We understand that making these changes can be daunting. For that reason, here's a - summary of how to migrate from the two most common ways to build: - - - If you were rooting your CMake invocation at ``/llvm`` and passing ``-DLLVM_ENABLE_PROJECTS=<...>`` - (which was the previously advertised way to build the runtimes), please simply root your CMake invocation at - ``/runtimes`` and pass ``-DLLVM_ENABLE_RUNTIMES=<...>``. - - - If you were doing multiple CMake invocations, e.g. one rooted at ``/libcxx`` and one rooted - at ``/libcxxabi`` (this used to be called a "Standalone build"), please move them to a - single invocation like so: - - .. code-block:: bash - - $ cmake -S /libcxx -B libcxx-build - $ cmake -S /libcxxabi -B libcxxabi-build - - should become - - .. code-block:: bash - - $ cmake -S /runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" - -- Support for building the runtimes using the GCC 32 bit multilib flag (``-m32``) has been removed. Support - for this had been flaky for a while, and we didn't know of anyone depending on this. Instead, please perform - a normal cross-compilation of the runtimes using the appropriate target, such as passing the following to - your bootstrapping build: - - .. code-block:: bash - - -DLLVM_RUNTIME_TARGETS=i386-unknown-linux - -- Libc++, libc++abi, and libunwind will not be built with ``-fPIC`` by default anymore. - If you want to build those runtimes with position-independent code, please specify - ``-DCMAKE_POSITION_INDEPENDENT_CODE=ON`` explicitly when configuring the build, or - ``-DRUNTIMES__CMAKE_POSITION_INDEPENDENT_CODE=ON`` if using the - bootstrapping build. - -- The ``{LIBCXX,LIBCXXABI,LIBUNWIND}_TARGET_TRIPLE``, ``{LIBCXX,LIBCXXABI,LIBUNWIND}_SYSROOT`` and - ``{LIBCXX,LIBCXXABI,LIBUNWIND}_GCC_TOOLCHAIN`` CMake variables are deprecated. Instead, please use - the ``CMAKE_CXX_COMPILER_TARGET``, ``CMAKE_SYSROOT`` and ``CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN`` - variables provided by CMake. +- The C++20 type ``std::counted_semaphore`` is now based on ``std::atomic`` + on all platforms, and does not use "native" semaphores such as pthreads + ``sem_t`` even on platforms that would support them. This changes the layout + of ``counted_semaphore`` notably on Linux, so it is an ABI break on that + platform. This change is needed to conform to the Standard, which requires + ``counted_semaphore``'s constructor to be constexpr. diff --git a/docs/Status/Cxx14.rst b/docs/Status/Cxx14.rst index 0557bdc28..fc3aeeec3 100644 --- a/docs/Status/Cxx14.rst +++ b/docs/Status/Cxx14.rst @@ -1,50 +1,52 @@ -.. _cxx14-status: - -================================ -libc++ C++14 Status -================================ - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - - -Overview -================================ - -In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, initially known as "C++1y". - -The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol). - -In August 2014, this draft was approved by ISO as C++14. - -This page shows the status of libc++; the status of clang's support of the language features is `here `__. - -The groups that have contributed papers: - -- CWG - Core Language Working group -- LWG - Library working group -- SG1 - Study group #1 (Concurrency working group) - - -.. _paper-status-cxx14: - -Paper Status -==================================== - -.. csv-table:: - :file: Cxx14Papers.csv - :header-rows: 1 - :widths: auto - - -.. _issues-status-cxx14: - -Library Working Group Issues Status -==================================== - -.. csv-table:: - :file: Cxx14Issues.csv - :header-rows: 1 - :widths: auto +.. _cxx14-status: + +================================ +libc++ C++14 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, initially known as "C++1y". + +The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol). + +In August 2014, this draft was approved by ISO as C++14. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + + +.. _paper-status-cxx14: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx14Papers.csv + :header-rows: 1 + :widths: auto + + +.. _issues-status-cxx14: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx14Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 25-Mar-2014 diff --git a/docs/Status/Cxx17.rst b/docs/Status/Cxx17.rst index 26bf0ad6b..9076b9cf4 100644 --- a/docs/Status/Cxx17.rst +++ b/docs/Status/Cxx17.rst @@ -1,55 +1,57 @@ -.. _cxx17-status: - -================================ -libc++ C++17 Status -================================ - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - - -Overview -================================ - -In November 2014, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++1z". -In February 2017, the C++ standard committee approved this draft, and sent it to ISO for approval as C++17. - -This page shows the status of libc++; the status of clang's support of the language features is `here `__. - -.. attention:: Features in unreleased drafts of the standard are subject to change. - -The groups that have contributed papers: - -- CWG - Core Language Working group -- LWG - Library working group -- SG1 - Study group #1 (Concurrency working group) - -.. note:: "Nothing to do" means that no library changes were needed to implement this change. - -.. _paper-status-cxx17: - -Paper Status -==================================== - -.. csv-table:: - :file: Cxx17Papers.csv - :header-rows: 1 - :widths: auto - -.. note:: - - .. [#note-P0067] P0067: ``std::(to|from)_chars`` for integrals has been available since version 7.0. ``std::to_chars`` for ``float`` and ``double`` since version 14.0 ``std::to_chars`` for ``long double`` uses the implementation for ``double``. - .. [#note-P0607] P0607: The parts of P0607 that are not done are the ```` bits. - - -.. _issues-status-cxx17: - -Library Working Group Issues Status -==================================== - -.. csv-table:: - :file: Cxx17Issues.csv - :header-rows: 1 - :widths: auto +.. _cxx17-status: + +================================ +libc++ C++17 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In November 2014, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++1z". +In February 2017, the C++ standard committee approved this draft, and sent it to ISO for approval as C++17. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx17: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx17Papers.csv + :header-rows: 1 + :widths: auto + +.. note:: + + .. [#note-P0433] P0433: So far, only the ````, sequence containers, container adaptors and ```` portions of P0433 have been implemented. + .. [#note-P0607] P0607: The parts of P0607 that are not done are the ```` bits. + + +.. _issues-status-cxx17: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx17Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 17-Nov-2020 diff --git a/docs/Status/Cxx17Issues.csv b/docs/Status/Cxx17Issues.csv index 27f0e660d..090e12ffd 100644 --- a/docs/Status/Cxx17Issues.csv +++ b/docs/Status/Cxx17Issues.csv @@ -114,7 +114,7 @@ "`2557 `__","Logical operator traits are broken in the zero-argument case","Jacksonville","|Complete|","" "`2558 `__","[fund.ts.v2] Logical operator traits are broken in the zero-argument case","Jacksonville","|Complete|","" "`2559 `__","Error in LWG 2234's resolution","Jacksonville","|Complete|","" -"`2560 `__","``is_constructible``\ underspecified when applied to a function type","Jacksonville","|Complete|","" +"`2560 `__","``is_constructible``\ underspecified when applied to a function type","Jacksonville","Broken in 3.6; See r261653.","" "`2565 `__","``std::function``\ 's move constructor should guarantee nothrow for ``reference_wrapper``\ s and function pointers","Jacksonville","|Complete|","" "`2566 `__","Requirements on the first template parameter of container adaptors","Jacksonville","|Complete|","" "`2571 `__","|sect|\ [map.modifiers]/2 imposes nonsensical requirement on ``insert(InputIterator, InputIterator)``\ ","Jacksonville","|Complete|","" diff --git a/docs/Status/Cxx17Papers.csv b/docs/Status/Cxx17Papers.csv index 87991643c..a015529fe 100644 --- a/docs/Status/Cxx17Papers.csv +++ b/docs/Status/Cxx17Papers.csv @@ -71,7 +71,7 @@ "`P0394r4 `__","LWG","Hotel Parallelifornia: terminate() for Parallel Algorithms Exception Handling","Oulu","","" "","","","","","" "`P0003R5 `__","LWG","Removing Deprecated Exception Specifications from C++17","Issaquah","|Complete|","5.0" -"`P0067R5 `__","LWG","Elementary string conversions, revision 5","Issaquah","|Partial| [#note-P0067]","" +"`P0067R5 `__","LWG","Elementary string conversions, revision 5","Issaquah","|Partial|","" "`P0403R1 `__","LWG","Literal suffixes for ``basic_string_view``\ ","Issaquah","|Complete|","4.0" "`P0414R2 `__","LWG","Merging shared_ptr changes from Library Fundamentals to C++17","Issaquah","|Complete|","11.0" "`P0418R2 `__","LWG","Fail or succeed: there is no atomic lattice","Issaquah","","" @@ -94,14 +94,14 @@ "`P0298R3 `__","CWG","A byte type definition","Kona","|Complete|","5.0" "`P0317R1 `__","LWG","Directory Entry Caching for Filesystem","Kona","|Complete|","7.0" "`P0430R2 `__","LWG","File system library on non-POSIX-like operating systems","Kona","|Complete|","7.0" -"`P0433R2 `__","LWG","Toward a resolution of US7 and US14: Integrating template deduction for class templates into the standard library","Kona","|Complete|","14.0" +"`P0433R2 `__","LWG","Toward a resolution of US7 and US14: Integrating template deduction for class templates into the standard library","Kona","|In Progress| [#note-P0433]_","7.0" "`P0452R1 `__","LWG","Unifying Parallel Algorithms","Kona","","" "`P0467R2 `__","LWG","Iterator Concerns for Parallel Algorithms","Kona","","" "`P0492R2 `__","LWG","Proposed Resolution of C++17 National Body Comments for Filesystems","Kona","|Complete|","7.0" "`P0518R1 `__","LWG","Allowing copies as arguments to function objects given to parallel algorithms in response to CH11","Kona","","" "`P0523R1 `__","LWG","Wording for CH 10: Complexity of parallel algorithms","Kona","","" "`P0548R1 `__","LWG","common_type and duration","Kona","|Complete|","5.0" -"`P0558R1 `__","LWG","Resolving atomic named base class inconsistencies","Kona","|Complete|","" +"`P0558R1 `__","LWG","Resolving atomic named base class inconsistencies","Kona","","" "`P0574R1 `__","LWG","Algorithm Complexity Constraints and Parallel Overloads","Kona","","" "`P0599R1 `__","LWG","noexcept for hash functions","Kona","|Complete|","5.0" "`P0604R0 `__","LWG","Resolving GB 55, US 84, US 85, US 86","Kona","|Complete|","" diff --git a/docs/Status/Cxx20.rst b/docs/Status/Cxx20.rst index 437440776..69e607cb7 100644 --- a/docs/Status/Cxx20.rst +++ b/docs/Status/Cxx20.rst @@ -1,58 +1,59 @@ -.. _cxx20-status: - -================================ -libc++ C++20 Status -================================ - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - - -Overview -================================ - -In July 2017, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++2a". -In September 2020, the C++ standard committee approved this draft, and sent it to ISO for approval as C++20. - -This page shows the status of libc++; the status of clang's support of the language features is `here `__. - -.. attention:: Features in unreleased drafts of the standard are subject to change. - -The groups that have contributed papers: - -- CWG - Core Language Working group -- LWG - Library working group -- SG1 - Study group #1 (Concurrency working group) - -.. note:: "Nothing to do" means that no library changes were needed to implement this change. - -.. _paper-status-cxx20: - -Paper Status -==================================== - -.. csv-table:: - :file: Cxx20Papers.csv - :header-rows: 1 - :widths: auto - -.. note:: - - .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class] and |sect|\ [mem.poly.allocator.class]. - .. [#note-P0645] P0645: The paper is implemented but still marked as an incomplete feature. Not yet implemented LWG-issues will cause API and ABI breakage. - .. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 `__. - .. [#note-P0619] P0619: Only sections D.8, D.9, D.10 and D.13 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone. - .. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet. - - -.. _issues-status-cxx20: - -Library Working Group Issues Status -==================================== - -.. csv-table:: - :file: Cxx20Issues.csv - :header-rows: 1 - :widths: auto +.. _cxx20-status: + +================================ +libc++ C++20 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In July 2017, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++2a". +In September 2020, the C++ standard committee approved this draft, and sent it to ISO for approval as C++20. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx20: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx20Papers.csv + :header-rows: 1 + :widths: auto + +.. note:: + + .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview]. + .. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 `__. + .. [#note-P0619] P0619: Only sections D.8, D.9, D.10 and D.13 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone. + .. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet. + + +.. _issues-status-cxx20: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx20Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 24-May-2021 diff --git a/docs/Status/Cxx20Issues.csv b/docs/Status/Cxx20Issues.csv index 68e1c2730..2437cc247 100644 --- a/docs/Status/Cxx20Issues.csv +++ b/docs/Status/Cxx20Issues.csv @@ -1,4 +1,4 @@ -"Issue #","Issue Name","Meeting","Status","First released version","Labels" +"Issue #","Issue Name","Meeting","Status","First released version" "`2070 `__","``allocate_shared``\ should use ``allocator_traits::construct``\ ","Toronto","Resolved by `P0674R1 `__","" "`2444 `__","Inconsistent complexity for ``std::sort_heap``\ ","Toronto","","" "`2593 `__","Moved-from state of Allocators","Toronto","","" @@ -23,7 +23,7 @@ "`2950 `__","std::byte operations are misspecified","Albuquerque","|Complete|","" "`2952 `__","iterator_traits should work for pointers to cv T","Albuquerque","|Complete|","" "`2953 `__","LWG 2853 should apply to deque::erase too","Albuquerque","|Complete|","" -"`2958 `__","Moves improperly defined as deleted","Albuquerque","|Complete|","" +"`2958 `__","Moves improperly defined as deleted","Albuquerque","*We already do this*","" "`2964 `__","Apparently redundant requirement for dynamic_pointer_cast","Albuquerque","","" "`2965 `__","Non-existing path::native_string() in filesystem_error::what() specification","Albuquerque","|Nothing To Do|","" "`2972 `__","What is ``is_trivially_destructible_v``\ ?","Albuquerque","|Complete|","" @@ -32,12 +32,12 @@ "`2978 `__","Hash support for pmr::string and friends","Albuquerque","","" "`2979 `__","aligned_union should require complete object types","Albuquerque","|Complete|","" "`2980 `__","Cannot compare_exchange empty pointers","Albuquerque","","" -"`2981 `__","Remove redundant deduction guides from standard library","Albuquerque","|Nothing To Do|","" +"`2981 `__","Remove redundant deduction guides from standard library","Albuquerque","","" "`2982 `__","Making size_type consistent in associative container deduction guides","Albuquerque","","" -"`2988 `__","Clause 32 cleanup missed one typename","Albuquerque","|Complete|","13.0" +"`2988 `__","Clause 32 cleanup missed one typename","Albuquerque","","" "`2993 `__","reference_wrapper conversion from T&&","Albuquerque","|Complete|","13.0" "`2998 `__","Requirements on function objects passed to {``forward_``,}list-specific algorithms","Albuquerque","|Nothing To Do|","" -"`3001 `__","weak_ptr::element_type needs remove_extent_t","Albuquerque","|Complete|","14.0" +"`3001 `__","weak_ptr::element_type needs remove_extent_t","Albuquerque","","" "`3024 `__","variant's copies must be deleted instead of disabled via SFINAE","Albuquerque","|Complete|","" "","","","","" "`2164 `__","What are the semantics of ``vector.emplace(vector.begin(), vector.back())``\ ?","Jacksonville","|Complete|","" @@ -70,7 +70,7 @@ "`3041 `__","Unnecessary ``decay``\ in ``reference_wrapper``\ ","Jacksonville","|Complete|","" "`3042 `__","``is_literal_type_v``\ should be inline","Jacksonville","|Complete|","" "`3043 `__","Bogus postcondition for ``filesystem_error``\ constructor","Jacksonville","|Complete|","" -"`3045 `__","``atomic``\ doesn't have ``value_type``\ or ``difference_type``\ ","Jacksonville","","" +"`3045 `__","``atomic<*floating-point*>``\ doesn't have ``value_type``\ or ``difference_type``\ ","Jacksonville","","" "`3048 `__","``transform_reduce(exec, first1, last1, first2, init)``\ discards execution policy","Jacksonville","","" "`3051 `__","Floating point classifications were inadvertently changed in P0175","Jacksonville","|Nothing To Do|","" "`3075 `__","``basic_string``\ needs deduction guides from ``basic_string_view``\ ","Jacksonville","|Complete|","" @@ -108,14 +108,14 @@ "`3025 `__","Map-like container deduction guides should use ``pair``\ , not ``pair``\ ","San Diego","|Complete|","" "`3031 `__","Algorithms and predicates with non-const reference arguments","San Diego","","" "`3037 `__","``polymorphic_allocator``\ and incomplete types","San Diego","","" -"`3038 `__","``polymorphic_allocator::allocate``\ should not allow integer overflow to create vulnerabilities","San Diego","|Complete|","14.0" +"`3038 `__","``polymorphic_allocator::allocate``\ should not allow integer overflow to create vulnerabilities","San Diego","","" "`3054 `__","``uninitialized_copy``\ appears to not be able to meet its exception-safety guarantee","San Diego","","" "`3065 `__","LWG 2989 missed that all ``path``\ 's other operators should be hidden friends as well","San Diego","|Complete|","" "`3096 `__","``path::lexically_relative``\ is confused by trailing slashes","San Diego","|Complete|","" -"`3116 `__","``OUTERMOST_ALLOC_TRAITS``\ needs ``remove_reference_t``\ ","San Diego","","" +"`3116 `__","``*OUTERMOST_ALLOC_TRAITS*``\ needs ``remove_reference_t``\ ","San Diego","","" "`3122 `__","``__cpp_lib_chrono_udls``\ was accidentally dropped","San Diego","|Complete|","" -"`3127 `__","``basic_osyncstream::rdbuf``\ needs a ``const_cast``\ ","San Diego","","" -"`3128 `__","``strstream::rdbuf``\ needs a ``const_cast``\ ","San Diego","|Nothing To Do|","" +"`3127 `__","``basic_osyncstream::rdbuf``\ needs a ````const_cast````\ ","San Diego","","" +"`3128 `__","``strstream::rdbuf``\ needs a ````const_cast````\ ","San Diego","|Nothing To Do|","" "`3129 `__","``regex_token_iterator``\ constructor uses wrong pointer arithmetic","San Diego","","" "`3130 `__","|sect|\ [input.output] needs many ``addressof``\ ","San Diego","","" "`3131 `__","``addressof``\ all the things","San Diego","","" @@ -125,7 +125,7 @@ "`3145 `__","``file_clock``\ breaks ABI for C++17 implementations","San Diego","|Complete|","" "`3147 `__","Definitions of ""likely"" and ""unlikely"" are likely to cause problems","San Diego","","" "`3148 `__","````\ should be freestanding","San Diego","","" -"`3153 `__","``Common``\ and ``common_type``\ have too little in common","San Diego","|Complete|","13.0" +"`3153 `__","``Common``\ and ``common_type``\ have too little in common","San Diego","","" "`3154 `__","``Common``\ and ``CommonReference``\ have a common defect","San Diego","","" "","","","","" "`3012 `__","``atomic``\ is unimplementable for non-``is_trivially_copy_constructible T``\ ","Kona","","" @@ -136,22 +136,22 @@ "`3112 `__","``system_error``\ and ``filesystem_error``\ constructors taking a ``string``\ may not be able to meet their postconditions","Kona","","" "`3119 `__","Program-definedness of closure types","Kona","|Nothing To Do|","" "`3133 `__","Modernizing numeric type requirements","Kona","","" -"`3144 `__","``span``\ does not have a ``const_pointer``\ typedef","Kona","|Complete|","" -"`3173 `__","Enable CTAD for ``ref-view``\ ","Kona","","","|ranges|" -"`3179 `__","``subrange``\ should always model ``Range``\ ","Kona","","","|ranges|" -"`3180 `__","Inconsistently named return type for ``ranges::minmax_element``\ ","Kona","","","|ranges|" +"`3144 `__","``span``\ does not have a ````const_pointer````\ typedef","Kona","|Complete|","" +"`3173 `__","Enable CTAD for *``ref-view``*\ ","Kona","","" +"`3179 `__","``subrange``\ should always model ``Range``\ ","Kona","","" +"`3180 `__","Inconsistently named return type for ``ranges::minmax_element``\ ","Kona","","" "`3182 `__","Specification of ``Same``\ could be clearer","Kona","","" "","","","","" "`2899 `__","``is_(nothrow_)move_constructible``\ and ``tuple``\ , ``optional``\ and ``unique_ptr``\ ","Cologne","","" "`3055 `__","``path::operator+=(*single-character*)``\ misspecified","Cologne","|Complete|","7.0" -"`3158 `__","``tuple(allocator_arg_t, const Alloc&)``\ should be conditionally explicit","Cologne","|Complete|","10.0" -"`3169 `__","``ranges``\ permutation generators discard useful information","Cologne","","","|ranges|" -"`3183 `__","Normative permission to specialize Ranges variable templates","Cologne","","","|ranges|" +"`3158 `__","``tuple(allocator_arg_t, const Alloc&)``\ should be conditionally explicit","Cologne","","" +"`3169 `__","``ranges``\ permutation generators discard useful information","Cologne","","" +"`3183 `__","Normative permission to specialize Ranges variable templates","Cologne","","" "`3184 `__","Inconsistencies in ``bind_front``\ wording","Cologne","|Complete|","13.0" "`3185 `__","Uses-allocator construction functions missing ``constexpr``\ and ``noexcept``\ ","Cologne","","" -"`3186 `__","``ranges``\ removal, partition, and ``partial_sort_copy``\ algorithms discard useful information","Cologne","","","|ranges|" +"`3186 `__","``ranges``\ removal, partition, and ``partial_sort_copy``\ algorithms discard useful information","Cologne","","" "`3187 `__","`P0591R4 `__ reverted DR 2586 fixes to ``scoped_allocator_adaptor::construct()``\ ","Cologne","","" -"`3191 `__","``std::ranges::shuffle``\ synopsis does not match algorithm definition","Cologne","","","|ranges|" +"`3191 `__","``std::ranges::shuffle``\ synopsis does not match algorithm definition","Cologne","","" "`3196 `__","``std::optional``\ is ill-formed is ``T``\ is an array","Cologne","|Complete|","" "`3198 `__","Bad constraint on ``std::span::span()``\ ","Cologne","|Complete|","" "`3199 `__","``istream >> bitset<0>``\ fails","Cologne","","" @@ -161,140 +161,140 @@ "`3209 `__","Expression in ``year::ok()``\ returns clause is ill-formed","Cologne","|Complete|","" "","","","","" "`3231 `__","``year_month_day_last::day``\ specification does not cover ``!ok()``\ values","Belfast","|Nothing To Do|","" -"`3225 `__","``zoned_time``\ converting constructor shall not be ``noexcept``\ ","Belfast","","","|chrono|" -"`3190 `__","``std::allocator::allocate``\ sometimes returns too little storage","Belfast","|Complete|","14.0" -"`3218 `__","Modifier for ``%d``\ parse flag does not match POSIX and ``format``\ specification","Belfast","","","|chrono| |format|" -"`3224 `__","``zoned_time``\ constructor from ``TimeZonePtr``\ does not specify initialization of ``tp_``\ ","Belfast","","","|chrono|" -"`3230 `__","Format specifier ``%y/%Y``\ is missing locale alternative versions","Belfast","","","|chrono| |format|" -"`3232 `__","Inconsistency in ``zoned_time``\ deduction guides","Belfast","","","|chrono|" +"`3225 `__","``zoned_time``\ converting constructor shall not be ``noexcept``\ ","Belfast","","" +"`3190 `__","``std::allocator::allocate``\ sometimes returns too little storage","Belfast","","" +"`3218 `__","Modifier for ``%d``\ parse flag does not match POSIX and ``format``\ specification","Belfast","","" +"`3224 `__","``zoned_time``\ constructor from ``TimeZonePtr``\ does not specify initialization of ``tp_``\ ","Belfast","","" +"`3230 `__","Format specifier ``%y/%Y``\ is missing locale alternative versions","Belfast","","" +"`3232 `__","Inconsistency in ``zoned_time``\ deduction guides","Belfast","","" "`3222 `__","P0574R1 introduced preconditions on non-existent parameters","Belfast","","" "`3221 `__","Result of ``year_month``\ arithmetic with ``months``\ is ambiguous","Belfast","|Complete|","8.0" "`3235 `__","``parse``\ manipulator without abbreviation is not callable","Belfast","","" -"`3246 `__","What are the constraints on the template parameter of ``basic_format_arg``\ ?","Belfast","","","|format|" +"`3246 `__","What are the constraints on the template parameter of ``basic_format_arg``\ ?","Belfast","","" "`3253 `__","``basic_syncbuf::basic_syncbuf()``\ should not be explicit","Belfast","","" -"`3245 `__","Unnecessary restriction on ``'%p'``\ parse specifier","Belfast","","","|chrono|" +"`3245 `__","Unnecessary restriction on ``'%p'``\ parse specifier","Belfast","","" "`3244 `__","Constraints for ``Source``\ in |sect|\ [fs.path.req] insufficiently constrainty","Belfast","","" -"`3241 `__","``chrono-spec``\ grammar ambiguity in |sect|\ [time.format]","Belfast","","","|chrono| |format|" +"`3241 `__","``chrono-spec``\ grammar ambiguity in |sect|\ [time.format]","Belfast","","" "`3257 `__","Missing feature testing macro update from P0858","Belfast","","" "`3256 `__","Feature testing macro for ``constexpr``\ algorithms","Belfast","|Complete|","13.0" -"`3273 `__","Specify ``weekday_indexed``\ to range of ``[0, 7]``\ ","Belfast","","","|chrono|" +"`3273 `__","Specify ``weekday_indexed``\ to range of ``[0, 7]``\ ","Belfast","","" "`3070 `__","``path::lexically_relative``\ causes surprising results if a filename can also be a *root-name*","Belfast","","" -"`3266 `__","``to_chars(bool)``\ should be deleted","Belfast","|Complete|","14.0" -"`3272 `__","``%I%p``\ should parse/format ``duration``\ since midnight","Belfast","","","|chrono| |format|" -"`3259 `__","The definition of *constexpr iterators* should be adjusted","Belfast","","","|ranges|" +"`3266 `__","``to_chars(bool)``\ should be deleted","Belfast","","" +"`3272 `__","``%I%p``\ should parse/format ``duration``\ since midnight","Belfast","","" +"`3259 `__","The definition of *constexpr iterators* should be adjusted","Belfast","","" "`3103 `__","Errors in taking subview of ``span``\ should be ill-formed where possible","Belfast","","" -"`3274 `__","Missing feature test macro for ````\ ","Belfast","|Complete|","11.0" -"`3276 `__","Class ``split_view::outer_iterator::value_type``\ should inherit from ``view_interface``\ ","Belfast","","","|ranges|" -"`3277 `__","Pre-increment on prvalues is not a requirement of ``weakly_incrementable``\ ","Belfast","","","|ranges|" +"`3274 `__","Missing feature test macro for ````\ ","Belfast","","" +"`3276 `__","Class ``split_view::outer_iterator::value_type``\ should inherit from ``view_interface``\ ","Belfast","","" +"`3277 `__","Pre-increment on prvalues is not a requirement of ``weakly_incrementable``\ ","Belfast","","" "`3149 `__","``DefaultConstructible``\ should require default initialization","Belfast","|Complete|","13.0" "","","","","" "`1203 `__","More useful rvalue stream insertion","Prague","|Complete|","12.0" "`2859 `__","Definition of *reachable* in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object","Prague","","" "`3018 `__","``shared_ptr``\ of function type","Prague","","" -"`3050 `__","Conversion specification problem in ``chrono::duration``\ constructor","Prague","","","|chrono|" +"`3050 `__","Conversion specification problem in ``chrono::duration``\ constructor","Prague","","" "`3141 `__","``CopyConstructible``\ doesn't preserve source values","Prague","|Nothing to do|","" "`3150 `__","``UniformRandomBitGenerator``\ should validate ``min``\ and ``max``\ ","Prague","|Complete|","13.0" "`3175 `__","The ``CommonReference``\ requirement of concept ``SwappableWith``\ is not satisfied in the example","Prague","|Complete|","13.0" "`3194 `__","``ConvertibleTo``\ prose does not match code","Prague","|Complete|","13.0" "`3200 `__","``midpoint``\ should not constrain ``T``\ is complete","Prague","|Nothing To Do|","" "`3201 `__","``lerp``\ should be marked as ``noexcept``\ ","Prague","|Complete|","" -"`3226 `__","``zoned_time``\ constructor from ``string_view``\ should accept ``zoned_time``\ ","Prague","","","|chrono|" +"`3226 `__","``zoned_time``\ constructor from ``string_view``\ should accept ``zoned_time``\ ","Prague","","" "`3233 `__","Broken requirements for ``shared_ptr``\ converting constructors","Prague","","" -"`3237 `__","LWG 3038 and 3190 have inconsistent PRs","Prague","|Complete|","14.0" +"`3237 `__","LWG 3038 and 3190 have inconsistent PRs","Prague","","" "`3238 `__","Insufficiently-defined behavior of ``std::function``\ deduction guides","Prague","","" -"`3242 `__","``std::format``\ : missing rules for ``arg-id``\ in ``width``\ and ``precision``\ ","Prague","|Complete|","Clang 14","|format|" -"`3243 `__","``std::format``\ and negative zeroes","Prague","|Complete|","14.0","|format|" -"`3247 `__","``ranges::iter_move``\ should perform ADL-only lookup of ``iter_move``\ ","Prague","","","|ranges|" -"`3248 `__","``std::format``\ ``#b``\ , ``#B``\ , ``#o``\ , ``#x``\ , and ``#X``\ presentation types misformat negative numbers","Prague","|Complete|","14.0","|format|" -"`3250 `__","``std::format``\ : ``#``\ (alternate form) for NaN and inf","Prague","|Complete|","14.0","|format|" -"`3251 `__","Are ``std::format``\ alignment specifiers applied to string arguments?","Prague","|Complete|","14.0","|format|" -"`3252 `__","Parse locale's aware modifiers for commands are not consistent with POSIX spec","Prague","","","|chrono|" +"`3242 `__","``std::format``\ : missing rules for ``arg-id``\ in ``width``\ and ``precision``\ ","Prague","","" +"`3243 `__","``std::format``\ and negative zeroes","Prague","","" +"`3247 `__","``ranges::iter_move``\ should perform ADL-only lookup of ``iter_move``\ ","Prague","","" +"`3248 `__","``std::format``\ ``#b``\ , ``#B``\ , ``#o``\ , ``#x``\ , and ``#X``\ presentation types misformat negative numbers","Prague","","" +"`3250 `__","``std::format``\ : ``#``\ (alternate form) for NaN and inf","Prague","","" +"`3251 `__","Are ``std::format``\ alignment specifiers applied to string arguments?","Prague","","" +"`3252 `__","Parse locale's aware modifiers for commands are not consistent with POSIX spec","Prague","","" "`3254 `__","Strike ``stop_token``\ 's ``operator!=``\ ","Prague","","" "`3255 `__","``span``\ 's ``array``\ constructor is too strict","Prague","|Complete|","" -"`3260 `__","``year_month*``\ arithmetic rejects durations convertible to years","Prague","","","|chrono|" -"`3262 `__","Formatting of negative durations is not specified","Prague","","","|chrono| |format|" -"`3264 `__","``sized_range``\ and ``ranges::size``\ redundantly use ``disable_sized_range``\ ","Prague","","","|ranges|" -"`3269 `__","Parse manipulators do not specify the result of the extraction from stream","Prague","","","|chrono|" -"`3270 `__","Parsing and formatting ``%j``\ with ``duration``\ s","Prague","","","|chrono| |format|" -"`3280 `__","View converting constructors can cause constraint recursion and are unneeded","Prague","","","|ranges|" -"`3281 `__","Conversion from ``*pair-like*``\ types to ``subrange``\ is a silent semantic promotion","Prague","","","|ranges|" -"`3282 `__","``subrange``\ converting constructor should disallow derived to base conversions","Prague","","","|ranges|" -"`3284 `__","``random_access_iterator``\ semantic constraints accidentally promote difference type using unary negate","Prague","","","|ranges|" +"`3260 `__","``year_month*``\ arithmetic rejects durations convertible to years","Prague","","" +"`3262 `__","Formatting of negative durations is not specified","Prague","","" +"`3264 `__","``sized_range``\ and ``ranges::size``\ redundantly use ``disable_sized_range``\ ","Prague","","" +"`3269 `__","Parse manipulators do not specify the result of the extraction from stream","Prague","","" +"`3270 `__","Parsing and formatting ``%j``\ with ``duration``\ s","Prague","","" +"`3280 `__","View converting constructors can cause constraint recursion and are unneeded","Prague","","" +"`3281 `__","Conversion from ``*pair-like*``\ types to ``subrange``\ is a silent semantic promotion","Prague","","" +"`3282 `__","``subrange``\ converting constructor should disallow derived to base conversions","Prague","","" +"`3284 `__","``random_access_iterator``\ semantic constraints accidentally promote difference type using unary negate","Prague","","" "`3285 `__","The type of a customization point object shall satisfy ``semiregular``\ ","Prague","","" -"`3286 `__","``ranges::size``\ is not required to be valid after a call to ``ranges::begin``\ on an input range","Prague","","","|ranges|" -"`3291 `__","``iota_view::iterator``\ has the wrong ``iterator_category``\ ","Prague","","","|ranges|" -"`3292 `__","``iota_view``\ is under-constrained","Prague","","","|ranges|" -"`3294 `__","``zoned_time``\ deduction guides misinterprets ``string``\ /``char*``\ ","Prague","","","|chrono|" +"`3286 `__","``ranges::size``\ is not required to be valid after a call to ``ranges::begin``\ on an input range","Prague","","" +"`3291 `__","``iota_view::iterator``\ has the wrong ``iterator_category``\ ","Prague","","" +"`3292 `__","``iota_view``\ is under-constrained","Prague","","" +"`3294 `__","``zoned_time``\ deduction guides misinterprets ``string``\ /``char*``\ ","Prague","","" "`3296 `__","Inconsistent default argument for ``basic_regex<>::assign``\ ","Prague","|Complete|","" -"`3299 `__","Pointers don't need customized iterator behavior","Prague","","","|ranges|" +"`3299 `__","Pointers don't need customized iterator behavior","Prague","","" "`3300 `__","Non-array ``ssize``\ overload is underconstrained","Prague","","" -"`3301 `__","``transform_view::iterator``\ has incorrect ``iterator_category``\ ","Prague","","","|ranges|" -"`3302 `__","Range adaptor objects ``keys``\ and ``values``\ are unspecified","Prague","","","|ranges|" +"`3301 `__","``transform_view::iterator``\ has incorrect ``iterator_category``\ ","Prague","","" +"`3302 `__","Range adaptor objects ``keys``\ and ``values``\ are unspecified","Prague","","" "`3303 `__","Bad ""``constexpr``\ "" marker for ``destroy/destroy_n``\ ","Prague","","" "`3304 `__","Allocate functions of ``std::polymorphic_allocator``\ should require ``[[nodiscard]]``\ ","Prague","","" "`3307 `__","``std::allocator().allocate(n)``\ ","Prague","","" "`3310 `__","Replace ``SIZE_MAX``\ with ``numeric_limits::max()``\ ","Prague","","" -"`3313 `__","``join_view::iterator::operator--``\ is incorrectly constrained","Prague","","","|ranges|" -"`3314 `__","Is stream insertion behavior locale dependent when ``Period::type``\ is ``micro``\ ?","Prague","","","|chrono|" +"`3313 `__","``join_view::iterator::operator--``\ is incorrectly constrained","Prague","","" +"`3314 `__","Is stream insertion behavior locale dependent when ``Period::type``\ is ``micro``\ ?","Prague","","" "`3315 `__","Correct Allocator Default Behavior","Prague","","" -"`3316 `__","Correctly define epoch for ``utc_clock``\ / ``utc_timepoint``\ ","Prague","","","|chrono|" -"`3317 `__","Incorrect ``operator<<``\ for floating-point durations","Prague","","","|chrono|" -"`3318 `__","Clarify whether clocks can represent time before their epoch","Prague","","","|chrono|" -"`3319 `__","Properly reference specification of IANA time zone database","Prague","","","|chrono|" +"`3316 `__","Correctly define epoch for ``utc_clock``\ / ``utc_timepoint``\ ","Prague","","" +"`3317 `__","Incorrect ``operator<<``\ for floating-point durations","Prague","","" +"`3318 `__","Clarify whether clocks can represent time before their epoch","Prague","","" +"`3319 `__","Properly reference specification of IANA time zone database","Prague","","" "`3320 `__","``span::cbegin/cend``\ methods produce different results than ``std::[ranges::]cbegin/cend``\ ","Prague","|Complete|","" "`3321 `__","``uninitialized_construct_using_allocator``\ should use ``construct_at``\ ","Prague","","" -"`3323 `__","``*has-tuple-element*``\ helper concept needs ``convertible_to``\ ","Prague","","","|ranges|" -"`3324 `__","Special-case ``std::strong/weak/partial_order``\ for pointers","Prague","|Complete|","14.0","|spaceship|" -"`3325 `__","Constrain return type of transformation function for ``transform_view``\ ","Prague","","","|ranges|" -"`3326 `__","``enable_view``\ has false positives","Prague","|In progress|","","|ranges|" -"`3327 `__","Format alignment specifiers vs. text direction","Prague","|Nothing To Do|","","|format|" +"`3323 `__","``*has-tuple-element*``\ helper concept needs ``convertible_to``\ ","Prague","","" +"`3324 `__","Special-case ``std::strong/weak/partial_order``\ for pointers","Prague","","" +"`3325 `__","Constrain return type of transformation function for ``transform_view``\ ","Prague","","" +"`3326 `__","``enable_view``\ has false positives","Prague","|In progress|","" +"`3327 `__","Format alignment specifiers vs. text direction","Prague","|Nothing To Do|","" "`3328 `__","Clarify that ``std::string``\ is not good for UTF-8","Prague","","" "`3329 `__","``totally_ordered_with``\ both directly and indirectly requires ``common_reference_with``\ ","Prague","|Complete|","13.0" -"`3330 `__","Include ````\ from most library headers","Prague","|Complete|","13.0","|spaceship|" -"`3331 `__","Define ``totally_ordered/_with``\ in terms of ``partially-ordered-with``\ ","Prague","|Complete|","13.0" -"`3332 `__","Issue in |sect|\ [time.format]","Prague","","","|chrono| |format|" +"`3330 `__","Include ````\ from most library headers","Prague","","" +"`3331 `__","Define ``totally_ordered/_with``\ in terms of ``*partially-ordered-with*``\ ","Prague","|Complete|","13.0" +"`3332 `__","Issue in |sect|\ [time.format]","Prague","","" "`3334 `__","``basic_osyncstream``\ move assignment and destruction calls ``basic_syncbuf::emit()``\ twice","Prague","","" -"`3335 `__","Resolve C++20 NB comments US 273 and GB 274","Prague","","","|ranges|" +"`3335 `__","Resolve C++20 NB comments US 273 and GB 274","Prague","","" "`3338 `__","Rename ``default_constructible``\ to ``default_initializable``\ ","Prague","|Complete|","13.0" -"`3340 `__","Formatting functions should throw on argument/format string mismatch in |sect|\ [format.functions]","Prague","|Complete|","14.0","|format|" +"`3340 `__","Formatting functions should throw on argument/format string mismatch in |sect|\ [format.functions]","Prague","","" "`3346 `__","``pair``\ and ``tuple``\ copy and move constructor have backwards specification","Prague","","" "`3347 `__","``std::pair``\ now requires ``T``\ and ``U``\ to be less-than-comparable","Prague","","" -"`3348 `__","``__cpp_lib_unwrap_ref``\ in wrong header","Prague","|Complete|","12.0" +"`3348 `__","``__cpp_lib_unwrap_ref``\ in wrong header","Prague","","" "`3349 `__","Missing ``__cpp_lib_constexpr_complex``\ for P0415R1","Prague","","" -"`3350 `__","Simplify return type of ``lexicographical_compare_three_way``\ ","Prague","","","|spaceship|" -"`3351 `__","``ranges::enable_safe_range``\ should not be constrained","Prague","","","|ranges|" -"`3352 `__","``strong_equality``\ isn't a thing","Prague","|Nothing To Do|","","|spaceship|" -"`3354 `__","``has_strong_structural_equality``\ has a meaningless definition","Prague","","","|spaceship|" -"`3355 `__","The memory algorithms should support move-only input iterators introduced by P1207","Prague","","","|ranges|" -"`3356 `__","``__cpp_lib_nothrow_convertible``\ should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","|Complete|","12.0" +"`3350 `__","Simplify return type of ``lexicographical_compare_three_way``\ ","Prague","","" +"`3351 `__","``ranges::enable_safe_range``\ should not be constrained","Prague","","" +"`3352 `__","``strong_equality``\ isn't a thing","Prague","","" +"`3354 `__","``has_strong_structural_equality``\ has a meaningless definition","Prague","","" +"`3355 `__","The memory algorithms should support move-only input iterators introduced by P1207","Prague","","" +"`3356 `__","``__cpp_lib_nothrow_convertible``\ should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","","" "`3358 `__","|sect|\ [span.cons] is mistaken that ``to_address``\ can throw","Prague","","" -"`3359 `__","````\ leap second support should allow for negative leap seconds","Prague","","","|chrono|" -"`3360 `__","``three_way_comparable_with``\ is inconsistent with similar concepts","Prague","|Nothing To Do|","","|spaceship|" +"`3359 `__","````\ leap second support should allow for negative leap seconds","Prague","","" +"`3360 `__","``three_way_comparable_with``\ is inconsistent with similar concepts","Prague","","" "`3362 `__","Strike ``stop_source``\ 's ``operator!=``\ ","Prague","","" -"`3363 `__","``drop_while_view``\ should opt-out of ``sized_range``\ ","Prague","","","|ranges|" -"`3364 `__","Initialize data members of ranges and their iterators","Prague","","","|ranges|" +"`3363 `__","``drop_while_view``\ should opt-out of ``sized_range``\ ","Prague","","" +"`3364 `__","Initialize data members of ranges and their iterators","Prague","","" "`3367 `__","Integer-class conversions should not throw","Prague","","" -"`3369 `__","``span``\ 's deduction-guide for built-in arrays doesn't work","Prague","|Complete|","14.0" -"`3371 `__","``visit_format_arg``\ and ``make_format_args``\ are not hidden friends","Prague","|Complete|","14.0","|format|" -"`3372 `__","``vformat_to``\ should not try to deduce ``Out``\ twice","Prague","|Complete|","14.0","|format|" -"`3373 `__","``{to,from}_chars_result``\ and ``format_to_n_result``\ need the ""we really mean what we say"" wording","Prague","|Complete|","14.0","|format|" +"`3369 `__","``span``\ 's deduction-guide for built-in arrays doesn't work","Prague","","" +"`3371 `__","``visit_format_arg``\ and ``make_format_args``\ are not hidden friends","Prague","","" +"`3372 `__","``vformat_to``\ should not try to deduce ``Out``\ twice","Prague","","" +"`3373 `__","``{to,from}_chars_result``\ and ``format_to_n_result``\ need the ""we really mean what we say"" wording","Prague","","" "`3374 `__","P0653 + P1006 should have made the other ``std::to_address``\ overload ``constexpr``\ ","Prague","|Complete|","12.0" -"`3375 `__","``decay``\ in ``viewable_range``\ should be ``remove_cvref``\ ","Prague","","","|ranges|" -"`3377 `__","``elements_view::iterator``\ befriends a specialization of itself","Prague","","","|ranges|" +"`3375 `__","``decay``\ in ``viewable_range``\ should be ``remove_cvref``\ ","Prague","","" +"`3377 `__","``elements_view::iterator``\ befriends a specialization of itself","Prague","","" "`3379 `__","""``safe``\ "" in several library names is misleading","Prague","|In Progress|","" -"`3380 `__","``common_type``\ and comparison categories","Prague","","","|spaceship|" -"`3381 `__","``begin``\ and ``data``\ must agree for ``contiguous_range``\ ","Prague","","","|ranges|" +"`3380 `__","``common_type``\ and comparison categories","Prague","","" +"`3381 `__","``begin``\ and ``data``\ must agree for ``contiguous_range``\ ","Prague","","" "`3382 `__","NTTP for ``pair``\ and ``array``\ ","Prague","","" -"`3383 `__","|sect|\ [time.zone.leap.nonmembers] ``sys_seconds``\ should be replaced with ``seconds``\ ","Prague","","","|chrono|" -"`3384 `__","``transform_view::*sentinel*``\ has an incorrect ``operator-``\ ","Prague","","","|ranges|" -"`3385 `__","``common_iterator``\ is not sufficiently constrained for non-copyable iterators","Prague","","","|ranges|" -"`3387 `__","|sect|\ [range.reverse.view] ``reverse_view``\ unintentionally requires ``range``\ ","Prague","","","|ranges|" -"`3388 `__","``view``\ iterator types have ill-formed ``<=>``\ operators","Prague","","","|ranges|" -"`3389 `__","A move-only iterator still does not have a ``counted_iterator``\ ","Prague","","","|ranges|" -"`3390 `__","``make_move_iterator()``\ cannot be used to construct a ``move_iterator``\ for a move-only iterator","Prague","|Complete|","14.0","|ranges|" -"`3393 `__","Missing/incorrect feature test macro for coroutines","Prague","|Complete|","14.0" -"`3395 `__","Definition for three-way comparison needs to be updated (US 152)","Prague","","","|spaceship|" +"`3383 `__","|sect|\ [time.zone.leap.nonmembers] ``sys_seconds``\ should be replaced with ``seconds``\ ","Prague","","" +"`3384 `__","``transform_view::*sentinel*``\ has an incorrect ``operator-``\ ","Prague","","" +"`3385 `__","``common_iterator``\ is not sufficiently constrained for non-copyable iterators","Prague","","" +"`3387 `__","|sect|\ [range.reverse.view] ``reverse_view``\ unintentionally requires ``range``\ ","Prague","","" +"`3388 `__","``view``\ iterator types have ill-formed ``<=>``\ operators","Prague","","" +"`3389 `__","A move-only iterator still does not have a ``counted_iterator``\ ","Prague","","" +"`3390 `__","``make_move_iterator()``\ cannot be used to construct a ``move_iterator``\ for a move-only iterator","Prague","","" +"`3393 `__","Missing/incorrect feature test macro for coroutines","Prague","","" +"`3395 `__","Definition for three-way comparison needs to be updated (US 152)","Prague","","" "`3396 `__","Clarify point of reference for ``source_location::current()``\ (DE 169)","Prague","","" -"`3397 `__","``ranges::basic_istream_view::iterator``\ should not provide ``iterator_category``\ ","Prague","","","|ranges|" -"`3398 `__","``tuple_element_t``\ is also wrong for ``const subrange``\ ","Prague","|Complete|","14.0","|ranges|" +"`3397 `__","``ranges::basic_istream_view::iterator``\ should not provide ``iterator_category``\ ","Prague","","" +"`3398 `__","``tuple_element_t``\ is also wrong for ``const subrange``\ ","Prague","","" "`3446 `__","``indirectly_readable_traits``\ ambiguity for types with both ``value_type``\ and ``element_type``\ ","November virtual meeting","|Complete|","13.0" diff --git a/docs/Status/Cxx20Papers.csv b/docs/Status/Cxx20Papers.csv index cf983a4b4..7915b7929 100644 --- a/docs/Status/Cxx20Papers.csv +++ b/docs/Status/Cxx20Papers.csv @@ -22,14 +22,14 @@ "`P0753R2 `__","LWG","Manipulators for C++ Synchronized Buffered Ostream","Jacksonville","","" "`P0754R2 `__","LWG","","Jacksonville","|Complete|","7.0" "`P0809R0 `__","LWG","Comparing Unordered Containers","Jacksonville","|Nothing To Do|","" -"`P0858R0 `__","LWG","Constexpr iterator requirements","Jacksonville","|Complete|","12.0" +"`P0858R0 `__","LWG","Constexpr iterator requirements","Jacksonville","","" "`P0905R1 `__","CWG","Symmetry for spaceship","Jacksonville","","" "`P0966R1 `__","LWG","``string::reserve``\ Should Not Shrink","Jacksonville","|Complete| [#note-P0966]_","12.0" "","","","","","" "`P0019R8 `__","LWG","Atomic Ref","Rapperswil","","" "`P0458R2 `__","LWG","Checking for Existence of an Element in Associative Containers","Rapperswil","|Complete|","13.0" "`P0475R1 `__","LWG","LWG 2511: guaranteed copy elision for piecewise construction","Rapperswil","|Complete|","" -"`P0476R2 `__","LWG","Bit-casting object representations","Rapperswil","|Complete|","14.0" +"`P0476R2 `__","LWG","Bit-casting object representations","Rapperswil","","" "`P0528R3 `__","CWG","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","Rapperswil","","" "`P0542R5 `__","CWG","Support for contract based programming in C++","Rapperswil","*Removed in Cologne*","n/a" "`P0556R3 `__","LWG","Integral power-of-2 operations","Rapperswil","|Complete|","9.0" @@ -98,110 +98,105 @@ "`P1463R1 `__","LWG","Mandating the Standard Library: Clause 21 - Containers library","Kona","","" "`P1464R1 `__","LWG","Mandating the Standard Library: Clause 22 - Iterators library","Kona","|Complete|","9.0" "","","","","","" -"`P0325R4 `__","LWG","to_array from LFTS with updates","Cologne","|Complete|","10.0" -"`P0408R7 `__","LWG","Efficient Access to basic_stringbuf's Buffer","Cologne","","" -"`P0466R5 `__","LWG","Layout-compatibility and Pointer-interconvertibility Traits","Cologne","","" -"`P0553R4 `__","LWG","Bit operations","Cologne","|Complete|","9.0" -"`P0631R8 `__","LWG","Math Constants","Cologne","|Complete|","11.0" -"`P0645R10 `__","LWG","Text Formatting","Cologne","|Complete| [#note-P0645]_","14.0" -"`P0660R10 `__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","","" -"`P0784R7 `__","CWG","More constexpr containers","Cologne","|Complete|","12.0" -"`P0980R1 `__","LWG","Making std::string constexpr","Cologne","","" -"`P1004R2 `__","LWG","Making std::vector constexpr","Cologne","","" -"`P1035R7 `__","LWG","Input Range Adaptors","Cologne","","" -"`P1065R2 `__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0" -"`P1135R6 `__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0" -"`P1207R4 `__","LWG","Movability of Single-pass Iterators","Cologne","","" -"`P1208R6 `__","LWG","Adopt source_location for C++20","Cologne","","" -"`P1355R2 `__","LWG","Exposing a narrow contract for ceil2","Cologne","|Complete|","9.0" -"`P1361R2 `__","LWG","Integration of chrono with text formatting","Cologne","","" -"`P1423R3 `__","LWG","char8_t backward compatibility remediation","Cologne","|In Progress|","" -"`P1424R1 `__","LWG","'constexpr' feature macro concerns","Cologne","Superseded by `P1902 `__","" -"`P1466R3 `__","LWG","Miscellaneous minor fixes for chrono","Cologne","","" -"`P1474R1 `__","LWG","Helpful pointers for ContiguousIterator","Cologne","","" -"`P1502R1 `__","LWG","Standard library header units for C++20","Cologne","","" -"`P1522R1 `__","LWG","Iterator Difference Type and Integer Overflow","Cologne","","" -"`P1523R1 `__","LWG","Views and Size Types","Cologne","","" -"`P1612R1 `__","LWG","Relocate Endian's Specification","Cologne","|Complete|","10.0" -"`P1614R2 `__","LWG","The Mothership has Landed","Cologne","|In Progress|","" -"`P1638R1 `__","LWG","basic_istream_view::iterator should not be copyable","Cologne","","" -"`P1643R1 `__","LWG","Add wait/notify to atomic_ref","Cologne","","" -"`P1644R0 `__","LWG","Add wait/notify to atomic","Cologne","","" -"`P1650R0 `__","LWG","Output std::chrono::days with 'd' suffix","Cologne","","" -"`P1651R0 `__","LWG","bind_front should not unwrap reference_wrapper","Cologne","|Complete|","13.0" -"`P1652R1 `__","LWG","Printf corner cases in std::format","Cologne","|Complete|","14.0" -"`P1661R1 `__","LWG","Remove dedicated precalculated hash lookup interface","Cologne","|Nothing To Do|","" -"`P1754R1 `__","LWG","Rename concepts to standard_case for C++20, while we still can","Cologne","|In Progress|","" +"`P0325 `__","LWG","to_array from LFTS with updates","Cologne","|Complete|","10.0" +"`P0408 `__","LWG","Efficient Access to basic_stringbuf's Buffer","Cologne","","" +"`P0466 `__","LWG","Layout-compatibility and Pointer-interconvertibility Traits","Cologne","","" +"`P0553 `__","LWG","Bit operations","Cologne","|Complete|","9.0" +"`P0631 `__","LWG","Math Constants","Cologne","|Complete|","11.0" +"`P0645 `__","LWG","Text Formatting","Cologne","|In Progress|","" +"`P0660 `__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","","" +"`P0784 `__","CWG","More constexpr containers","Cologne","|Complete|","12.0" +"`P0980 `__","LWG","Making std::string constexpr","Cologne","","" +"`P1004 `__","LWG","Making std::vector constexpr","Cologne","","" +"`P1035 `__","LWG","Input Range Adaptors","Cologne","","" +"`P1065 `__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0" +"`P1135 `__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0" +"`P1207 `__","LWG","Movability of Single-pass Iterators","Cologne","","" +"`P1208 `__","LWG","Adopt source_location for C++20","Cologne","","" +"`P1355 `__","LWG","Exposing a narrow contract for ceil2","Cologne","|Complete|","9.0" +"`P1361 `__","LWG","Integration of chrono with text formatting","Cologne","","" +"`P1423 `__","LWG","char8_t backward compatibility remediation","Cologne","|In Progress|","" +"`P1424 `__","LWG","'constexpr' feature macro concerns","Cologne","Superseded by `P1902 `__","" +"`P1466 `__","LWG","Miscellaneous minor fixes for chrono","Cologne","","" +"`P1474 `__","LWG","Helpful pointers for ContiguousIterator","Cologne","","" +"`P1502 `__","LWG","Standard library header units for C++20","Cologne","","" +"`P1522 `__","LWG","Iterator Difference Type and Integer Overflow","Cologne","","" +"`P1523 `__","LWG","Views and Size Types","Cologne","","" +"`P1612 `__","LWG","Relocate Endian's Specification","Cologne","|Complete|","10.0" +"`P1614 `__","LWG","The Mothership has Landed","Cologne","|In Progress|","" +"`P1638 `__","LWG","basic_istream_view::iterator should not be copyable","Cologne","","" +"`P1643 `__","LWG","Add wait/notify to atomic_ref","Cologne","","" +"`P1644 `__","LWG","Add wait/notify to atomic","Cologne","","" +"`P1650 `__","LWG","Output std::chrono::days with 'd' suffix","Cologne","","" +"`P1651 `__","LWG","bind_front should not unwrap reference_wrapper","Cologne","|Complete|","13.0" +"`P1652 `__","LWG","Printf corner cases in std::format","Cologne","","" +"`P1661 `__","LWG","Remove dedicated precalculated hash lookup interface","Cologne","|Nothing To Do|","" +"`P1754 `__","LWG","Rename concepts to standard_case for C++20, while we still can","Cologne","|In Progress|","" "","","","","","" -"`P0883R2 `__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]_","14.0" -"`P1391R4 `__","LWG","Range constructor for std::string_view","Belfast","|Complete|","14.0" -"`P1394R4 `__","LWG","Range constructor for std::span","Belfast","|Complete|","14.0" -"`P1456R1 `__","LWG","Move-only views","Belfast","* *","" -"`P1622R3 `__","LWG","Mandating the Standard Library: Clause 32 - Thread support library","Belfast","* *","" -"`P1645R1 `__","LWG","constexpr for numeric algorithms","Belfast","|Complete|","12.0" -"`P1686R2 `__","LWG","Mandating the Standard Library: Clause 27 - Time library","Belfast","* *","" -"`P1690R1 `__","LWG","Refinement Proposal for P0919 Heterogeneous lookup for unordered containers","Belfast","|Complete|","12.0" -"`P1716R3 `__","LWG","ranges compare algorithm are over-constrained","Belfast","* *","" -"`P1718R2 `__","LWG","Mandating the Standard Library: Clause 25 - Algorithms library","Belfast","* *","" -"`P1719R2 `__","LWG","Mandating the Standard Library: Clause 26 - Numerics library","Belfast","* *","" -"`P1720R2 `__","LWG","Mandating the Standard Library: Clause 28 - Localization library","Belfast","* *","" -"`P1721R2 `__","LWG","Mandating the Standard Library: Clause 29 - Input/Output library","Belfast","* *","" -"`P1722R2 `__","LWG","Mandating the Standard Library: Clause 30 - Regular Expression library","Belfast","* *","" -"`P1723R2 `__","LWG","Mandating the Standard Library: Clause 31 - Atomics library","Belfast","* *","" -"`P1855R0 `__","LWG","Make ````\ freestanding","Belfast","* *","" -"`P1862R1 `__","LWG","Ranges adaptors for non-copyable iterators","Belfast","* *","" -"`P1865R1 `__","LWG","Add max() to latch and barrier","Belfast","|Complete|","11.0" -"`P1869R1 `__","LWG","Rename 'condition_variable_any' interruptible wait methods","Belfast","* *","" -"`P1870R1 `__","LWG","forwarding-range is too subtle","Belfast","|In Progress|","" -"`P1871R1 `__","LWG","Should concepts be enabled or disabled?","Belfast","|Complete|","14.0" -"`P1872R0 `__","LWG","span should have size_type, not index_type","Belfast","|Complete|","10.0" -"`P1878R1 `__","LWG","Constraining Readable Types","Belfast","* *","" -"`P1892R1 `__","LWG","Extended locale-specific presentation specifiers for std::format","Belfast","|Complete|","14.0" -"`P1902R1 `__","LWG","Missing feature-test macros 2018-2019","Belfast","* *","" -"`P1959R0 `__","LWG","Remove std::weak_equality and std::strong_equality","Belfast","* *","" -"`P1960R0 `__","LWG","NB Comment Changes Reviewed by SG1","Belfast","* *","" -"`P1961R0 `__","LWG","Harmonizing the definitions of total order for pointers","Belfast","* *","" -"`P1965R0 `__","LWG","Blanket Wording for Specifying ""Hidden Friends""","Belfast","* *","" +"`P0883 `__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]_","13.0" +"`P1391 `__","LWG","Range constructor for std::string_view","Belfast","* *","" +"`P1394 `__","LWG","Range constructor for std::span","Belfast","* *","" +"`P1456 `__","LWG","Move-only views","Belfast","* *","" +"`P1622 `__","LWG","Mandating the Standard Library: Clause 32 - Thread support library","Belfast","* *","" +"`P1645 `__","LWG","constexpr for numeric algorithms","Belfast","|Complete|","12.0" +"`P1664 `__","LWG","reconstructible_range - a concept for putting ranges back together","Belfast","* *","" +"`P1686 `__","LWG","Mandating the Standard Library: Clause 27 - Time library","Belfast","* *","" +"`P1690 `__","LWG","Refinement Proposal for P0919 Heterogeneous lookup for unordered containers","Belfast","|Complete|","12.0" +"`P1716 `__","LWG","ranges compare algorithm are over-constrained","Belfast","* *","" +"`P1718 `__","LWG","Mandating the Standard Library: Clause 25 - Algorithms library","Belfast","* *","" +"`P1719 `__","LWG","Mandating the Standard Library: Clause 26 - Numerics library","Belfast","* *","" +"`P1720 `__","LWG","Mandating the Standard Library: Clause 28 - Localization library","Belfast","* *","" +"`P1721 `__","LWG","Mandating the Standard Library: Clause 29 - Input/Output library","Belfast","* *","" +"`P1722 `__","LWG","Mandating the Standard Library: Clause 30 - Regular Expression library","Belfast","* *","" +"`P1723 `__","LWG","Mandating the Standard Library: Clause 31 - Atomics library","Belfast","* *","" +"`P1855 `__","LWG","Make ````\ freestanding","Belfast","* *","" +"`P1862 `__","LWG","Ranges adaptors for non-copyable iterators","Belfast","* *","" +"`P1865 `__","LWG","Add max() to latch and barrier","Belfast","|Complete|","11.0" +"`P1869 `__","LWG","Rename 'condition_variable_any' interruptible wait methods","Belfast","* *","" +"`P1870 `__","LWG","forwarding-range is too subtle","Belfast","|In Progress|","" +"`P1871 `__","LWG","Should concepts be enabled or disabled?","Belfast","* *","" +"`P1872 `__","LWG","span should have size_type, not index_type","Belfast","|Complete|","10.0" +"`P1878 `__","LWG","Constraining Readable Types","Belfast","* *","" +"`P1892 `__","LWG","Extended locale-specific presentation specifiers for std::format","Belfast","* *","" +"`P1902 `__","LWG","Missing feature-test macros 2018-2019","Belfast","* *","" +"`P1959 `__","LWG","Remove std::weak_equality and std::strong_equality","Belfast","* *","" +"`P1960 `__","LWG","NB Comment Changes Reviewed by SG1","Belfast","* *","" +"`P1961 `__","LWG","Harmonizing the definitions of total order for pointers","Belfast","* *","" +"`P1965 `__","LWG","Blanket Wording for Specifying ""Hidden Friends""","Belfast","* *","" "","","","","","" -"`P0586R2 `__","LWG","Safe integral comparisons","Prague","|Complete|","13.0" -"`P0593R6 `__","CWG","Implicit creation of objects for low-level object manipulation","Prague","* *","" -"`P1115R3 `__","LWG","Improving the Return Value of Erase-Like Algorithms II: Free erase/erase if","Prague","|Complete|","11.0" -"`P1243R4 `__","LWG","Rangify New Algorithms","Prague","* *","" -"`P1460R1 `__","LWG","Mandating the Standard Library: Clause 20 - Utilities library","Prague","* *","" -"`P1739R4 `__","LWG","Avoid template bloat for safe_ranges in combination with ""subrange-y"" view adaptors","Prague","* *","" -"`P1831R1 `__","LWG","Deprecating volatile: library","Prague","* *","" -"`P1868R2 `__","LWG","width: clarifying units of width and precision in std::format","Prague","|Complete|","14.0" -"`P1908R1 `__","CWG","Reserving Attribute Namespaces for Future Use","Prague","* *","" -"`P1937R2 `__","CWG","Fixing inconsistencies between constexpr and consteval functions","Prague","* *","" -"`P1956R1 `__","LWG","On the names of low-level bit manipulation functions","Prague","|Complete|","12.0" -"`P1957R2 `__","CWG","Converting from ``T*``\ to bool should be considered narrowing (re: US 212)","Prague","* *","" -"`P1963R0 `__","LWG","Fixing US 313","Prague","* *","" -"`P1964R2 `__","LWG","Wording for boolean-testable","Prague","|Complete|","13.0" -"`P1970R2 `__","LWG","Consistency for size() functions: Add ranges::ssize","Prague","* *","" -"`P1973R1 `__","LWG","Rename ""_default_init"" Functions, Rev1","Prague","* *","" -"`P1976R2 `__","LWG","Fixed-size span construction from dynamic range","Prague","|Complete|","11.0" -"`P1981R0 `__","LWG","Rename leap to leap_second","Prague","* *","" -"`P1982R0 `__","LWG","Rename link to time_zone_link","Prague","* *","" -"`P1983R0 `__","LWG","Wording for GB301, US296, US292, US291, and US283","Prague","* *","" -"`P1994R1 `__","LWG","elements_view needs its own sentinel","Prague","* *","" -"`P2002R1 `__","CWG","Defaulted comparison specification cleanups","Prague","* *","" -"`P2045R1 `__","LWG","Missing Mandates for the standard library","Prague","* *","" -"`P2085R0 `__","CWG","Consistent defaulted comparisons","Prague","* *","" -"`P2091R0 `__","LWG","Issues with range access CPOs","Prague","* *","" -"`P2101R0 `__","LWG","'Models' subsumes 'satisfies' (Wording for US298 and US300)","Prague","* *","" -"`P2102R0 `__","LWG","Make 'implicit expression variations' more explicit (Wording for US185)","Prague","* *","" -"`P2106R0 `__","LWG","Alternative wording for GB315 and GB316","Prague","* *","" -"`P2116R0 `__","LWG","Remove tuple-like protocol support from fixed-extent span","Prague","|Complete|","11.0" -"","","","","","" -"`P2231R1 `__","LWG","Missing constexpr in std::optional and std::variant","June 2021","|In progress|","13.0" -"`P2325R3 `__","LWG","Views should not be required to be default constructible","June 2021","|In progress|","" +"`P0586 `__","LWG","Safe integral comparisons","Prague","|Complete|","13.0" +"`P0593 `__","CWG","Implicit creation of objects for low-level object manipulation","Prague","* *","" +"`P1115 `__","LWG","Improving the Return Value of Erase-Like Algorithms II: Free erase/erase if","Prague","|Complete|","11.0" +"`P1243 `__","LWG","Rangify New Algorithms","Prague","* *","" +"`P1460 `__","LWG","Mandating the Standard Library: Clause 20 - Utilities library","Prague","* *","" +"`P1739 `__","LWG","Avoid template bloat for safe_ranges in combination with ""subrange-y"" view adaptors","Prague","* *","" +"`P1831 `__","LWG","Deprecating volatile: library","Prague","* *","" +"`P1868 `__","LWG","width: clarifying units of width and precision in std::format","Prague","* *","" +"`P1908 `__","CWG","Reserving Attribute Namespaces for Future Use","Prague","* *","" +"`P1937 `__","CWG","Fixing inconsistencies between constexpr and consteval functions","Prague","* *","" +"`P1956 `__","LWG","On the names of low-level bit manipulation functions","Prague","|Complete|","12.0" +"`P1957 `__","CWG","Converting from ``T*``\ to bool should be considered narrowing (re: US 212)","Prague","* *","" +"`P1963 `__","LWG","Fixing US 313","Prague","* *","" +"`P1964 `__","LWG","Wording for boolean-testable","Prague","|Complete|","13.0" +"`P1970 `__","LWG","Consistency for size() functions: Add ranges::ssize","Prague","* *","" +"`P1973 `__","LWG","Rename ""_default_init"" Functions, Rev1","Prague","* *","" +"`P1976 `__","LWG","Fixed-size span construction from dynamic range","Prague","|Complete|","11.0" +"`P1981 `__","LWG","Rename leap to leap_second","Prague","* *","" +"`P1982 `__","LWG","Rename link to time_zone_link","Prague","* *","" +"`P1983 `__","LWG","Wording for GB301, US296, US292, US291, and US283","Prague","* *","" +"`P1994 `__","LWG","elements_view needs its own sentinel","Prague","* *","" +"`P2002 `__","CWG","Defaulted comparison specification cleanups","Prague","* *","" +"`P2045 `__","LWG","Missing Mandates for the standard library","Prague","* *","" +"`P2085 `__","CWG","Consistent defaulted comparisons","Prague","* *","" +"`P2091 `__","LWG","Issues with range access CPOs","Prague","* *","" +"`P2101 `__","LWG","'Models' subsumes 'satisfies' (Wording for US298 and US300)","Prague","* *","" +"`P2102 `__","LWG","Make 'implicit expression variations' more explicit (Wording for US185)","Prague","* *","" +"`P2106 `__","LWG","Alternative wording for GB315 and GB316","Prague","* *","" +"`P2116 `__","LWG","Remove tuple-like protocol support from fixed-extent span","Prague","|Complete|","11.0" +"`P2231 `__","LWG","Missing constexpr in std::optional and std::variant","February 2021","|In progress|","13.0" +"`P2325 `__","LWG","Views should not be required to be default constructible","June 2021","|In progress|","" "`P2210R2 `__","LWG",Superior String Splitting,"June 2021","","" -"`P2216R3 `__","LWG",std::format improvements,"June 2021","|Partial|","" -"`P2281R1 `__","LWG",Clarifying range adaptor objects,"June 2021","|Complete|","14.0" +"`P2216R3 `__","LWG",std::format improvements,"June 2021","","" +"`P2281R1 `__","LWG",Clarifying range adaptor objects,"June 2021","","" "`P2328R1 `__","LWG",join_view should join all views of ranges,"June 2021","","" -"`P2367R0 `__","LWG",Remove misuses of list-initialization from Clause 24,"June 2021","","" -"","","","","","" -"`P2372R3 `__","LWG","Fixing locale handling in chrono formatters","October 2021","","" -"`P2415R2 `__","LWG","What is a ``view``","October 2021","|Complete|","14.0" -"`P2418R2 `__","LWG","Add support for ``std::generator``-like types to ``std::format``","October 2021","","" -"`P2432R1 `__","LWG","Fix ``istream_view``","October 2021","","" +"`P2367R0 `__","LWG",Remove misuses of list-initialization from Clause 24,"June 2021","","" \ No newline at end of file diff --git a/docs/Status/Cxx2b.rst b/docs/Status/Cxx2b.rst index de8916293..cdd1b9c2e 100644 --- a/docs/Status/Cxx2b.rst +++ b/docs/Status/Cxx2b.rst @@ -1,48 +1,50 @@ -.. _cxx2b-status: - -================================ -libc++ C++2b Status -================================ - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - - -Overview -================================ - -In November 2020, the C++ standard committee adopted the first changes to the next version of the C++ standard, known here as "C++2b" (probably to be C++23). - -This page shows the status of libc++; the status of clang's support of the language features is `here `__. - -.. attention:: Features in unreleased drafts of the standard are subject to change. - -The groups that have contributed papers: - -- CWG - Core Language Working group -- LWG - Library working group -- SG1 - Study group #1 (Concurrency working group) - -.. note:: "Nothing to do" means that no library changes were needed to implement this change. - -.. _paper-status-cxx2b: - -Paper Status -==================================== - -.. csv-table:: - :file: Cxx2bPapers.csv - :header-rows: 1 - :widths: auto - -.. _issues-status-cxx2b: - -Library Working Group Issues Status -==================================== - -.. csv-table:: - :file: Cxx2bIssues.csv - :header-rows: 1 - :widths: auto +.. _cxx2b-status: + +================================ +libc++ C++2b Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In November 2020, the C++ standard committee adopted the first changes to the next version of the C++ standard, known here as "C++2b" (probably to be C++23). + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx2b: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx2bPapers.csv + :header-rows: 1 + :widths: auto + +.. _issues-status-cxx2b: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx2bIssues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 22-July-2021 diff --git a/docs/Status/Cxx2bIssues.csv b/docs/Status/Cxx2bIssues.csv index bcbfe4402..3e745c599 100644 --- a/docs/Status/Cxx2bIssues.csv +++ b/docs/Status/Cxx2bIssues.csv @@ -1,141 +1,99 @@ -"Issue #","Issue Name","Meeting","Status","First released version","Labels" -"`2839 `__","Self-move-assignment of library types, again","November 2020","|Nothing To Do|","" +"Issue #","Issue Name","Meeting","Status","First released version" +"`2839 `__","Self-move-assignment of library types, again","November 2020","","" "`3117 `__","Missing ``packaged_task`` deduction guides","November 2020","","" "`3143 `__","``monotonic_buffer_resource`` growth policy is unclear","November 2020","","" -"`3195 `__","What is the stored pointer value of an empty ``weak_ptr``?","November 2020","|Nothing To Do|","" -"`3211 `__","``std::tuple<>`` should be trivially constructible","November 2020","|Complete|","9.0" -"`3236 `__","Random access iterator requirements lack limiting relational operators domain to comparing those from the same range","November 2020","|Nothing To Do|","","|ranges|" +"`3195 `__","What is the stored pointer value of an empty weak_ptr?","November 2020","","" +"`3211 `__","``std::tuple<>`` should be trivially constructible","November 2020","","" +"`3236 `__","Random access iterator requirements lack limiting relational operators domain to comparing those from the same range","November 2020","","" "`3265 `__","``move_iterator``'s conversions are more broken after P1207","November 2020","Fixed by `LWG3435 `__","" "`3435 `__","``three_way_comparable_with, reverse_iterator>``","November 2020","|Complete|","13.0" -"`3432 `__","Missing requirement for ``comparison_category``","November 2020","","","|spaceship|" -"`3447 `__","Deduction guides for ``take_view`` and ``drop_view`` have different constraints","November 2020","|Complete|","14.0" -"`3450 `__","The const overloads of ``take_while_view::begin/end`` are underconstrained","November 2020","","","|ranges|" +"`3432 `__","Missing requirement for comparison_category","November 2020","","" +"`3447 `__","Deduction guides for ``take_view`` and ``drop_view`` have different constraints","November 2020","","" +"`3450 `__","The const overloads of ``take_while_view::begin/end`` are underconstrained","November 2020","","" "`3464 `__","``istream::gcount()`` can overflow","November 2020","","" -"`2731 `__","Existence of ``lock_guard::mutex_type`` typedef unclear","November 2020","|Complete|","5.0" -"`2743 `__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","November 2020","|Nothing To Do|","" -"`2820 `__","Clarify ```` macros","November 2020","|Nothing To Do|","" +"`2731 `__","Existence of ``lock_guard::mutex_type`` typedef unclear","November 2020","","" +"`2743 `__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","November 2020","","" +"`2820 `__","Clarify ```` macros","November 2020","","" "`3120 `__","Unclear behavior of ``monotonic_buffer_resource::release()``","November 2020","","" "`3170 `__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","November 2020","","" "`3036 `__","``polymorphic_allocator::destroy`` is extraneous","November 2020","","" -"`3171 `__","LWG2989 breaks ``directory_entry`` stream insertion","November 2020","|Complete|","14.0" -"`3306 `__","``ranges::advance`` violates its preconditions","November 2020","|Complete|","14.0","|ranges|" -"`3403 `__","Domain of ``ranges::ssize(E)`` doesn't ``match ranges::size(E)``","November 2020","","","|ranges|" -"`3404 `__","Finish removing subrange's conversions from pair-like","November 2020","","","|ranges|" -"`3405 `__","``common_view``'s converting constructor is bad, too","November 2020","|Complete|","14.0","|ranges|" -"`3406 `__","``elements_view::begin()`` and ``elements_view::end()`` have incompatible constraints","November 2020","","","|ranges|" -"`3419 `__","[algorithms.requirements]/15 doesn't reserve as many rights as it intends to","November 2020","|Nothing To Do|","" -"`3420 `__","cpp17-iterator should check that the type looks like an iterator first","November 2020","|Complete|","14.0","|ranges|" -"`3421 `__","Imperfect ADL emulation for boolean-testable","November 2020","|Nothing To Do|","","|ranges|" -"`3425 `__","``condition_variable_any`` fails to constrain its Lock parameters","November 2020","|Nothing To Do|","" -"`3426 `__","``operator<=>(const unique_ptr&, nullptr_t)`` can't get no satisfaction","November 2020","","","|spaceship|" -"`3427 `__","``operator<=>(const shared_ptr&, nullptr_t)`` definition ill-formed","November 2020","","","|spaceship|" -"`3428 `__","``single_view``'s in place constructor should be explicit","November 2020","|Complete|","14.0","|ranges|" -"`3434 `__","``ios_base`` never reclaims memory for iarray and parray","November 2020","|Nothing To Do|","" -"`3437 `__","``__cpp_lib_polymorphic_allocator`` is in the wrong header","November 2020","|Complete|","14.0" -"`3446 `__","``indirectly_readable_traits`` ambiguity for types with both ``value_type`` and ``element_type``","November 2020","|Complete|","14.0","|ranges|" -"`3448 `__","``transform_view``'s ``sentinel`` not comparable with ``iterator``","November 2020","","","|ranges|" -"`3449 `__","``take_view`` and ``take_while_view``'s ``sentinel`` not comparable with their ``const iterator``","November 2020","","","|ranges|" -"`3453 `__","Generic code cannot call ``ranges::advance(i, s)``","November 2020","|Nothing To Do|","","|ranges|" +"`3171 `__","LWG2989 breaks ``directory_entry`` stream insertion","November 2020","","" +"`3306 `__","``ranges::advance`` violates its preconditions","November 2020","","" +"`3403 `__","Domain of ``ranges::ssize(E)`` doesn't ``match ranges::size(E)``","November 2020","","" +"`3404 `__","Finish removing subrange's conversions from pair-like","November 2020","","" +"`3405 `__","``common_view``'s converting constructor is bad, too","November 2020","","" +"`3406 `__","``elements_view::begin()`` and ``elements_view::end()`` have incompatible constraints","November 2020","","" +"`3419 `__","[algorithms.requirements]/15 doesn't reserve as many rights as it intends to","November 2020","","" +"`3420 `__","cpp17-iterator should check that the type looks like an iterator first","November 2020","","" +"`3421 `__","Imperfect ADL emulation for boolean-testable","November 2020","","" +"`3425 `__","``condition_variable_any`` fails to constrain its Lock parameters","November 2020","","" +"`3426 `__","``operator<=>(const unique_ptr&, nullptr_t)`` can't get no satisfaction","November 2020","","" +"`3427 `__","``operator<=>(const shared_ptr&, nullptr_t)`` definition ill-formed","November 2020","","" +"`3428 `__","``single_view``'s in place constructor should be explicit","November 2020","","" +"`3434 `__","``ios_base`` never reclaims memory for iarray and parray","November 2020","","" +"`3437 `__","``__cpp_lib_polymorphic_allocator`` is in the wrong header","November 2020","","" +"`3446 `__","``indirectly_readable_traits`` ambiguity for types with both ``value_type`` and ``element_type``","November 2020","","" +"`3448 `__","``transform_view``'s sentinel not comparable with ``iterator``","November 2020","","" +"`3449 `__","take_view and take_while_view's ``sentinel`` not comparable with their const iterator","November 2020","","" +"`3453 `__","Generic code cannot call ``ranges::advance(i, s)``","November 2020","","" "`3455 `__","Incorrect Postconditions on ``unique_ptr`` move assignment","November 2020","|Nothing To Do|","" -"`3460 `__","Unimplementable ``noop_coroutine_handle`` guarantees","November 2020","|Complete|","14.0" -"`3461 `__","``convertible_to``'s description mishandles cv-qualified ``void``","November 2020","|Nothing To Do|","" -"`3465 `__","``compare_partial_order_fallback`` requires ``F < E``","November 2020","|Complete|","14.0","|spaceship|" -"`3466 `__","Specify the requirements for ``promise``/``future``/``shared_future`` consistently","November 2020","|Nothing To Do|","" -"`3467 `__","``bool`` can't be an integer-like type","November 2020","|Complete|","14.0" -"`3472 `__","``counted_iterator`` is missing preconditions","November 2020","|Complete|","14.0","|ranges|" -"`3473 `__","Normative encouragement in non-normative note","November 2020","|Nothing To Do|","","|format|" -"`3474 `__","Nesting ``join_views`` is broken because of CTAD","November 2020","","","|ranges|" +"`3460 `__","Unimplementable ``noop_coroutine_handle`` guarantees","November 2020","","" +"`3461 `__","``convertible_to``'s description mishandles cv-qualified void","November 2020","","" +"`3465 `__","compare_partial_order_fallback requires ``F < E``","November 2020","","" +"`3466 `__","Specify the requirements for ``promise``/``future``/``shared_future`` consistently","November 2020","","" +"`3467 `__","``bool`` can't be an integer-like type","November 2020","","" +"`3472 `__","``counted_iterator`` is missing preconditions","November 2020","","" +"`3473 `__","Normative encouragement in non-normative note","November 2020","","" +"`3474 `__","Nesting ``join_views`` is broken because of CTAD","November 2020","","" "`3476 `__","``thread`` and ``jthread`` constructors require that the parameters be move-constructible but never move construct the parameters","November 2020","","" -"`3477 `__","Simplify constraints for ``semiregular-box``","November 2020","","","|ranges|" -"`3482 `__","``drop_view``'s const begin should additionally require ``sized_range``","November 2020","|Complete|","14.0","|ranges|" -"`3483 `__","``transform_view::iterator``'s difference is overconstrained","November 2020","|Complete|","14.0","|ranges|" +"`3477 `__","Simplify constraints for semiregular-box","November 2020","","" +"`3482 `__","``drop_view``'s const begin should additionally require sized_range","November 2020","","" +"`3483 `__","``transform_view::iterator``'s difference is overconstrained","November 2020","","" "","","","","" -"`3391 `__","Problems with ``counted_iterator``/``move_iterator::base() const &``","February 2021","","","|ranges|" -"`3433 `__","``subrange::advance(n)`` has UB when ``n < 0``","February 2021","|Complete|","14.0","|ranges|" -"`3490 `__","``ranges::drop_while_view::begin()`` is missing a precondition","February 2021","|Nothing To Do|","","|ranges|" -"`3492 `__","Minimal improvements to ``elements_view::iterator``","February 2021","","","|ranges|" -"`3494 `__","Allow ranges to be conditionally borrowed","February 2021","Superseded by `P2017R1 `__","","|ranges|" -"`3495 `__","``constexpr launder`` makes pointers to inactive members of unions usable","February 2021","|Nothing To Do|","" -"`3500 `__","``join_view::iterator::operator->()`` is bogus","February 2021","","","|ranges|" -"`3502 `__","``elements_view`` should not be allowed to return dangling reference","February 2021","","","|ranges|" -"`3505 `__","``split_view::outer-iterator::operator++`` misspecified","February 2021","","","|ranges|" +"`3391 `__","Problems with ``counted_iterator``/``move_iterator::base() const &``","February 2021","","" +"`3433 `__","``subrange::advance(n)`` has UB when ``n < 0``","February 2021","","" +"`3490 `__","``ranges::drop_while_view::begin()`` is missing a precondition","February 2021","","" +"`3492 `__","Minimal improvements to ``elements_view::iterator``","February 2021","","" +"`3494 `__","Allow ranges to be conditionally borrowed","February 2021","Superseded by `P2017R1 `__","" +"`3495 `__","``constexpr launder`` makes pointers to inactive members of unions usable","February 2021","","" +"`3500 `__","``join_view::iterator::operator->()`` is bogus","February 2021","","" +"`3502 `__","``elements_view`` should not be allowed to return dangling reference","February 2021","","" +"`3505 `__","``split_view::outer-iterator::operator++`` misspecified","February 2021","","" "","","","","" `2774 `__,"``std::function`` construction vs assignment","June 2021","","" -`2818 `__,"``::std::`` everywhere rule needs tweaking","June 2021","|Nothing To Do|","" +`2818 `__,"``::std::`` everywhere rule needs tweaking","June 2021","","" `2997 `__,"LWG 491 and the specification of ``{forward_,}list::unique``","June 2021","","" -`3410 `__,"``lexicographical_compare_three_way`` is overspecified","June 2021","","","|spaceship|" +`3410 `__,"``lexicographical_compare_three_way`` is overspecified","June 2021","","" `3430 `__,"``std::fstream`` & co. should be constructible from string_view","June 2021","","" -`3462 `__,"§[formatter.requirements]: Formatter requirements forbid use of ``fc.arg()``","June 2021","","","|format|" -`3481 `__,"``viewable_range`` mishandles lvalue move-only views","June 2021","Superseded by `P2415R2 `__","","|ranges|" -`3506 `__,"Missing allocator-extended constructors for ``priority_queue``","June 2021","|Complete|","14.0" -`3517 `__,"``join_view::iterator``'s ``iter_swap`` is underconstrained","June 2021","","","|ranges|" -`3518 `__,"Exception requirements on char trait operations unclear","June 2021","|Nothing To Do|","" -`3519 `__,"Incomplete synopses for ```` classes","June 2021","","" -`3520 `__,"``iter_move`` and ``iter_swap`` are inconsistent for ``transform_view::iterator``","June 2021","|Complete|","14.0","|ranges|" -`3521 `__,"Overly strict requirements on ``qsort`` and ``bsearch``","June 2021","|Nothing To Do|","" -`3522 `__,"Missing requirement on ``InputIterator`` template parameter for ``priority_queue`` constructors","June 2021","|Complete|","14.0","|ranges|" -`3523 `__,"``iota_view::sentinel`` is not always ``iota_view``'s sentinel","June 2021","","","|ranges|" +`3462 `__,"§[formatter.requirements]: Formatter requirements forbid use of ``fc.arg()``","June 2021","","" +`3481 `__,"``viewable_range`` mishandles lvalue move-only views","June 2021","","" +`3506 `__,"Missing allocator-extended constructors for ``priority_queue``","June 2021","","" +`3517 `__,"``join_view::iterator``'s ``iter_swap`` is underconstrained","June 2021","","" +`3518 `__,"Exception requirements on char trait operations unclear","June 2021","","" +`3519 `__,"Incomplete synopses for classes","June 2021","","" +`3520 `__,"``iter_move`` and ``iter_swap`` are inconsistent for ``transform_view::iterator``","June 2021","","" +`3521 `__,"Overly strict requirements on ``qsort`` and ``bsearch``","June 2021","","" +`3522 `__,"Missing requirement on ``InputIterator`` template parameter for ``priority_queue`` constructors","June 2021","","" +`3523 `__,"``iota_view::sentinel`` is not always ``iota_view``'s sentinel","June 2021","","" `3526 `__,"Return types of ``uses_allocator_construction_args`` unspecified","June 2021","","" `3527 `__,"``uses_allocator_construction_args`` handles rvalue pairs of rvalue references incorrectly","June 2021","","" `3528 `__,"``make_from_tuple`` can perform (the equivalent of) a C-style cast","June 2021","","" -`3529 `__,"``priority_queue(first, last)`` should construct ``c`` with ``(first, last)``","June 2021","|Complete|","14.0" +`3529 `__,"``priority_queue(first, last)`` should construct ``c`` with ``(first, last)``","June 2021","","" `3530 `__,"``BUILTIN-PTR-MEOW`` should not opt the type out of syntactic checks","June 2021","","" -`3532 `__,"``split_view::inner-iterator::operator++(int)`` should depend on ``Base``","June 2021","","","|ranges|" -`3533 `__,"Make ``base() const &`` consistent across iterator wrappers that supports ``input_iterators``","June 2021","|Complete|","14.0","|ranges|" -`3536 `__,"Should ``chrono::from_stream()`` assign zero to duration for failure?","June 2021","","","|chrono|" -`3539 `__,"``format_to`` must not copy models of ``output_iterator``","June 2021","","","|format|" -`3540 `__,"§[format.arg] There should be no const in ``basic_format_arg(const T* p)``","June 2021","|Complete|","14.0","|format|" -`3541 `__,"``indirectly_readable_traits`` should be SFINAE-friendly for all types","June 2021","|Complete|","14.0","|ranges|" -`3542 `__,"``basic_format_arg`` mishandles ``basic_string_view`` with custom traits","June 2021","|Complete|","14.0","|format|" -`3543 `__,"Definition of when ``counted_iterators`` refer to the same sequence isn't quite right","June 2021","|Nothing To Do|","","|ranges|" -`3544 `__,"``format-arg-store::args`` is unintentionally not exposition-only","June 2021","|Complete|","14.0","|format|" -`3546 `__,"``common_iterator``'s postfix-proxy is not quite right","June 2021","","","|ranges|" +`3532 `__,"``split_view::inner-iterator::operator++(int)`` should depend on ``Base``","June 2021","","" +`3533 `__,"Make ``base() const &`` consistent across iterator wrappers that supports ``input_iterators``","June 2021","","" +`3536 `__,"Should ``chrono::from_stream()`` assign zero to duration for failure?","June 2021","","" +`3539 `__,"``format_to`` must not copy models of ``output_iterator``","June 2021","","" +`3540 `__,"§[format.arg] There should be no const in ``basic_format_arg(const T* p)``","June 2021","","" +`3541 `__,"``indirectly_readable_traits`` should be SFINAE-friendly for all types","June 2021","","" +`3542 `__,"``basic_format_arg`` mishandles ``basic_string_view`` with custom traits","June 2021","","" +`3543 `__,"Definition of when ``counted_iterators`` refer to the same sequence isn't quite right","June 2021","","" +`3544 `__,"``format-arg-store::args`` is unintentionally not exposition-only","June 2021","","" +`3546 `__,"``common_iterator``'s postfix-proxy is not quite right","June 2021","","" `3548 `__,"``shared_ptr`` construction from ``unique_ptr`` should move (not copy) the deleter","June 2021","","" -`3549 `__,"``view_interface`` is overspecified to derive from ``view_base``","June 2021","|Complete|","14.0","|ranges|" -`3551 `__,"``borrowed_{iterator,subrange}_t`` are overspecified","June 2021","|Nothing To Do|","","|ranges|" +`3549 `__,"``view_interface`` is overspecified to derive from ``view_base``","June 2021","","" +`3551 `__,"``borrowed_{iterator,subrange}_t`` are overspecified","June 2021","","" `3552 `__,"Parallel specialized memory algorithms should require forward iterators","June 2021","","" -`3553 `__,"Useless constraint in ``split_view::outer-iterator::value_type::begin()``","June 2021","","","|ranges|" -`3555 `__,"``{transform,elements}_view::iterator::iterator_concept`` should consider const-qualification of the underlying range","June 2021","","","|ranges|" -"","","","","" -`2191 `__,"Incorrect specification of ``match_results(match_results&&)``","October 2021","|Nothing To Do|","" -`2381 `__,"Inconsistency in parsing floating point numbers","October 2021","","" -`2762 `__,"``unique_ptr operator*()`` should be ``noexcept``","October 2021","","" -`3121 `__,"``tuple`` constructor constraints for ``UTypes&&...`` overloads","October 2021","","" -`3123 `__,"``duration`` constructor from representation shouldn't be effectively non-throwing","October 2021","","","|chrono|" -`3146 `__,"Excessive unwrapping in ``std::ref/cref``","October 2021","|Complete|","14.0" -`3152 `__,"``common_type`` and ``common_reference`` have flaws in common","October 2021","","" -`3293 `__,"``move_iterator operator+()`` has incorrect constraints","October 2021","","","|ranges|" -`3361 `__,"``safe_range`` case","October 2021","|Nothing To Do|","","|ranges|" -`3392 `__,"``ranges::distance()`` cannot be used on a move-only iterator with a sized sentinel","October 2021","|Complete|","14.0","|ranges|" -`3407 `__,"Some problems with the wording changes of P1739R4","October 2021","","","|ranges|" -`3422 `__,"Issues of ``seed_seq``'s constructors","October 2021","|Complete|","14.0" -`3470 `__,"``convertible-to-non-slicing`` seems to reject valid case","October 2021","|Complete|","14.0","|ranges|" -`3480 `__,"``directory_iterator`` and ``recursive_directory_iterator`` are not C++20 ranges","October 2021","|Complete|","14.0","|ranges|" -`3498 `__,"Inconsistent ``noexcept``-specifiers for ``basic_syncbuf``","October 2021","","" -`3535 `__,"``join_view::iterator::iterator_category`` and ``::iterator_concept`` lie","October 2021","","","|ranges|" -`3554 `__,"``chrono::parse`` needs ``const charT*`` and ``basic_string_view`` overloads","October 2021","","","|chrono|" -`3557 `__,"The ``static_cast`` expression in ``convertible_to`` has the wrong operand","October 2021","|Complete|","14.0" -`3559 `__,"Semantic requirements of ``sized_range`` is circular","October 2021","|Nothing To Do|","","|ranges|" -`3560 `__,"``ranges::equal`` and ``ranges::is_permutation`` should short-circuit for ``sized_ranges``","October 2021","","","|ranges|" -`3561 `__,"Issue with internal counter in ``discard_block_engine``","October 2021","","" -`3563 `__,"``keys_view`` example is broken","October 2021","","","|ranges|" -`3566 `__,"Constraint recursion for ``operator<=>(optional, U)``","October 2021","","","|spaceship|" -`3567 `__,"Formatting move-only iterators take two","October 2021","","","|format|" -`3568 `__,"``basic_istream_view`` needs to initialize ``value_``","October 2021","","","|ranges|" -`3570 `__,"``basic_osyncstream::emit`` should be an unformatted output function","October 2021","","" -`3571 `__,"``flush_emit`` should set ``badbit`` if the ``emit`` call fails","October 2021","","" -`3572 `__,"``copyable-box`` should be fully ``constexpr``","October 2021","|Complete|","14.0","|ranges|" -`3573 `__,"Missing Throws element for ``basic_string_view(It begin, End end)``","October 2021","|Complete|","14.0" -`3574 `__,"``common_iterator`` should be completely ``constexpr``-able","October 2021","|Complete|","14.0","|ranges|" -`3580 `__,"``iota_view``'s ``iterator``'s binary ``operator+`` should be improved","October 2021","|Complete|","14.0","|ranges|" -`3581 `__,"The range constructor makes ``basic_string_view`` not trivially move constructible","October 2021","|Complete|","14.0","|ranges|" -`3585 `__,"``variant`` converting assignment with immovable alternative","October 2021","","" -`3589 `__,"The ``const`` lvalue reference overload of ``get`` for ``subrange`` does not constrain ``I`` to be ``copyable`` when ``N == 0``","October 2021","|Complete|","14.0","|ranges|" -`3590 `__,"``split_view::base() const &`` is overconstrained","October 2021","","","|ranges|" -`3591 `__,"``lazy_split_view::inner-iterator::base() &&`` invalidates outer iterators","October 2021","","","|ranges|" -`3592 `__,"``lazy_split_view`` needs to check the simpleness of Pattern","October 2021","","","|ranges|" -`3593 `__,"Several iterators' ``base() const &`` and ``lazy_split_view::outer-iterator::value_type::end()`` missing ``noexcept``","October 2021","","","|ranges|" -`3595 `__,"Exposition-only classes proxy and postfix-proxy for ``common_iterator`` should be fully ``constexpr``","October 2021","|Complete|","14.0","|ranges|" -"","","","","" -`3645 `__,"``resize_and_overwrite`` is overspecified to call its callback with lvalues", "Not voted in","|Complete|","14.0","" +`3553 `__,"Useless constraint in ``split_view::outer-iterator::value_type::begin()``","June 2021","","" +`3555 `__,"``{transform,elements}_view::iterator::iterator_concept`` should consider const-qualification of the underlying range","June 2021","","" "","","","","" diff --git a/docs/Status/Cxx2bPapers.csv b/docs/Status/Cxx2bPapers.csv index f5ab6edad..4df0bfcdd 100644 --- a/docs/Status/Cxx2bPapers.csv +++ b/docs/Status/Cxx2bPapers.csv @@ -15,26 +15,11 @@ "`P0448R4 `__","LWG","A strstream replacement using span as buffer","June 2021","","" "`P1132R8 `__","LWG","out_ptr - a scalable output pointer abstraction","June 2021","","" "`P1328R1 `__","LWG","Making std::type_info::operator== constexpr","June 2021","","" -"`P1425R4 `__","LWG","Iterators pair constructors for stack and queue","June 2021","|Complete|","14.0" +"`P1425R4 `__","LWG","Iterators pair constructors for stack and queue","June 2021","","" "`P1518R2 `__","LWG","Stop overconstraining allocators in container deduction guides","June 2021","|Complete|","13.0" "`P1659R3 `__","LWG","starts_with and ends_with","June 2021","","" -"`P1951R1 `__","LWG","Default Arguments for pair Forwarding Constructor","June 2021","|Complete|","14.0" -"`P1989R2 `__","LWG","Range constructor for std::string_view","June 2021","|Complete|","14.0" +"`P1951R1 `__","LWG","Default Arguments for pair Forwarding Constructor","June 2021","","" +"`P1989R2 `__","LWG","Range constructor for std::string_view","June 2021","","" "`P2136R3 `__","LWG","invoke_r","June 2021","","" "`P2166R1 `__","LWG","A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr","June 2021","|Complete|","13.0" -"","","","","","" -"`P0288R9 `__","LWG","``any_invocable``","October 2021","","" -"`P0798R8 `__","LWG","Monadic operations for ``std::optional``","October 2021","|Complete|","14.0" -"`P0849R8 `__","LWG","``auto(x)``: ``DECAY_COPY`` in the language","October 2021","|Complete|","14.0" -"`P1072R10 `__","LWG","``basic_string::resize_and_overwrite``","October 2021","|Complete|","14.0" -"`P1147R1 `__","LWG","Printing ``volatile`` Pointers","October 2021","|Complete|","14.0" -"`P1272R4 `__","LWG","Byteswapping for fun&&nuf","October 2021","|Complete|","14.0" -"`P1675R2 `__","LWG","``rethrow_exception`` must be allowed to copy","October 2021","","" -"`P2077R3 `__","LWG","Heterogeneous erasure overloads for associative containers","October 2021","","" -"`P2251R1 `__","LWG","Require ``span`` & ``basic_string_view`` to be Trivially Copyable","October 2021","|Complete|","14.0" -"`P2301R1 `__","LWG","Add a ``pmr`` alias for ``std::stacktrace``","October 2021","","" -"`P2321R2 `__","LWG","``zip``","October 2021","|In Progress|","" -"`P2340R1 `__","LWG","Clarifying the status of the 'C headers'","October 2021","","" -"`P2393R1 `__","LWG","Cleaning up ``integer``-class types","October 2021","","" -"`P2401R0 `__","LWG","Add a conditional ``noexcept`` specification to ``std::exchange``","October 2021","|Complete|","14.0" -"","","","","","" +"","","","","","" \ No newline at end of file diff --git a/docs/Status/Format.rst b/docs/Status/Format.rst index 35d8adfca..948b1b744 100644 --- a/docs/Status/Format.rst +++ b/docs/Status/Format.rst @@ -39,6 +39,10 @@ Misc. Items and TODOs (Please mark all Format-related TODO comments with the string ``TODO FMT``, so we can find them easily.) + * C++23 may break the ABI with `P2216 `_. + This ABI break may be backported to C++20. Therefore the library will not + be available on platforms where the ABI break is an issue. + Paper and Issue Status ====================== diff --git a/docs/Status/FormatIssues.csv b/docs/Status/FormatIssues.csv index 473aba8ea..7f4218d33 100644 --- a/docs/Status/FormatIssues.csv +++ b/docs/Status/FormatIssues.csv @@ -1,10 +1,31 @@ Number,Name,Assignee,Patch,Status,First released version -`P0645 `_,"Text Formatting",Mark de Wever,,|Complete|,Clang 14 -`P1652 `_,"Printf corner cases in std::format",Mark de Wever,"`D103433 `__, `D114001 `__",|Complete|,Clang 14 -`P1892 `_,"Extended locale-specific presentation specifiers for std::format",Mark de Wever,`D103368 `__,|Complete|,Clang 14 -`P1868 `_,"width: clarifying units of width and precision in std::format (Implements the unicode support.)",Mark de Wever,"`D103413 `__ `D103425 `__ `D103670 `__",|Complete|,Clang 14 -`P2216 `_,"std::format improvements",Mark de Wever,,|In Progress|, -`P2418 `__,"Add support for ``std::generator``-like types to ``std::format``",Mark de Wever,,|In Progress|, +`P0645 `_,"Text Formatting",Mark de Wever,,|partial|, +`P1652 `_,"Printf corner cases in std::format",Mark de Wever,`D103433 `__,Review, +`P1892 `_,"Extended locale-specific presentation specifiers for std::format",Mark de Wever,`D103368 `__,Review, +`P1868 `_,"width: clarifying units of width and precision in std::format (Implements the unicode support.)",Mark de Wever,"`D103413 `__ `D103425 `__ `D103670 `__",Review, +`P2216 `_,"std::format improvements",,,, +`LWG-3242 `_,"std::format: missing rules for arg-id in width and precision",Mark de Wever,`D103368 `__,Review, +`LWG-3243 `_,"std::format and negative zeroes",,,, +`LWG-3246 `_,"What are the constraints on the template parameter of basic_format_arg?",,,, +`LWG-3248 `_,"std::format #b, #B, #o, #x, and #X presentation types misformat negative numbers",Mark de Wever,`D103433 `__,Review, +`LWG-3250 `_,"std::format: # (alternate form) for NaN and inf",,,, +`LWG-3327 `_,"Format alignment specifiers vs. text direction",,,|Nothing To Do|, +`LWG-3340 `_,"Formatting functions should throw on argument/format string mismatch in [format.functions]",,,, +`LWG-3371 `_,"visit_format_arg and make_format_args are not hidden friends",Mark de Wever,`D103357 `__,Review, +`LWG-3372 `_,"vformat_to should not try to deduce Out twice",,,, +`LWG-3373 `_,"{to,from}_chars_result and format_to_n_result need the 'we really mean what we say'",,,, +`LWG-3462 `_,"§[formatter.requirements]: Formatter requirements forbid use of fc.arg()",,,, +`LWG-3539 `_,"format_to must not copy models of output_iterator",,,, +`LWG-3540 `_,"§[format.arg] There should be no const in basic_format_arg(const T* p)",,,, +`LWG-3541 `_,"indirectly_readable_traits should be SFINAE-friendly for all types",,,, +`LWG-3542 `_,"basic_format_arg mishandles basic_string_view with custom traits",,,, +`LWG-3544 `_,"format-arg-store::args is unintentionally not exposition-only",,,, -`P1361 `_,"Integration of chrono with text formatting",,,|Not Started|, -`P2372 `__,"Fixing locale handling in chrono formatters",,,|Not Started|, +`P1361 `_,"Integration of chrono with text formatting",,,, +`LWG-3218 `_,"Modifier for %d parse flag does not match POSIX and format specification",,,, +`LWG-3230 `_,"Format specifier %y/%Y is missing locale alternative versions",,,, +`LWG-3241 `_,"chrono-spec grammar ambiguity in [time.format]",,,, +`LWG-3262 `_,"Formatting of negative durations is not specified",,,, +`LWG-3270 `_,"Parsing and formatting %j with durations",,,, +`LWG-3272 `_,"%I%p should parse/format duration since midnight",,,, +`LWG-3332 `_,"Issue in [time.format]",,,, diff --git a/docs/Status/FormatPaper.csv b/docs/Status/FormatPaper.csv index e45777ef1..afdf88355 100644 --- a/docs/Status/FormatPaper.csv +++ b/docs/Status/FormatPaper.csv @@ -1,49 +1,48 @@ Section,Description,Dependencies,Assignee,Patch,Status,First released version -`[charconv.to.chars] `_,"Fix integral conformance",,Mark de Wever,`D100722 `__,|Complete|,Clang 13 -`[charconv.to.chars] `_,"Add floating-point conversion",`D100722 `__,"Mark de Wever (Code provided by Stephan T. Lavavej of Microsoft)",`D70631 `__,|Complete|,Clang 14 -`[format.error] `_,"Class format_error",,Mark de Wever,`D92214 `__,|Complete|,Clang 13 -`[format.parse.ctx] `_,"Class template basic_format_parse_context",,Mark de Wever,`D93166 `__,|Complete|,Clang 13 -`[format.context] `_,"Class template basic_format_context",,Mark de Wever,`D103357 `__,|Complete|,Clang 14 -`[format.args] `_,"Class template basic_format_args",,Mark de Wever,`D103357 `__,|Complete|,Clang 14 -`[format.arg] `_,"Class template basic_format_arg",,Mark de Wever,`D103357 `__,|Complete|,Clang 14 -`[format.arg] `_,"Class template basic_format_arg - handle",,Mark de Wever,,|Complete|,Clang 14 -`[format.arg] `_,"Class template basic_format_arg - pointers",,Mark de Wever,,|Complete|,Clang 14 -`[format.arg.store] `_,"Class template format-arg-store",,Mark de Wever,`D103357 `__,|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - character types",,Mark de Wever,"`D96664 `__ `D103466 `__",|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - string types",,Mark de Wever,"`D96664 `__ `D103425 `__",|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - boolean type",,Mark de Wever,"`D96664 `__ `D103670 `__",|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - integral types",,Mark de Wever,"`D96664 `__ `D103433 `__",|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - floating-point types",`D70631 `__,Mark de Wever,`D114001 `__,|Complete|,Clang 14 -`[format.formatter.spec] `_,"Formatter specializations - pointer types",,Mark de Wever,,|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - character types",,Mark de Wever,`D103368 `__,|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - string types",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - boolean type",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - integral types",,Mark de Wever,`D103368 `__,|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - floating-point types",,Mark de Wever,`D114001 `__,|Complete|,Clang 14 -`[format.string.std] `_,"Standard format specifiers - pointer types",,Mark de Wever,,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat(string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat(wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat(const locale& loc, string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat(const locale& loc, wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to(Out out, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat_to(Out out, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat_to(Out out, wstring_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat_to(Out out, const locale& loc, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - vformat_to(Out out, const locale& loc, wstring_view fmt,format_args_t, wchar_t> args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to_n(Out out, iter_difference_t n, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to_n(Out out, iter_difference_t n, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - formatted_size(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - formatted_size(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - formatted_size(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - formatted_size(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,|Complete|,Clang 14 -`[format.functions] `_,"Format functions - Improve performance format_to_n",,Mark de Wever,`D110499 `__,|Review|, -`[format.functions] `_,"Format functions - Improve performance formatted size",,Mark de Wever,`D110500 `__,|Review|, -`[format.functions] `_,"`P2216 `_ - Compile-time checks",,Mark de Wever,,|In Progress|, -`[format.functions] `_,"`P2216 `_ - Binary size",,Mark de Wever,`D110494 `__,|Complete|,Clang 14 +[charconv.to.chars],"Fix integral conformance",,Mark de Wever,`D100722 `__,|Complete|,Clang 13 +[charconv.to.chars],"Add floating-point conversion",`D100722 `__,"Mark de Wever (Code provided by Stephan T. Lavavej of Microsoft)",`D70631 `__,In progress, +[format.error],"Class format_error",,Mark de Wever,`D92214 `__,|Complete|,Clang 13 +[format.parse.ctx],"Class template basic_format_parse_context",,Mark de Wever,`D93166 `__,|Complete|,Clang 13 +[format.context],"Class template basic_format_context",,Mark de Wever,`D103357 `__,Review, +[format.args],"Class template basic_format_args",,Mark de Wever,`D103357 `__,Review, +[format.arg],"Class template basic_format_arg",,Mark de Wever,`D103357 `__,Review, +[format.arg],"Class template basic_format_arg - handle",,,,,, +[format.arg],"Class template basic_format_arg - pointers",,,,,, +[format.arg.store],"Class template format-arg-store",,Mark de Wever,`D103357 `__,Review, +[format.formatter.spec],"Formatter specializations - character types",,Mark de Wever,"`D96664 `__ `D103466 `__",Review, +[format.formatter.spec],"Formatter specializations - string types",,Mark de Wever,"`D96664 `__ `D103425 `__",Review, +[format.formatter.spec],"Formatter specializations - boolean type",,Mark de Wever,"`D96664 `__ `D103670 `__",Review, +[format.formatter.spec],"Formatter specializations - integral types",,Mark de Wever,"`D96664 `__ `D103433 `__",Review, +[format.formatter.spec],"Formatter specializations - floating-point types",`D70631 `__,Mark de Wever,`D96664 `__,Review, +[format.formatter.spec],"Formatter specializations - pointer types",,,,,, +[format.string.std],"Standard format specifiers - character types",,Mark de Wever,`D103368 `__,Review, +[format.string.std],"Standard format specifiers - string types",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",Review, +[format.string.std],"Standard format specifiers - boolean type",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",Review, +[format.string.std],"Standard format specifiers - integral types",,Mark de Wever,`D103368 `__,Review, +[format.string.std],"Standard format specifiers - floating-point types",,Mark de Wever,,,, +[format.string.std],"Standard format specifiers - pointer types",,Mark de Wever,,,, +[format.functions],"Format functions - format(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(const locale& loc, string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(const locale& loc, wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to(Out out, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, wstring_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, const locale& loc, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, const locale& loc, wstring_view fmt,format_args_t, wchar_t> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n(Out out, iter_difference_t n, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n(Out out, iter_difference_t n, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - Implement locale support",,Mark de Wever,,In progress,, +[format.functions],"Format functions - Improve performance format_to_n",,Mark de Wever,,,, +[format.functions],"Format functions - Improve performance formatted size",,Mark de Wever,,,, diff --git a/docs/Status/Ranges.rst b/docs/Status/Ranges.rst index 30546ed09..66b2ba375 100644 --- a/docs/Status/Ranges.rst +++ b/docs/Status/Ranges.rst @@ -31,11 +31,6 @@ Sub-Projects in the One Ranges Proposal :header-rows: 1 :widths: auto -.. csv-table:: - :file: RangesAlgorithms.csv - :header-rows: 1 - :widths: auto - Misc. Items and TODOs ==================================== @@ -53,4 +48,4 @@ Paper and Issue Status .. csv-table:: :file: RangesIssues.csv :header-rows: 1 - :widths: auto + :widths: auto \ No newline at end of file diff --git a/docs/Status/RangesAlgorithms.csv b/docs/Status/RangesAlgorithms.csv deleted file mode 100644 index 155e6b880..000000000 --- a/docs/Status/RangesAlgorithms.csv +++ /dev/null @@ -1,100 +0,0 @@ -Category,Algorithm,Assignee,CL,Complete -Search,any_of,Christopher Di Bella,`D105793 `_ -Search,all_of,Christopher Di Bella,`D105793 `_ -Search,none_of,Christopher Di Bella,`D105793 `_ -Search,find,Christopher Di Bella,`D105456 `_ -Search,find_if,Christopher Di Bella,`D105792 `_ -Search,find_if_not,Christopher Di Bella,`D105792 `_ -Search,find_first_of,Not assigned,n/a,Not started -Search,adjacent_find,Not assigned,n/a,Not started -Search,mismatch,Not assigned,n/a,Not started -Search,equal,Not assigned,n/a,Not started -Search,lexicographical_compare,Not assigned,n/a,Not started -Search,partition_point,Christopher Di Bella,`D105794 `_,Under review -Search,lower_bound,Christopher Di Bella,`D105795 `_,Under review -Search,upper_bound,Christopher Di Bella,`D105795 `_,Under review -Search,equal_range,Christopher Di Bella,n/a,Not started -Search,binary_search,Christopher Di Bella,n/a,Not started -Search,min,Not assigned,n/a,Not started -Search,max,Not assigned,n/a,Not started -Search,minmax,Not assigned,n/a,Not started -Search,min_element,Not assigned,n/a,Not started -Search,max_element,Not assigned,n/a,Not started -Search,minmax_element,Not assigned,n/a,Not started -Search,count,Not assigned,n/a,Not started -Search,count_if,Not assigned,n/a,Not started -Search,search,Not assigned,n/a,Not started -Search,search_n,Not assigned,n/a,Not started -Search,find_end,Not assigned,n/a,Not started -Read-only,is_partitioned,Christopher Di Bella,`D105794 `_,Under review -Read-only,is_sorted,Not assigned,n/a,Not started -Read-only,is_sorted_unitl,Not assigned,n/a,Not started -Read-only,includes,Not assigned,n/a,Not started -Read-only,is_heap,Not assigned,n/a,Not started -Read-only,is_heap_until,Not assigned,n/a,Not started -Read-only,clamp,Not assigned,n/a,Not started -Read-only,is_permutation,Not assigned,n/a,Not started -Read-only,for_each,Not assigned,n/a,Not started -Read-only,for_each_n,Not assigned,n/a,Not started -Write,copy,Not assigned,n/a,Not started -Write,copy_if,Not assigned,n/a,Not started -Write,copy_n,Not assigned,n/a,Not started -Write,copy_backward,Not assigned,n/a,Not started -Write,move,Not assigned,n/a,Not started -Write,move_backward,Not assigned,n/a,Not started -Write,fill,Not assigned,n/a,Not started -Write,fill_n,Not assigned,n/a,Not started -Write,transform,Not assigned,n/a,Not started -Write,generate,Not assigned,n/a,Not started -Write,generate_nNot assigned,n/a,Not started -Write,remove_copy,Not assigned,n/a,Not started -Write,remove_copy_if,Not assigned,n/a,Not started -Write,replace,Not assigned,n/a,Not started -Write,replace_if,Not assigned,n/a,Not started -Write,replace_copy,Not assigned,n/a,Not started -Write,replace_copy_if,Not assigned,n/a,Not started -Write,swap_ranges,Not assigned,n/a,Not started -Write,reverse_copy,Not assigned,n/a,Not started -Write,rotate_copy,Not assigned,n/a,Not started -Write,sample,Not assigned,n/a,Not started -Write,unique_copy,Not assigned,n/a,Not started -Write,partition_copy,Not assigned,n/a,Not started -Write,partial_sort_copy,Not assigned,n/a,Not started -Merge,merge,Not assigned,n/a,Not started -Merge,set_difference,Not assigned,n/a,Not started -Merge,set_intersection,Not assigned,n/a,Not started -Merge,set_symmetric_difference,Not assigned,n/a,Not started -Merge,set_union,Not assigned,n/a,Not started -Permutation,remove,Not assigned,n/a,Not started -Permutation,remove_if,Not assigned,n/a,Not started -Permutation,reverse,Not assigned,n/a,Not started -Permutation,rotate,Not assigned,n/a,Not started -Permutation,shuffle,Not assigned,n/a,Not started -Permutation,unique,Not assigned,n/a,Not started -Permutation,partition,Not assigned,n/a,Not started -Permutation,stable_partition,Not assigned,n/a,Not started -Permutation,sort,Not assigned,n/a,Not started -Permutation,stable_sort,Not assigned,n/a,Not started -Permutation,partial_sort,Not assigned,n/a,Not started -Permutation,nth_element,Not assigned,n/a,Not started -Permutation,inplace_merge,Not assigned,n/a,Not started -Permutation,make_heap,Not assigned,n/a,Not started -Permutation,push_heap,Not assigned,n/a,Not started -Permutation,pop_heap,Not assigned,n/a,Not started -Permutation,sort_heap,Not assigned,n/a,Not started -Permutation,prev_permutation,Not assigned,n/a,Not started -Permutation,next_permutation,Not assigned,n/a,Not started -Uninitialised memory,uninitialized_copy,Konstantin Varlamov,`D116023 `_,✅ -Uninitialised memory,uninitialized_copy_n,Konstantin Varlamov,`D116023 `_,✅ -Uninitialised memory,uninitialized_fill,Konstantin Varlamov,`D115626 `_,✅ -Uninitialised memory,uninitialized_fill_n,Konstantin Varlamov,`D115626 `_,✅ -Uninitialised memory,uninitialized_move,Konstantin Varlamov,`D116023 `_,✅ -Uninitialised memory,uninitialized_move_n,Konstantin Varlamov,`D116023 `_,✅ -Uninitialised memory,uninitialized_default_construct,Konstantin Varlamov,`D115315 `_,✅ -Uninitialised memory,uninitialized_default_construct_n,Konstantin Varlamov,`D115315 `_,✅ -Uninitialised memory,uninitialized_value_construct,Konstantin Varlamov,`D115626 `_,✅ -Uninitialised memory,uninitialized_value_construct_n,Konstantin Varlamov,`D115626 `_,✅ -Uninitialised memory,destroy,Konstantin Varlamov,`D116078 `_,✅ -Uninitialised memory,destroy_n,Konstantin Varlamov,`D116078 `_,✅ -Uninitialised memory,destroy_at,Konstantin Varlamov,`D116078 `_,✅ -Uninitialised memory,construct_at,Konstantin Varlamov,`D116078 `_,✅ diff --git a/docs/Status/RangesIssues.csv b/docs/Status/RangesIssues.csv index 728742d5b..4cd6c3d11 100644 --- a/docs/Status/RangesIssues.csv +++ b/docs/Status/RangesIssues.csv @@ -1,11 +1,11 @@ -"Number","Name","Status","First released version" +"Number","Name","Status","Assignee" `P0896R4 `__,,, `P1035R7 `__,Input Range Adaptors,, `P1207R4 `__,Movability Of Single-Pass Iterators,, `P1243R4 `__,Rangify New Algorithms,, -`P1248R1 `__,Fixing Relations,|Complete|,13.0 +`P1248R1 `__,Fixing Relations,, `P1252R2 `__,Ranges Design Cleanup,, -`P1391R4 `__,Range Constructor For string_view,|Complete|,14.0 +`P1391R4 `__,Range Constructor For string_view,, `P1456R1 `__,Move-Only Views,, `P1474R1 `__,Helpful Pointers For contiguous_iterator,, `P1522R1 `__,Iterator Difference Type And Integer Overflow,, @@ -15,7 +15,7 @@ `P1739R4 `__,Avoiding Template Bloat For Ranges,, `P1862R1 `__,Range Adaptors For Non-Copyable Iterators,, `P1870R1 `__,safe_range,, -`P1871R1 `__,disable_sized_sentinel_for,|Complete|,14.0 +`P1871R1 `__,disable_sized_sentinel_for,, `P1878R1 `__,Constraining Readable Types,, `P1970R2 `__,ranges::ssize,, `P1983R0 `__,Fixing Minor Ranges Issues,, @@ -26,8 +26,55 @@ `P2325R3 `__,Views should not be required to be default constructible ,, `P2328R1 `__,join_view should join all views of ranges,, `P2210R2 `__,Superior String Splitting,, -`P2281R1 `__,Clarifying range adaptor objects,|Complete|,14.0 +`P2281R1 `__,Clarifying range adaptor objects,, `P2367R0 `__,Remove misuses of list-initialization from Clause 24,, -`P2415 `__,"What is a ``view``",|Complete|,14.0 -`P2432 `__,"Fix ``istream_view``",, +`LWG3169 `__, ranges permutation generators discard useful information,, +`LWG3173 `__, Enable CTAD for ref-view,, +`LWG3179 `__, subrange should always model Range,, +`LWG3180 `__, Inconsistently named return type for ranges::minmax_element,, +`LWG3183 `__, Normative permission to specialize Ranges variable templates,, +`LWG3186 `__, "ranges removal, partition, and partial_sort_copy algorithms discard useful information",, +`LWG3191 `__, std::ranges::shuffle synopsis does not match algorithm definition,, +`LWG3276 `__, Class split_view::outer_iterator::value_type should inherit from view_interface,, +`LWG3280 `__, View converting constructors can cause constraint recursion and are unneeded,, +`LWG3281 `__, Conversion from pair-like types to subrange is a silent semantic promotion,, +`LWG3282 `__, subrange converting constructor should disallow derived to base conversions,, +`LWG3286 `__, ranges::size is not required to be valid after a call to ranges::begin on an input range,, +`LWG3291 `__, iota_view::iterator has the wrong iterator_category,, +`LWG3292 `__, iota_view is under-constrained,, +`LWG3299 `__, Pointers don't need customized iterator behavior,, +`LWG3301 `__, transform_view::iterator has incorrect iterator_category,, +`LWG3302 `__, Range adaptor objects keys and values are unspecified,, +`LWG3313 `__, join_view::iterator::operator-- is incorrectly constrained,, +`LWG3323 `__, has-tuple-element helper concept needs convertible_to,, +`LWG3325 `__, Constrain return type of transformation function for transform_view,, +`LWG3335 `__, range_size_t and views::all_t,, +`LWG3355 `__, The memory algorithms should support move-only input iterators introduced by P1207,, +`LWG3363 `__, drop_while_view should opt-out of sized_range,, +`LWG3364 `__, Initialize data members of ranges and their iterators,, +`LWG3381 `__, begin and data must agree for contiguous_range,, +`LWG3384 `__, transform_view::sentinel has an incorrect operator-,, +`LWG3385 `__, common_iterator is not sufficiently constrained for non-copyable iterators,, +`LWG3387 `__, [range.reverse.view] reverse_view unintentionally requires range,, +`LWG3388 `__, view iterator types have ill-formed <=> operators,, +`LWG3389 `__, A move-only iterator still does not have a counted_iterator,, +`LWG3397 `__, ranges::basic_istream_view::iterator should not provide iterator_category,, +`LWG3398 `__, tuple_element_t is also wrong for const subrange,, +`LWG3474 `__, Nesting join_views is broken because of CTAD,, +`LWG3481 `__,"viewable_range mishandles lvalue move-only views",, +`LWG3500 `__, join_view::iterator::operator->() is bogus,, +`LWG3505 `__, split_view::outer-iterator::operator++ misspecified,, +`LWG3517 `__,"join_view::iterator's iter_swap is underconstrained",, +`LWG3520 `__,"iter_move and iter_swap are inconsistent for transform_view::iterator",, +`LWG3522 `__,"Missing requirement on InputIterator template parameter for priority_queue constructors",, +`LWG3523 `__,"iota_view::sentinel is not always iota_view's sentinel",, +`LWG3532 `__,"split_view::inner-iterator::operator++(int) should depend on Base",, +`LWG3533 `__,"Make base() const & consistent across iterator wrappers that supports input_iterators",, +`LWG3541 `__,"indirectly_readable_traits should be SFINAE-friendly for all types",, +`LWG3543 `__,"Definition of when counted_iterators refer to the same sequence isn't quite right",, +`LWG3546 `__,"common_iterator's postfix-proxy is not quite right",, +`LWG3549 `__,"view_interface is overspecified to derive from view_base",, +`LWG3551 `__,"borrowed_{iterator,subrange}_t are overspecified",, +`LWG3553 `__,"Useless constraint in split_view::outer-iterator::value_type::begin()",, +`LWG3555 `__,"{transform,elements}_view::iterator::iterator_concept should consider const-qualification of the underlying range",, diff --git a/docs/Status/RangesPaper.csv b/docs/Status/RangesPaper.csv index e6fddabbd..a7d289706 100644 --- a/docs/Status/RangesPaper.csv +++ b/docs/Status/RangesPaper.csv @@ -1,42 +1,42 @@ Section,Description,Dependencies,Assignee,Complete -`[tuple.helper] `_,Update includes.,None,Konstantin Varlamov,Not started -`[range.cmp] `_,"| `ranges::equal_to `_ +[tuple.helper],Update includes.,None,Unassigned,Not started +`[range.cmp] `_,"| `ranges::equal_to `_ | `ranges::not_equal_to `_ | `ranges::less `_ | `ranges::greater `_ | `ranges::less_equal `_ | `ranges::greater_equal `_",None,Zoe Carver,✅ -`[readable.traits] `_,"| `indirectly_readable_traits `_ +`[readable.traits] `_,"| `indirectly_readable_traits `_ | `iter_value_t `_",None,Christopher Di Bella,✅ -`[incrementable.traits] `_,"| `incrementable_traits `_ +`[incrementable.traits] `_,"| `incrementable_traits `_ | `iter_difference_t `_",,Christopher Di Bella,✅ -`[iterator.traits] `_,`Updates to iterator_traits `_,"| indirectly_readable_traits +`[iterator.traits] `_,`Updates to iterator_traits `_,"| indirectly_readable_traits | incrementable_traits",Christopher Di Bella,✅ -`[special.mem.concepts] `_,"| `nothrow-input-iterator `_ -| `nothrow-sentinel-for `_ -| `nothrow-input-range `_ -| `nothrow-forward-iterator `_ -| `nothrow-forward-range `_","| [iterator.concepts] -| [range.refinements]",Konstantin Varlamov,✅ -`[specialized.algorithms] `_,"| `ranges::uninitialized_default_construct `_ -| `ranges::uninitialized_default_construct_n `_ -| `ranges::uninitialized_value_construct `_ -| `ranges::uninitialized_value_construct_n `_ -| `ranges::uninitialized_copy `_ -| `ranges::uninitialized_copy_n `_ -| `ranges::uninitialized_move `_ -| `ranges::uninitialized_move_n `_ -| `ranges::uninitialized_fill `_ -| `ranges::uninitialized_fill_n `_ -| `ranges::construct_at `_ -| `ranges::destroy `_ -| `ranges::destroy_at `_ -| `ranges::destroy_n `_",[special.mem.concepts],Konstantin Varlamov,✅ -`[strings] `_,Adds begin/end and updates const_iterator.,[iterator.concepts],Unassigned,Not started -`[views.span] `_,Same as [strings],[iterator.concepts],Unassigned,Not started -`[iterator.cust.move] `_,`ranges::iter_move `_,,Zoe Carver,✅ -`[iterator.cust.swap] `_,`ranges::iter_swap `_,iter_value_t,Zoe Carver,✅ -`[iterator.concepts] `_,"| `indirectly_readable `_ +`[special.mem.concepts] `_,"| *no-throw-input-iterator* +| *no-throw-sentinel-for* +| *no-throw-input-range* +| *no-throw-forward-iterator* +| *no-throw-forward-range*","| [iterator.concepts] +| [range.refinements]",Unassigned,Not started +`[specialized.algorithms] `_,"| ranges::uninitialized_default_construct +| ranges::uninitialized_default_construct_n +| ranges::uninitialized_value_construct +| ranges::uninitialized_value_construct_n +| ranges::uninitialized_copy +| ranges::uninitialized_copy_n +| ranges::uninitialized_move +| ranges::uninitialized_move_n +| ranges::uninitialized_fill +| ranges::uninitialized_fill_n +| ranges::construct_at +| ranges::destroy +| ranges::destroy_at +| ranges::destroy_n",[special.mem.concepts],Unassigned,Not started +[strings],Adds begin/end and updates const_iterator.,[iterator.concepts],Unassigned,Not started +[views.span],Same as [strings],[iterator.concepts],Unassigned,Not started +`[iterator.cust.move] `_,`ranges::iter_move `_,,Zoe Carver,✅ +`[iterator.cust.swap] `_,`ranges::iter_swap `_,iter_value_t,Zoe Carver,✅ +`[iterator.concepts] `_,"| `indirectly_readable `_ | `indirectly_writable `_ | `weakly_incrementable `_ | `incrementable `_ @@ -49,52 +49,42 @@ Section,Description,Dependencies,Assignee,Complete | `bidirectional_iterator `_ | `random_access_iterator `_ | `contiguous_iterator `_",,Various,✅ -`[indirectcallable.indirectinvocable] `_," -| `indirectly_unary_invocable `_ +`[indirectcallable.indirectinvocable] `_,"| indirectly_unary_invocable | `indirectly_regular_unary_invocable `_ | `indirectly_unary_predicate `_ | `indirectly_binary_predicate `_ | `indirectly_equivalence_relation `_ | `indirectly_strict_weak_order `_",[readable.traits],Louis Dionne,✅ -`[projected] `_,`ranges::projected `_,[iterator.concepts],Louis Dionne,✅ -`[common.alg.req] `_: pt. 1,"| `indirectly_movable `_ +`[projected] `_,`ranges::projected `_,[iterator.concepts],Louis Dionne,✅ +`[common.alg.req] `_: pt. 1,"| `indirectly_movable `_ | `indirectly_movable_storable `_ | indirectly_copyable | indirectly_copyable_storable",[iterator.concepts],Zoe Carver,In progress -`[common.alg.req] `_: pt. 2,`indirectly_swappable `_,"| [iterator.concepts] +[common.alg.req]: pt. 2,indirectly_swappable,"| [iterator.concepts] | [iterator.cust.swap]",Zoe Carver,✅ -`[common.alg.req] `_: pt. 3,`indirectly_comparable `_,[projected],Nikolas Klauser,✅ -`[common.alg.req] `_: pt. 4,"| permutable +[common.alg.req]: pt. 3,indirectly_comparable,[projected],Louis Dionne,Not started +[common.alg.req]: pt. 4,"| permutable | mergeable | sortable",[iterator.concepts],Unassigned,Not started -`[std.iterator.tags] `_,,[iterator.traits],Unassigned,Not started -`[range.iter.ops] `_,"| `ranges::advance `_ +[std.iterator.tags],,[iterator.traits],Unassigned,Not started +`[range.iter.ops] `_,"| `ranges::advance `_ | `ranges::distance `_ | `ranges::next `_ -| `ranges::prev `_",[iterator.concepts],Christopher Di Bella and Arthur O'Dwyer,✅ -`[predef.iterators] `_," -| Updates to reverse_iterator -| Updates to back_insert_iterator -| Updates to front_insert_iterator -| Updates to move_iterator","| [iterator.concepts] +| `ranges::prev `_",[iterator.concepts],Christopher Di Bella,In progress +[predef.iterators],Updates to predefined iterators.,"| [iterator.concepts] | [iterator.cust.swap] | [iterator.cust.move]",Unassigned,Not started -`[move.sentinel] `_,move_sentinel,[predef.iterators],Unassigned,Not started -`[common.iterator] `_,`common_iterator `_,"| [iterator.concepts] +[move.sentinel],,[predef.iterators],Unassigned,Not started +[common.iterator],,"| [iterator.concepts] | [iterator.cust.swap] | [iterator.cust.move]",Zoe Carver,✅ -`[default.sentinel] `_,`std::default_sentinel_t `_,No dependencies,Zoe Carver,✅ -`[counted.iterator] `_,`counted_iterator `_,"| [iterator.concepts] +[default.sentinels],std::default_sentinel_t.,No dependencies,Zoe Carver,✅ +[counted.iterator],,"| [iterator.concepts] | [iterator.cust.swap] | [iterator.cust.move] | [default.sentinels]",Zoe Carver,✅ -`[stream.iterators] `_," -| Updates to istream_iterator -| Updates to ostream_iterator -| Updates to istreambuf_iterator -| Updates to ostreambuf_iterator -",[default.sentinels],Unassigned,Not started -`[range.access] `_,"| `ranges::begin `_ +[stream.iterators],,[default.sentinels],Unassigned,Not started +`[range.access] `_,"| `ranges::begin `_ | `ranges::end `_ | `range::cbegin `_ | `ranges::cend `_ @@ -106,8 +96,8 @@ Section,Description,Dependencies,Assignee,Complete | `ranges::ssize `_ | `ranges::empty `_ | `ranges::data `_ -| `ranges::cdata `_",[iterator.concepts],Christopher Di Bella and Zoe Carver,In progress -`[range.range] `_,"| `ranges::range `_ +| ranges::cdata",[iterator.concepts],Christopher Di Bella and Zoe Carver,In progress +`[range.range] `_,"| `ranges::range `_ | `ranges::borrowed_range `_ | `ranges::enable_borrowed_range `_ | `ranges::iterator_t `_ @@ -117,43 +107,43 @@ Section,Description,Dependencies,Assignee,Complete | `ranges::range_value_t `_ | `ranges::range_reference_t `_ | `ranges::range_rvalue_reference_t `_",[range.access],Christopher Di Bella,✅ -`[range.sized] `_,"| `ranges::sized_range `_ +`[range.sized] `_,"| `ranges::sized_range `_ | `ranges::disable_sized_range `_","| [range.primitives] | [range.range]",Christopher Di Bella,✅ -`[range.view] `_,"| `ranges::enable_view `_ +`[range.view] `_,"| `ranges::enable_view `_ | `ranges::view_base `_ | `ranges::view `_",[range.range],Louis Dionne,✅ -`[range.refinements] `_,"| `ranges::output_range `_ +`[range.refinements] `_,"| ranges::output_range | `ranges::input_range `_ -| `ranges::forward_range `_ +| `ranges::forward_range: `D100275 `_ | `ranges::bidirectional_range `_ | `ranges::random_access_range `_ -| `ranges::contiguous_range `_ +| ranges::contiguous_range | `ranges::common_range `_",[range.range],Christopher Di Bella,✅ `[range.refinements]`_,`ranges::viewable_range `_,[range.range],Louis Dionne,✅ -`[range.utility.helpers] `_,"| `simple-view `_ -| `has-arrow `_ -| `not-same-as `_","| [range.range] +`[range.utility.helpers] `_,"| *simple-view* +| *has-arrow* +| *not-same-as*","| [range.range] | [iterator.concept.input]",Zoe Carver,✅ -`[view.interface] `_,"`ranges::view_interface `_","| [ranges.range] +`[view.interface] `_,"`ranges::view_interface `_","| [ranges.range] | [range.view] | [range.iterator.op.prev] | [range.refinements]",Zoe Carver,✅ -`[range.subrange] `_,`ranges::subrange `_,[view.interface],Zoe Carver,✅ -`[range.dangling] `_,"| `ranges::dangling `_ -| `ranges::borrowed_iterator_t `_ -| `ranges::borrowed_subrange_t `_","| [range.range] +`[range.subrange] `_,`ranges::subrange `_,[view.interface],Zoe Carver,✅ +`[range.dangling] `_,"| ranges::dangling +| ranges::borrowed_iterator_t +| ranges::borrowed_subrange_t","| [range.range] | [range.subrange]",Christopher Di Bella,✅ -`[range.empty] `_,`empty_view `_,[view.interface],Zoe Carver,✅ -`[range.single] `_,`single_view `_,[view.interface],Zoe Carver,✅ -`[range.iota] `_,`iota_view `_,[range.all],Zoe Carver,✅ -`[range.all] `_,`view::all `_,"[range.subrange], [range.view.ref]",Zoe Carver,✅ -`[range.ref.view] `_,`ref_view `_,[view.interface],Zoe Carver,✅ -`[range.filter] `_,`filter_view `_,[range.all],Louis Dionne,Under review -`[range.transform] `_,`transform_view `_,[range.all],Zoe Carver,✅ -`[range.take] `_,`take_view `_,[range.all],Zoe Carver,✅ -`[range.join] `_,`join_view `_,[range.all],Zoe Carver,✅ -`[range.split] `_,`split_view `_,[range.all],Zoe Carver,In progress -`[range.counted] `_,`view::counted `_,[range.subrange],Zoe Carver,✅ -`[range.common] `_,`common_view `_,[range.all],Zoe Carver,✅ -`[range.reverse] `_,`reverse_view `_,[range.all],Zoe Carver,✅ +`[range.all] `_,`view::all `_,"[range.subrange], [range.view.ref]",Zoe Carver,✅ +`[range.view.ref] `_,`ref-view `_,[view.interface],Zoe Carver,✅ +`[range.filter] `_,filter_view,[range.all],Louis Dionne,Not started +`[range.transform] `_,`transform_view `_,[range.all],Zoe Carver,✅ +`[range.iota] `_,iota_view,[range.all],Louis Dionne,Not started +`[range.take] `_,take_view,[range.all],Zoe Carver,In Progress +`[range.join] `_,join_view,[range.all],Christopher Di Bella,Not started +`[range.empty] `_,`empty_view `_,[view.interface],Zoe Carver,✅ +`[range.single] `_,single_view,[view.interface],Zoe Carver,In Progress +`[range.split] `_,split_view,[range.all],Unassigned,Not started +`[range.counted] `_,view::counted,[range.subrange],Zoe Carver,Not started +`[range.common] `_,common_view,[range.all],Zoe Carver,✅ +`[range.reverse] `_,reverse_view,[range.all],Unassigned,Not started diff --git a/docs/Status/Spaceship.rst b/docs/Status/Spaceship.rst deleted file mode 100644 index d596c1128..000000000 --- a/docs/Status/Spaceship.rst +++ /dev/null @@ -1,53 +0,0 @@ -.. spaceship-status: - -============================================== -libc++ Spaceship Operator Status (operator<=>) -============================================== - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - - -Overview -================================ - -This document contains the status of the C++20 spaceship operator support -in libc++. It is used to track both the status of the sub-projects of the effort -and who is assigned to these sub-projects. This is imperative to effective -implementation so that work is not duplicated and implementors are not blocked -by each other. - -If you are interested in contributing to this effort, please send a message -to the #libcxx channel in the LLVM discord. Please *do not* start working on any -of the assigned items below. - - -Sub-Projects in the Implementation Effort -========================================= - -.. csv-table:: - :file: SpaceshipProjects.csv - :header-rows: 1 - :widths: auto - -.. note:: - - .. [#note-strongorder] ``std::strong_order(long double, long double)`` is not yet implemented. - - -Misc. Items and TODOs -==================================== - -(Note: files with required updates will contain the TODO at the beginning of the -list item so they can be easily found via global search.) - - -Paper and Issue Status -==================================== - -.. csv-table:: - :file: SpaceshipPapers.csv - :header-rows: 1 - :widths: auto diff --git a/docs/Status/SpaceshipPapers.csv b/docs/Status/SpaceshipPapers.csv deleted file mode 100644 index 82eea1bf9..000000000 --- a/docs/Status/SpaceshipPapers.csv +++ /dev/null @@ -1,10 +0,0 @@ -"Number","Name","Status","First released version" -`P1614R2 `_,The Mothership has Landed,|In Progress|, -`P2404R0 `_,"Relaxing equality_comparable_with's, totally_ordered_with's, and three_way_comparable_with's common reference requirements to support move-only types",, -`P2405R0 `_,nullopt_t and nullptr_t should both have operator<=> and operator==,, -`LWG3330 `_,Include from most library headers,"|Complete|","13.0" -`LWG3347 `_,"std::pair now requires T and U to be less-than-comparable",|Nothing To Do|, -`LWG3350 `_,Simplify return type of lexicographical_compare_three_way,|Nothing To Do|, -`LWG3360 `_,three_way_comparable_with is inconsistent with similar concepts,|Nothing To Do|, -`LWG3380 `_,common_type and comparison categories,|Nothing To Do|, -`LWG3395 `_,Definition for three-way comparison needs to be updated,|Nothing To Do|, diff --git a/docs/Status/SpaceshipProjects.csv b/docs/Status/SpaceshipProjects.csv deleted file mode 100644 index 25bb7d077..000000000 --- a/docs/Status/SpaceshipProjects.csv +++ /dev/null @@ -1,82 +0,0 @@ -Section,Description,Dependencies,Assignee,Complete -| `[cmp.concept] `_,"| `three_way_comparable `_ -| `three_way_comparable_with `_",None,Ruslan Arutyunyan,|Complete| -| `[cmp.result] `_,| `compare_three_way_result `_,None,Arthur O'Dwyer,|Complete| -| `[expos.only.func] `_,"| `synth-three-way `_ -| `synth-three-way-result `_",[cmp.concept],Kent Ross,|Complete| -| `[comparisons.three.way] `_,| `compare_three_way `_,[cmp.concept],Arthur O'Dwyer,|Complete| -| `[cmp.alg] `_,"| `strong_order `_ -| `weak_order `_ -| `partial_order `_ -| `strong_order_fallback `_ -| `weak_order_fallback `_ -| `partial_order_fallback `_",None,Arthur O'Dwyer,|Complete| [#note-strongorder]_ -| `[alg.three.way] `_,| `lexicographical_compare_three_way `_,[comparisons.three.way],Christopher Di Bella,|In Progress| -| `[coroutine.handle.compare] `_,| `coroutine_handle `_,[comparisons.three.way],Chuanqi Xu,|Complete| -| `[pairs.spec] `_,| `pair `_,[expos.only.func],Kent Ross,|Complete| -| `[syserr.errcat.nonvirtuals] `_,| error_category,[comparisons.three.way],Unassigned,|Not Started| -| `[syserr.compare] `_,"| error_code -| error_condition",None,Unassigned,|Not Started| -| `[tuple.rel] `_,| `tuple `_,[expos.only.func],Kent Ross,|Complete| -"| `[optional.relops] `_ -| `[optional.nullops] `_ -| `[optional.comp.with.t] `_","| optional -| nullopt",None,Kent Ross,|In Progress| -"| `[variant.relops] `_ -| `[variant.monostate.relops] `_","| monostate -| variant",None,Kent Ross,|In Progress| -| `[unique.ptr.special] `_,| unique_ptr,[comparisons.three.way],Unassigned,|Not Started| -| `[util.smartptr.shared.cmp] `_,| shared_ptr,[comparisons.three.way],Unassigned,|Not Started| -| `[type.index.members] `_,| type_index,None,Unassigned,|Not Started| -| `[charconv.syn] `_,| to_chars_result,None,Mark de Wever,|Complete| -| `[charconv.syn] `_,| from_chars_result,None,Mark de Wever,|Complete| -| `[stacktrace.entry.cmp] `_,| stacktrace_entry,None,Unassigned,|Not Started| -| `[stacktrace.basic.cmp] `_,| basic_stacktrace,[alg.three.way],Unassigned,|Not Started| -| `[string.cmp] `_,| `basic_string `_,None,Christopher Di Bella,|In Progress| -| `[string.view.comparison] `_,| `basic_string_view `_,None,Christopher Di Bella,|In Progress| -| `[array.syn] `_ (`general `_),| array,[expos.only.func],Unassigned,|Not Started| -| `[deque.syn] `_ (`general `_),| deque,[expos.only.func],Unassigned,|Not Started| -| `[forward.list.syn] `_ (`general `_),| forward_list,[expos.only.func],Unassigned,|Not Started| -| `[list.syn] `_ (`general `_),| list,[expos.only.func],Unassigned,|Not Started| -| `[vector.syn] `_ (`general `_),| vector,[expos.only.func],Unassigned,|Not Started| -| `[associative.map.syn] `_ (`general `_),"| map -| multimap",[expos.only.func],Unassigned,|Not Started| -| `[associative.set.syn] `_ (`general `_),"| multiset -| set",[expos.only.func],Unassigned,|Not Started| -| `[queue.ops] `_,| queue,None,Unassigned,|Not Started| -| `[stack.ops] `_,| stack,None,Unassigned,|Not Started| -| `[reverse.iter.cmp] `_,| reverse_iterator,None,Mikhail Maltsev,|Complete| -| `[move.iter.op.comp] `_,| move_iterator,None,Unassigned,|Not Started| -| `[counted.iter.cmp] `_,| counted_iterator,None,Unassigned,|Not Started| -| `[range.iota.iterator] `_,| ranges::iota_view::iterator,[concepts.cmp],Unassigned,|Not Started| -| `[range.transform.iterator] `_,| ranges::transform_view::iterator,[concepts.cmp],Unassigned,|Not Started| -| `[range.elements.iterator] `_,| ranges::elements_view::iterator,[concepts.cmp],Unassigned,|Not Started| -"| `[time.duration.comparisons] `_ -| `[time.point.comparisons] `_ -| `[time.cal.day.nonmembers] `_ -| `[time.cal.month.nonmembers] `_ -| `[time.cal.year.nonmembers] `_ -| `[time.cal.md.nonmembers] `_ -| `[time.cal.mdlast] `_ -| `[time.cal.ym.nonmembers] `_ -| `[time.cal.ymd.nonmembers] `_ -| `[time.cal.ymdlast.nonmembers] `_ -| `[time.zone.nonmembers] `_ -| `[time.zone.leap.nonmembers] `_ -| `[time.zone.link.nonmembers] `_","| chrono::duration -| chrono::time_point -| chrono::day -| chrono::month -| chrono::year -| chrono::month_day -| chrono::month_day_last -| chrono::year_month -| chrono::year_month_day -| chrono::year_month_day_last -| chrono::time_zone -| chrono::leap_second -| chrono::time_zone_link",None,Unassigned,|Not Started| -| `[fs.path.nonmember] `_,| filesystem::path,None,Unassigned,|Not Started| -| `[fs.dir.entry.obs] `_,| filesystem::directory_entry,None,Unassigned,|Not Started| -| `[re.submatch.op] `_,| sub_match,None,Unassigned,|Not Started| -| `[thread.thread.id] `_,| thread::id,None,Unassigned,|Not Started| diff --git a/docs/Status/Zip.rst b/docs/Status/Zip.rst deleted file mode 100644 index db2cdfe29..000000000 --- a/docs/Status/Zip.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. zip-status: - -=========================== -libc++ Zip Status (P2321R2) -=========================== - -.. include:: ../Helpers/Styles.rst - -.. contents:: - :local: - -Overview -======== - -This document contains the status of the C++2b zip implementation in libc++. -It is used to track both the status of the sub-projects of the effort and who -is assigned to these sub-projects. This avoids duplicating effort. - -If you are interested in contributing to this effort, please send a message -to the #libcxx channel in the LLVM discord. Please *do not* start working -on any items below that has already been assigned to someone else. - -Sub-projects in the Implementation Effort -========================================= - -.. csv-table:: - :file: ZipProjects.csv - :header-rows: 1 - :widths: auto diff --git a/docs/Status/ZipProjects.csv b/docs/Status/ZipProjects.csv deleted file mode 100644 index 4990d6b3e..000000000 --- a/docs/Status/ZipProjects.csv +++ /dev/null @@ -1,27 +0,0 @@ -Section,Description,Dependencies,Assignee,Complete -| `[tuple.syn] `_, "`[tuple] basic_common_reference, common_type `_", None, Nikolas Klauser, |In Progress| -| `[tuple.tuple] `_, "`[tuple] constructor, assignment and swap overloads `_", None, Nikolas Klauser, |In Progress| -| `[utility.syn] `_, "[pair] basic_common_reference, common_type", None, Nikolas Klauser, |Not Started| -| `[pairs.pair] `_, "[pair] constructor, assignment and swap overloads", None, Nikolas Klauser, |Not Started| -"| `[memory.syn] `_ -| `[allocator.uses.construction] `_", "[pair] uses_allocator_construction_args overloads", None, Unassigned, |Not Started| -| `[vector.bool] `_, "[vector::reference] add const operator= overload", None, Nikolas Klauser, |Not Started| -| `[iterator.concept.winc] `_, "Update weakly_comparable", None, Unassigned, |Not Started| -| `[range.zip] `_, "zip_view", "| `zip_view::iterator` -| `zip_view::sentinel`", Unassigned, |Not Started| -| `[range.zip.iterator] `_, "zip_view::iterator", None, Unassigned, |Not Started| -| `[range.zip.sentinel] `_, "zip_view::sentinel", None, Unassigned, |Not Started| -| `[range.zip.transform.view] `_, "zip_transform_view", "| `zip_transform_view::iterator` -| `zip_transform_view::sentinel`", Unassigned, |Not Started| -| `[range.zip.transform.iterator] `_, "zip_transform_view::iterator", None, Unassigned, |Not Started| -| `[range.zip.transform.sentinel] `_, "zip_transform_view::sentinel", None, Unassigned, |Not Started| -| `[range.adjacent.view] `_, "adjacent_view", "| `adjacent_view::iterator` -| `adjacent_view::sentinel`", Unassigned, |Not Started| -| `[range.adjacent.iterator] `_, "adjacent_view::iterator", None, Unassigned, |Not Started| -| `[range.adjacent.sentinel] `_, "adjacent_view::sentinel", None, Unassigned, |Not Started| -| `[range.adjacent.transform.view] `_, "adjacent_transform_view", "| `adjacent_transform_view::iterator`, -| `adjacent_transform_view::sentinel`", Unassigned, |Not Started| -| `[range.adjacent.transform.iterator] `_, "adjacent_transform_view::iterator", None, Unassigned, |Not Started| -| `[range.adjacent.transform.sentinel] `_, "adjacent_transform_view::sentinel", None, Unassigned, |Not Started| -| `[ranges.syn] `_, "enable_borrowed_range zip_view and adjacent_view", "| `zip_view` -| `adjacent_view`", Unassigned, |Not Started| diff --git a/docs/TestingLibcxx.rst b/docs/TestingLibcxx.rst index b5c7ae89c..ddb8a6d09 100644 --- a/docs/TestingLibcxx.rst +++ b/docs/TestingLibcxx.rst @@ -227,11 +227,12 @@ An example build would look like: .. code-block:: bash $ cd build - $ ninja cxx-benchmarks + $ cmake [options] + $ make cxx-benchmarks This will build all of the benchmarks under ``/benchmarks`` to be built against the just-built libc++. The compiled tests are output into -``build/projects/libcxx/benchmarks``. +``build/benchmarks``. The benchmarks can also be built against the platforms native standard library using the ``-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON`` CMake option. This @@ -254,7 +255,8 @@ For example: .. code-block:: bash - $ cd build/projects/libcxx/benchmarks + $ cd build/benchmarks + $ make cxx-benchmarks $ ./algorithms.libcxx.out # Runs all the benchmarks $ ./algorithms.libcxx.out --benchmark_filter=BM_Sort.* # Only runs the sort benchmarks diff --git a/docs/UsingLibcxx.rst b/docs/UsingLibcxx.rst index bd999f05c..863123688 100644 --- a/docs/UsingLibcxx.rst +++ b/docs/UsingLibcxx.rst @@ -338,7 +338,6 @@ which no dialect declares as such (See the second form described above). * ``upper_bound`` * ``lock_guard``'s constructors * ``as_const`` -* ``bit_cast`` * ``forward`` * ``move`` * ``move_if_noexcept`` diff --git a/docs/conf.py b/docs/conf.py index 6b0aad6b2..f3c904c8e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,9 +48,9 @@ copyright = u'2011-%d, LLVM Project' % date.today().year # built documents. # # The short X.Y version. -version = '14.0' +version = '13.0' # The full version, including alpha/beta/rc tags. -release = '14.0' +release = '13.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/index.rst b/docs/index.rst index b1560a51b..c52e42b14 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -43,10 +43,8 @@ Getting Started with libc++ Status/Cxx17 Status/Cxx20 Status/Cxx2b - Status/Format Status/Ranges - Status/Spaceship - Status/Zip + Status/Format .. toctree:: @@ -93,6 +91,7 @@ reasons, but some of the major ones are: Further, both projects are apparently abandoned: STLport 5.2.1 was released in Oct'08, and STDCXX 4.2.1 in May'08. +.. _platform_and_compiler_support: Platform and Compiler Support ============================= @@ -104,9 +103,8 @@ velocity, libc++ drops support for older compilers as newer ones are released. ============ =============== ========================== ===================== Compiler Versions Restrictions Support policy ============ =============== ========================== ===================== -Clang 12, 13 latest two stable releases per `LLVM's release page `_ +Clang 11, 12 latest two stable releases per `LLVM's release page `_ AppleClang 12 latest stable release per `Xcode's release page `_ -Open XL 17.1 (AIX) latest stable release per `Open XL's documentation page `_ GCC 11 In C++11 or later only latest stable release per `GCC's release page `_ ============ =============== ========================== ===================== @@ -118,8 +116,7 @@ Target platform Target architecture Notes macOS 10.9+ i386, x86_64, arm64 Building the shared library itself requires targetting macOS 10.11+ FreeBSD 10+ i386, x86_64, arm Linux i386, x86_64, arm, arm64 -Windows x86_64 Both MSVC and MinGW style environments -AIX powerpc, powerpc64 +Windows x86_64 =============== ========================= ============================ Generally speaking, libc++ should work on any platform that provides a fairly complete @@ -132,8 +129,8 @@ for all the platforms and compilers that we claim to support. If a platform or c is not listed here, it is not officially supported. It may happen to work, and in practice the library is known to work on some platforms not listed here, but we don't make any guarantees. If you would like your compiler and/or platform -to be formally supported and listed here, please work with the libc++ team to set -up testing for your configuration. +to be formally supported and listed here, +please work with the libc++ team to set up testing for your configuration. C++ Dialect Support @@ -158,7 +155,7 @@ This list contains known issues with libc++ A full list of currently open libc++ bugs can be `found here`__. -.. __: https://github.com/llvm/llvm-project/labels/libc%2B%2B +.. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 Design Documents @@ -178,7 +175,6 @@ Design Documents DesignDocs/NoexceptPolicy DesignDocs/ThreadingSupportAPI DesignDocs/UniquePtrTrivialAbi - DesignDocs/UnspecifiedBehaviorRandomization DesignDocs/VisibilityMacros @@ -199,7 +195,7 @@ and `Getting started with LLVM `__. **Bug Reports** If you think you've found a bug in libc++, please report it using -the `LLVM bug tracker`_. If you're not sure, you +the `LLVM Bugzilla`_. If you're not sure, you can post a message to the `libcxx-dev mailing list`_ or on IRC. **Patches** @@ -218,7 +214,7 @@ Quick Links =========== * `LLVM Homepage `_ * `libc++abi Homepage `_ -* `LLVM bug tracker `_ +* `LLVM Bugzilla `_ * `libcxx-commits Mailing List`_ * `libcxx-dev Mailing List`_ * `Browse libc++ Sources `_ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 53700fc9e..5fba76077 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -4,79 +4,76 @@ set(files __algorithm/any_of.h __algorithm/binary_search.h __algorithm/clamp.h - __algorithm/comp.h __algorithm/comp_ref_type.h - __algorithm/copy.h + __algorithm/comp.h __algorithm/copy_backward.h __algorithm/copy_if.h __algorithm/copy_n.h - __algorithm/count.h + __algorithm/copy.h __algorithm/count_if.h - __algorithm/equal.h + __algorithm/count.h __algorithm/equal_range.h - __algorithm/fill.h + __algorithm/equal.h __algorithm/fill_n.h - __algorithm/find.h + __algorithm/fill.h __algorithm/find_end.h __algorithm/find_first_of.h - __algorithm/find_if.h __algorithm/find_if_not.h - __algorithm/for_each.h + __algorithm/find_if.h + __algorithm/find.h __algorithm/for_each_n.h - __algorithm/generate.h + __algorithm/for_each.h __algorithm/generate_n.h + __algorithm/generate.h __algorithm/half_positive.h - __algorithm/in_in_out_result.h - __algorithm/in_in_result.h - __algorithm/in_out_result.h __algorithm/includes.h __algorithm/inplace_merge.h - __algorithm/is_heap.h __algorithm/is_heap_until.h + __algorithm/is_heap.h __algorithm/is_partitioned.h __algorithm/is_permutation.h - __algorithm/is_sorted.h __algorithm/is_sorted_until.h + __algorithm/is_sorted.h __algorithm/iter_swap.h __algorithm/lexicographical_compare.h __algorithm/lower_bound.h __algorithm/make_heap.h - __algorithm/max.h __algorithm/max_element.h + __algorithm/max.h __algorithm/merge.h - __algorithm/min.h __algorithm/min_element.h - __algorithm/minmax.h + __algorithm/min.h __algorithm/minmax_element.h + __algorithm/minmax.h __algorithm/mismatch.h - __algorithm/move.h __algorithm/move_backward.h + __algorithm/move.h __algorithm/next_permutation.h __algorithm/none_of.h __algorithm/nth_element.h - __algorithm/partial_sort.h __algorithm/partial_sort_copy.h - __algorithm/partition.h + __algorithm/partial_sort.h __algorithm/partition_copy.h __algorithm/partition_point.h + __algorithm/partition.h __algorithm/pop_heap.h __algorithm/prev_permutation.h __algorithm/push_heap.h - __algorithm/remove.h - __algorithm/remove_copy.h __algorithm/remove_copy_if.h + __algorithm/remove_copy.h __algorithm/remove_if.h - __algorithm/replace.h - __algorithm/replace_copy.h + __algorithm/remove.h __algorithm/replace_copy_if.h + __algorithm/replace_copy.h __algorithm/replace_if.h - __algorithm/reverse.h + __algorithm/replace.h __algorithm/reverse_copy.h - __algorithm/rotate.h + __algorithm/reverse.h __algorithm/rotate_copy.h + __algorithm/rotate.h __algorithm/sample.h - __algorithm/search.h __algorithm/search_n.h + __algorithm/search.h __algorithm/set_difference.h __algorithm/set_intersection.h __algorithm/set_symmetric_difference.h @@ -85,117 +82,34 @@ set(files __algorithm/shift_right.h __algorithm/shuffle.h __algorithm/sift_down.h - __algorithm/sort.h __algorithm/sort_heap.h + __algorithm/sort.h __algorithm/stable_partition.h __algorithm/stable_sort.h __algorithm/swap_ranges.h __algorithm/transform.h - __algorithm/unique.h __algorithm/unique_copy.h + __algorithm/unique.h __algorithm/unwrap_iter.h __algorithm/upper_bound.h __availability - __bit/bit_cast.h - __bit/byteswap.h __bit_reference __bits __bsd_locale_defaults.h __bsd_locale_fallbacks.h - __charconv/chars_format.h - __charconv/from_chars_result.h - __charconv/to_chars_result.h - __chrono/calendar.h - __chrono/convert_to_timespec.h - __chrono/duration.h - __chrono/file_clock.h - __chrono/high_resolution_clock.h - __chrono/steady_clock.h - __chrono/system_clock.h - __chrono/time_point.h - __compare/common_comparison_category.h - __compare/compare_partial_order_fallback.h - __compare/compare_strong_order_fallback.h - __compare/compare_three_way.h - __compare/compare_three_way_result.h - __compare/compare_weak_order_fallback.h - __compare/is_eq.h - __compare/ordering.h - __compare/partial_order.h - __compare/strong_order.h - __compare/synth_three_way.h - __compare/three_way_comparable.h - __compare/weak_order.h - __concepts/arithmetic.h - __concepts/assignable.h - __concepts/boolean_testable.h - __concepts/class_or_enum.h - __concepts/common_reference_with.h - __concepts/common_with.h - __concepts/constructible.h - __concepts/convertible_to.h - __concepts/copyable.h - __concepts/derived_from.h - __concepts/destructible.h - __concepts/different_from.h - __concepts/equality_comparable.h - __concepts/invocable.h - __concepts/movable.h - __concepts/predicate.h - __concepts/regular.h - __concepts/relation.h - __concepts/same_as.h - __concepts/semiregular.h - __concepts/swappable.h - __concepts/totally_ordered.h __config - __coroutine/coroutine_handle.h - __coroutine/coroutine_traits.h - __coroutine/noop_coroutine_handle.h - __coroutine/trivial_awaitables.h __debug __errc - __filesystem/copy_options.h - __filesystem/directory_entry.h - __filesystem/directory_iterator.h - __filesystem/directory_options.h - __filesystem/file_status.h - __filesystem/file_time_type.h - __filesystem/file_type.h - __filesystem/filesystem_error.h - __filesystem/operations.h - __filesystem/path.h - __filesystem/path_iterator.h - __filesystem/perm_options.h - __filesystem/perms.h - __filesystem/recursive_directory_iterator.h - __filesystem/space_info.h - __filesystem/u8path.h - __format/format_arg.h - __format/format_args.h - __format/format_context.h __format/format_error.h - __format/format_fwd.h __format/format_parse_context.h - __format/format_string.h - __format/format_to_n_result.h - __format/formatter.h - __format/formatter_bool.h - __format/formatter_char.h - __format/formatter_floating_point.h - __format/formatter_integer.h - __format/formatter_integral.h - __format/formatter_pointer.h - __format/formatter_string.h - __format/parser_std_format_spec.h + __function_like.h + __functional_base __functional/binary_function.h __functional/binary_negate.h - __functional/bind.h - __functional/bind_back.h __functional/bind_front.h + __functional/bind.h __functional/binder1st.h __functional/binder2nd.h - __functional/compose.h __functional/default_searcher.h __functional/function.h __functional/hash.h @@ -215,7 +129,6 @@ set(files __functional/unary_negate.h __functional/unwrap_ref.h __functional/weak_result_type.h - __functional_base __hash_table __iterator/access.h __iterator/advance.h @@ -230,14 +143,13 @@ set(files __iterator/erase_if_container.h __iterator/front_insert_iterator.h __iterator/incrementable_traits.h - __iterator/indirectly_comparable.h __iterator/insert_iterator.h __iterator/istream_iterator.h __iterator/istreambuf_iterator.h __iterator/iter_move.h __iterator/iter_swap.h - __iterator/iterator.h __iterator/iterator_traits.h + __iterator/iterator.h __iterator/move_iterator.h __iterator/next.h __iterator/ostream_iterator.h @@ -248,109 +160,47 @@ set(files __iterator/reverse_access.h __iterator/reverse_iterator.h __iterator/size.h - __iterator/unreachable_sentinel.h __iterator/wrap_iter.h __libcpp_version __locale - __mbstate_t.h __memory/addressof.h __memory/allocation_guard.h - __memory/allocator.h __memory/allocator_arg_t.h __memory/allocator_traits.h + __memory/allocator.h __memory/auto_ptr.h __memory/compressed_pair.h - __memory/concepts.h __memory/construct_at.h + __memory/pointer_safety.h __memory/pointer_traits.h - __memory/ranges_construct_at.h - __memory/ranges_uninitialized_algorithms.h __memory/raw_storage_iterator.h __memory/shared_ptr.h __memory/temporary_buffer.h __memory/uninitialized_algorithms.h __memory/unique_ptr.h __memory/uses_allocator.h - __memory/voidify.h __mutex_base __node_handle __nullptr - __numeric/accumulate.h - __numeric/adjacent_difference.h - __numeric/exclusive_scan.h - __numeric/gcd_lcm.h - __numeric/inclusive_scan.h - __numeric/inner_product.h - __numeric/iota.h - __numeric/midpoint.h - __numeric/partial_sum.h - __numeric/reduce.h - __numeric/transform_exclusive_scan.h - __numeric/transform_inclusive_scan.h - __numeric/transform_reduce.h - __random/bernoulli_distribution.h - __random/binomial_distribution.h - __random/cauchy_distribution.h - __random/chi_squared_distribution.h - __random/clamp_to_integral.h - __random/default_random_engine.h - __random/discard_block_engine.h - __random/discrete_distribution.h - __random/exponential_distribution.h - __random/extreme_value_distribution.h - __random/fisher_f_distribution.h - __random/gamma_distribution.h - __random/generate_canonical.h - __random/geometric_distribution.h - __random/independent_bits_engine.h - __random/is_seed_sequence.h - __random/knuth_b.h - __random/linear_congruential_engine.h - __random/log2.h - __random/lognormal_distribution.h - __random/mersenne_twister_engine.h - __random/negative_binomial_distribution.h - __random/normal_distribution.h - __random/piecewise_constant_distribution.h - __random/piecewise_linear_distribution.h - __random/poisson_distribution.h - __random/random_device.h - __random/ranlux.h - __random/seed_seq.h - __random/shuffle_order_engine.h - __random/student_t_distribution.h - __random/subtract_with_carry_engine.h __random/uniform_int_distribution.h - __random/uniform_random_bit_generator.h - __random/uniform_real_distribution.h - __random/weibull_distribution.h __ranges/access.h __ranges/all.h __ranges/common_view.h __ranges/concepts.h __ranges/copyable_box.h - __ranges/counted.h __ranges/dangling.h __ranges/data.h __ranges/drop_view.h - __ranges/empty.h __ranges/empty_view.h + __ranges/empty.h __ranges/enable_borrowed_range.h __ranges/enable_view.h - __ranges/iota_view.h - __ranges/join_view.h __ranges/non_propagating_cache.h - __ranges/owning_view.h - __ranges/range_adaptor.h __ranges/ref_view.h - __ranges/reverse_view.h - __ranges/single_view.h __ranges/size.h __ranges/subrange.h - __ranges/take_view.h __ranges/transform_view.h __ranges/view_interface.h - __ranges/views.h __split_buffer __std_stream __string @@ -358,12 +208,14 @@ set(files __support/fuchsia/xlocale.h __support/ibm/gettod_zos.h __support/ibm/limits.h + __support/ibm/locale_mgmt_aix.h __support/ibm/locale_mgmt_zos.h __support/ibm/nanosleep.h __support/ibm/support.h __support/ibm/xlocale.h __support/musl/xlocale.h __support/newlib/xlocale.h + __support/nuttx/xlocale.h __support/openbsd/xlocale.h __support/solaris/floatingpoint.h __support/solaris/wchar.h @@ -373,14 +225,12 @@ set(files __support/xlocale/__nop_locale_mgmt.h __support/xlocale/__posix_l_fallback.h __support/xlocale/__strtonum_fallback.h - __thread/poll_with_backoff.h - __thread/timed_backoff_policy.h __threading_support __tree __tuple __undef_macros + __utility/__decay_copy.h __utility/as_const.h - __utility/auto_cast.h __utility/cmp.h __utility/declval.h __utility/exchange.h @@ -390,11 +240,9 @@ set(files __utility/move.h __utility/pair.h __utility/piecewise_construct.h - __utility/priority_tag.h __utility/rel_ops.h __utility/swap.h __utility/to_underlying.h - __utility/transaction.h __variant/monostate.h algorithm any @@ -422,7 +270,6 @@ set(files complex.h concepts condition_variable - coroutine csetjmp csignal cstdarg @@ -501,6 +348,7 @@ set(files queue random ranges + ranges ratio regex scoped_allocator @@ -519,8 +367,8 @@ set(files stdlib.h streambuf string - string.h string_view + string.h strstream system_error tgmath.h @@ -570,7 +418,7 @@ if (LIBCXX_INSTALL_HEADERS) foreach(file ${files}) get_filename_component(dir ${file} DIRECTORY) install(FILES ${file} - DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}/${dir}" + DESTINATION ${LIBCXX_INSTALL_INCLUDE_DIR}/${dir} COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) @@ -578,7 +426,7 @@ if (LIBCXX_INSTALL_HEADERS) # Install the generated __config_site. install(FILES ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site - DESTINATION "${LIBCXX_INSTALL_INCLUDE_TARGET_DIR}" + DESTINATION ${LIBCXX_INSTALL_INCLUDE_TARGET_DIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT cxx-headers) diff --git a/include/__algorithm/adjacent_find.h b/include/__algorithm/adjacent_find.h index 29ad83f96..0a2aa055c 100644 --- a/include/__algorithm/adjacent_find.h +++ b/include/__algorithm/adjacent_find.h @@ -10,14 +10,17 @@ #ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -43,4 +46,6 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H diff --git a/include/__algorithm/all_of.h b/include/__algorithm/all_of.h index 817a4bc89..7d6ed5085 100644 --- a/include/__algorithm/all_of.h +++ b/include/__algorithm/all_of.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ALL_OF_H diff --git a/include/__algorithm/any_of.h b/include/__algorithm/any_of.h index f4116d913..d5a6c094a 100644 --- a/include/__algorithm/any_of.h +++ b/include/__algorithm/any_of.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ANY_OF_H diff --git a/include/__algorithm/binary_search.h b/include/__algorithm/binary_search.h index 2558dd0b2..766f5da16 100644 --- a/include/__algorithm/binary_search.h +++ b/include/__algorithm/binary_search.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H #define _LIBCPP___ALGORITHM_BINARY_SEARCH_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> -#include <__algorithm/lower_bound.h> #include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/lower_bound.h> +#include <__algorithm/comp_ref_type.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -50,6 +53,9 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va __less::value_type, _Tp>()); } + _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H diff --git a/include/__algorithm/clamp.h b/include/__algorithm/clamp.h index a51c1015b..f8eba03cf 100644 --- a/include/__algorithm/clamp.h +++ b/include/__algorithm/clamp.h @@ -9,17 +9,21 @@ #ifndef _LIBCPP___ALGORITHM_CLAMP_H #define _LIBCPP___ALGORITHM_CLAMP_H -#include <__algorithm/comp.h> #include <__config> #include <__debug> +#include <__algorithm/comp.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 +// clamp template _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR @@ -43,4 +47,6 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_CLAMP_H diff --git a/include/__algorithm/comp.h b/include/__algorithm/comp.h index b3f971e4f..2039cf7b3 100644 --- a/include/__algorithm/comp.h +++ b/include/__algorithm/comp.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // I'd like to replace these with _VSTD::equal_to, but can't because: @@ -89,4 +92,6 @@ struct __less<_T1, const _T1> _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COMP_H diff --git a/include/__algorithm/comp_ref_type.h b/include/__algorithm/comp_ref_type.h index 0802d2496..b3bca82c0 100644 --- a/include/__algorithm/comp_ref_type.h +++ b/include/__algorithm/comp_ref_type.h @@ -10,16 +10,15 @@ #define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H #include <__config> - -#ifdef _LIBCPP_DEBUG -# include <__debug> -# include <__utility/declval.h> -#endif +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #ifdef _LIBCPP_DEBUG @@ -28,11 +27,11 @@ template struct __debug_less { _Compare &__comp_; - _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_CONSTEXPR_AFTER_CXX17 __debug_less(_Compare& __c) : __comp_(__c) {} template - _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator()(const _Tp& __x, const _Up& __y) { bool __r = __comp_(__x, __y); @@ -42,7 +41,7 @@ struct __debug_less } template - _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator()(_Tp& __x, _Up& __y) { bool __r = __comp_(__x, __y); @@ -52,7 +51,7 @@ struct __debug_less } template - _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY decltype((void)declval<_Compare&>()( declval<_LHS &>(), declval<_RHS &>())) @@ -62,7 +61,7 @@ struct __debug_less } template - _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void __do_compare_assert(long, _LHS &, _RHS &) {} }; @@ -74,12 +73,15 @@ struct __comp_ref_type { // Pass the comparator by lvalue reference. Or in debug mode, using a // debugging wrapper that stores a reference. #ifndef _LIBCPP_DEBUG - typedef _Comp& type; + typedef typename add_lvalue_reference<_Comp>::type type; #else typedef __debug_less<_Comp> type; #endif }; + _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H diff --git a/include/__algorithm/copy.h b/include/__algorithm/copy.h index 65f0e0b0e..9db7434c0 100644 --- a/include/__algorithm/copy.h +++ b/include/__algorithm/copy.h @@ -9,8 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_COPY_H #define _LIBCPP___ALGORITHM_COPY_H -#include <__algorithm/unwrap_iter.h> #include <__config> +#include <__algorithm/unwrap_iter.h> #include <__iterator/iterator_traits.h> #include #include @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // copy @@ -74,4 +77,6 @@ copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COPY_H diff --git a/include/__algorithm/copy_backward.h b/include/__algorithm/copy_backward.h index ac733290a..03a9c5f2d 100644 --- a/include/__algorithm/copy_backward.h +++ b/include/__algorithm/copy_backward.h @@ -9,8 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H -#include <__algorithm/unwrap_iter.h> #include <__config> +#include <__algorithm/unwrap_iter.h> #include <__iterator/iterator_traits.h> #include #include @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -76,4 +79,6 @@ copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H diff --git a/include/__algorithm/copy_if.h b/include/__algorithm/copy_if.h index d32514d99..153304c7a 100644 --- a/include/__algorithm/copy_if.h +++ b/include/__algorithm/copy_if.h @@ -10,11 +10,18 @@ #define _LIBCPP___ALGORITHM_COPY_IF_H #include <__config> +#include <__algorithm/unwrap_iter.h> +#include <__iterator/iterator_traits.h> +#include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -36,4 +43,6 @@ copy_if(_InputIterator __first, _InputIterator __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COPY_IF_H diff --git a/include/__algorithm/copy_n.h b/include/__algorithm/copy_n.h index cdcc0d50d..bbfeb8686 100644 --- a/include/__algorithm/copy_n.h +++ b/include/__algorithm/copy_n.h @@ -9,15 +9,20 @@ #ifndef _LIBCPP___ALGORITHM_COPY_N_H #define _LIBCPP___ALGORITHM_COPY_N_H -#include <__algorithm/copy.h> #include <__config> +#include <__algorithm/copy.h> +#include <__algorithm/unwrap_iter.h> #include <__iterator/iterator_traits.h> +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -55,12 +60,13 @@ typename enable_if >::type copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { - typedef typename iterator_traits<_InputIterator>::difference_type difference_type; typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; _IntegralSize __n = __orig_n; - return _VSTD::copy(__first, __first + difference_type(__n), __result); + return _VSTD::copy(__first, __first + __n, __result); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COPY_N_H diff --git a/include/__algorithm/count.h b/include/__algorithm/count.h index 81a2c186f..7f2d1954c 100644 --- a/include/__algorithm/count.h +++ b/include/__algorithm/count.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -32,4 +35,6 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COUNT_H diff --git a/include/__algorithm/count_if.h b/include/__algorithm/count_if.h index 00f5d671d..a5efffb92 100644 --- a/include/__algorithm/count_if.h +++ b/include/__algorithm/count_if.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -32,4 +35,6 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COUNT_IF_H diff --git a/include/__algorithm/equal.h b/include/__algorithm/equal.h index 4c9ad05ad..bc6755981 100644 --- a/include/__algorithm/equal.h +++ b/include/__algorithm/equal.h @@ -10,15 +10,18 @@ #ifndef _LIBCPP___ALGORITHM_EQUAL_H #define _LIBCPP___ALGORITHM_EQUAL_H -#include <__algorithm/comp.h> #include <__config> -#include <__iterator/distance.h> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> +#include // FIXME: replace with <__iterator/distance.h> when it lands #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -57,14 +60,14 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) return false; return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, - _BinaryPredicate&>(__first1, __last1, __first2, __pred); + typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, __pred); } template _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred) { - return _VSTD::__equal<_BinaryPredicate&>( + return _VSTD::__equal::type>( __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(), typename iterator_traits<_InputIterator2>::iterator_category()); } @@ -82,4 +85,6 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_EQUAL_H diff --git a/include/__algorithm/equal_range.h b/include/__algorithm/equal_range.h index e13f0bdd9..9694dae95 100644 --- a/include/__algorithm/equal_range.h +++ b/include/__algorithm/equal_range.h @@ -9,18 +9,21 @@ #ifndef _LIBCPP___ALGORITHM_EQUAL_RANGE_H #define _LIBCPP___ALGORITHM_EQUAL_RANGE_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/half_positive.h> #include <__algorithm/lower_bound.h> #include <__algorithm/upper_bound.h> -#include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -79,4 +82,6 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H diff --git a/include/__algorithm/fill.h b/include/__algorithm/fill.h index 0cb36b02c..4fefe8653 100644 --- a/include/__algorithm/fill.h +++ b/include/__algorithm/fill.h @@ -9,8 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_FILL_H #define _LIBCPP___ALGORITHM_FILL_H -#include <__algorithm/fill_n.h> #include <__config> +#include <__algorithm/fill_n.h> #include <__iterator/iterator_traits.h> #include @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -47,4 +50,6 @@ fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FILL_H diff --git a/include/__algorithm/fill_n.h b/include/__algorithm/fill_n.h index 857ac1415..34a245edb 100644 --- a/include/__algorithm/fill_n.h +++ b/include/__algorithm/fill_n.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -39,4 +42,6 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FILL_N_H diff --git a/include/__algorithm/find.h b/include/__algorithm/find.h index 2a6dfbe41..bc593dc54 100644 --- a/include/__algorithm/find.h +++ b/include/__algorithm/find.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_H diff --git a/include/__algorithm/find_end.h b/include/__algorithm/find_end.h index dd0f7d7ac..f4277f003 100644 --- a/include/__algorithm/find_end.h +++ b/include/__algorithm/find_end.h @@ -10,14 +10,18 @@ #ifndef _LIBCPP___ALGORITHM_FIND_END_OF_H #define _LIBCPP___ALGORITHM_FIND_END_OF_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -95,16 +99,14 @@ template ::difference_type _D1; - typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2; // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern - _D2 __len2 = __last2 - __first2; + typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2; if (__len2 == 0) return __last1; - _D1 __len1 = __last1 - __first1; + typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1; if (__len1 < __len2) return __last1; - const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here + const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here _RandomAccessIterator1 __l1 = __last1; _RandomAccessIterator2 __l2 = __last2; --__l2; @@ -132,7 +134,7 @@ template ( + return _VSTD::__find_end::type>( __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()); } @@ -147,4 +149,6 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_END_OF_H diff --git a/include/__algorithm/find_first_of.h b/include/__algorithm/find_first_of.h index 69354f617..d956c8dda 100644 --- a/include/__algorithm/find_first_of.h +++ b/include/__algorithm/find_first_of.h @@ -10,14 +10,17 @@ #ifndef _LIBCPP___ALGORITHM_FIND_FIRST_OF_H #define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -49,4 +52,6 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H diff --git a/include/__algorithm/find_if.h b/include/__algorithm/find_if.h index a94196a16..456cc5b0a 100644 --- a/include/__algorithm/find_if.h +++ b/include/__algorithm/find_if.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_IF_H diff --git a/include/__algorithm/find_if_not.h b/include/__algorithm/find_if_not.h index e057db5ef..d7d25160c 100644 --- a/include/__algorithm/find_if_not.h +++ b/include/__algorithm/find_if_not.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H diff --git a/include/__algorithm/for_each.h b/include/__algorithm/for_each.h index 1612ffa5c..e71a36a1d 100644 --- a/include/__algorithm/for_each.h +++ b/include/__algorithm/for_each.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_eac _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FOR_EACH_H diff --git a/include/__algorithm/for_each_n.h b/include/__algorithm/for_each_n.h index 00e3fb9c1..77f6c8621 100644 --- a/include/__algorithm/for_each_n.h +++ b/include/__algorithm/for_each_n.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 @@ -39,4 +42,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator fo _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H diff --git a/include/__algorithm/generate.h b/include/__algorithm/generate.h index 10834cdb7..d3e1133e2 100644 --- a/include/__algorithm/generate.h +++ b/include/__algorithm/generate.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -28,4 +31,6 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_GENERATE_H diff --git a/include/__algorithm/generate_n.h b/include/__algorithm/generate_n.h index 595007cdd..c31259858 100644 --- a/include/__algorithm/generate_n.h +++ b/include/__algorithm/generate_n.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -32,4 +35,6 @@ generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_GENERATE_N_H diff --git a/include/__algorithm/half_positive.h b/include/__algorithm/half_positive.h index 5d36ff5da..b03efc495 100644 --- a/include/__algorithm/half_positive.h +++ b/include/__algorithm/half_positive.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // Perform division by two quickly for positive integers (llvm.org/PR39129) @@ -46,4 +49,6 @@ __half_positive(_Tp __value) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H diff --git a/include/__algorithm/in_in_out_result.h b/include/__algorithm/in_in_out_result.h deleted file mode 100644 index 8d29b7b69..000000000 --- a/include/__algorithm/in_in_out_result.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H -#define _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H - -#include <__concepts/convertible_to.h> -#include <__config> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -namespace ranges { - -template -struct in_in_out_result { - [[no_unique_address]] _I1 in1; - [[no_unique_address]] _I2 in2; - [[no_unique_address]] _O1 out; - - template - requires convertible_to && convertible_to && convertible_to - _LIBCPP_HIDE_FROM_ABI constexpr - operator in_in_out_result<_II1, _II2, _OO1>() const& { - return {in1, in2, out}; - } - - template - requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1> - _LIBCPP_HIDE_FROM_ABI constexpr - operator in_in_out_result<_II1, _II2, _OO1>() && { - return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)}; - } -}; - -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H diff --git a/include/__algorithm/in_in_result.h b/include/__algorithm/in_in_result.h deleted file mode 100644 index c8fe43d03..000000000 --- a/include/__algorithm/in_in_result.h +++ /dev/null @@ -1,51 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ALGORITHM_IN_IN_RESULT_H -#define _LIBCPP___ALGORITHM_IN_IN_RESULT_H - -#include <__concepts/convertible_to.h> -#include <__config> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace ranges { - -template -struct in_in_result { - [[no_unique_address]] _I1 in1; - [[no_unique_address]] _I2 in2; - - template - requires convertible_to && convertible_to - _LIBCPP_HIDE_FROM_ABI constexpr - operator in_in_result<_II1, _II2>() const & { - return {in1, in2}; - } - - template - requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> - _LIBCPP_HIDE_FROM_ABI constexpr - operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; } -}; - -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H diff --git a/include/__algorithm/in_out_result.h b/include/__algorithm/in_out_result.h deleted file mode 100644 index dcf72d08d..000000000 --- a/include/__algorithm/in_out_result.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ALGORITHM_IN_OUT_RESULT_H -#define _LIBCPP___ALGORITHM_IN_OUT_RESULT_H - -#include <__concepts/convertible_to.h> -#include <__config> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -namespace ranges { - -template -struct in_out_result { - [[no_unique_address]] _InputIterator in; - [[no_unique_address]] _OutputIterator out; - - template - requires convertible_to && convertible_to - _LIBCPP_HIDE_FROM_ABI - constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & { - return {in, out}; - } - - template - requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2> - _LIBCPP_HIDE_FROM_ABI - constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && { - return {_VSTD::move(in), _VSTD::move(out)}; - } -}; - -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H diff --git a/include/__algorithm/includes.h b/include/__algorithm/includes.h index 9d0bc694c..ff298a511 100644 --- a/include/__algorithm/includes.h +++ b/include/__algorithm/includes.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_INCLUDES_H #define _LIBCPP___ALGORITHM_INCLUDES_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -59,4 +62,6 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_INCLUDES_H diff --git a/include/__algorithm/inplace_merge.h b/include/__algorithm/inplace_merge.h index e6f1efc01..c74633a74 100644 --- a/include/__algorithm/inplace_merge.h +++ b/include/__algorithm/inplace_merge.h @@ -9,14 +9,14 @@ #ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H #define _LIBCPP___ALGORITHM_INPLACE_MERGE_H -#include <__algorithm/comp.h> +#include <__config> #include <__algorithm/comp_ref_type.h> +#include <__algorithm/comp.h> #include <__algorithm/lower_bound.h> #include <__algorithm/min.h> #include <__algorithm/move.h> #include <__algorithm/rotate.h> #include <__algorithm/upper_bound.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> #include diff --git a/include/__algorithm/is_heap.h b/include/__algorithm/is_heap.h index 925ba8bfb..bc3682d47 100644 --- a/include/__algorithm/is_heap.h +++ b/include/__algorithm/is_heap.h @@ -9,16 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_IS_HEAP_H #define _LIBCPP___ALGORITHM_IS_HEAP_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> -#include <__algorithm/is_heap_until.h> #include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/is_heap_until.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -27,8 +29,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last; + return _VSTD::is_heap_until(__first, __last, __comp) == __last; } template @@ -42,4 +43,6 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_HEAP_H diff --git a/include/__algorithm/is_heap_until.h b/include/__algorithm/is_heap_until.h index aa23b6d03..8c52edb7d 100644 --- a/include/__algorithm/is_heap_until.h +++ b/include/__algorithm/is_heap_until.h @@ -9,20 +9,22 @@ #ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H #define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator -__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator +is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; difference_type __len = __last - __first; @@ -47,21 +49,17 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co return __last; } -template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator -is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) -{ - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp); -} - template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { - return _VSTD::__is_heap_until(__first, __last, __less::value_type>()); + return _VSTD::is_heap_until(__first, __last, __less::value_type>()); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H diff --git a/include/__algorithm/is_partitioned.h b/include/__algorithm/is_partitioned.h index e5b2214aa..43de6650c 100644 --- a/include/__algorithm/is_partitioned.h +++ b/include/__algorithm/is_partitioned.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -35,4 +38,6 @@ is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H diff --git a/include/__algorithm/is_permutation.h b/include/__algorithm/is_permutation.h index 344aa763a..0545eb763 100644 --- a/include/__algorithm/is_permutation.h +++ b/include/__algorithm/is_permutation.h @@ -12,14 +12,17 @@ #include <__algorithm/comp.h> #include <__config> -#include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> +#include // FIXME: replace with <__iterator/distance.h> when it lands #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -133,14 +136,15 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __fir if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) return false; return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, - _BinaryPredicate&>(__first1, __last1, __first2, __pred); + typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, + __pred); } template _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) { - return _VSTD::__is_permutation<_BinaryPredicate&>( + return _VSTD::__is_permutation::type>( __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()); } @@ -159,4 +163,6 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H diff --git a/include/__algorithm/is_sorted.h b/include/__algorithm/is_sorted.h index 57953295a..30d8da049 100644 --- a/include/__algorithm/is_sorted.h +++ b/include/__algorithm/is_sorted.h @@ -10,7 +10,6 @@ #define _LIBCPP___ALGORITHM_IS_SORTED_H #include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> #include <__algorithm/is_sorted_until.h> #include <__config> #include <__iterator/iterator_traits.h> @@ -19,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -27,8 +29,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last; + return _VSTD::is_sorted_until(__first, __last, __comp) == __last; } template @@ -42,4 +43,6 @@ is_sorted(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_SORTED_H diff --git a/include/__algorithm/is_sorted_until.h b/include/__algorithm/is_sorted_until.h index 57cad4776..a914b5a56 100644 --- a/include/__algorithm/is_sorted_until.h +++ b/include/__algorithm/is_sorted_until.h @@ -9,20 +9,22 @@ #ifndef _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H #define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator -__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) { @@ -37,16 +39,10 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __ return __last; } -template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator -is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) -{ - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp); -} - template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::is_sorted_until(__first, __last, __less::value_type>()); @@ -54,4 +50,6 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H diff --git a/include/__algorithm/iter_swap.h b/include/__algorithm/iter_swap.h index 9f7d0d776..b63bce62c 100644 --- a/include/__algorithm/iter_swap.h +++ b/include/__algorithm/iter_swap.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_F _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ITER_SWAP_H diff --git a/include/__algorithm/lexicographical_compare.h b/include/__algorithm/lexicographical_compare.h index 55a1da620..6e4a90bdc 100644 --- a/include/__algorithm/lexicographical_compare.h +++ b/include/__algorithm/lexicographical_compare.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H #define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -60,4 +63,6 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H diff --git a/include/__algorithm/lower_bound.h b/include/__algorithm/lower_bound.h index 663a0b162..1448c8963 100644 --- a/include/__algorithm/lower_bound.h +++ b/include/__algorithm/lower_bound.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_LOWER_BOUND_H #define _LIBCPP___ALGORITHM_LOWER_BOUND_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/half_positive.h> -#include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -48,7 +51,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { - return _VSTD::__lower_bound<_Compare&>(__first, __last, __value_, __comp); + typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -63,4 +67,6 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H diff --git a/include/__algorithm/make_heap.h b/include/__algorithm/make_heap.h index f489addaf..eca4013cb 100644 --- a/include/__algorithm/make_heap.h +++ b/include/__algorithm/make_heap.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_MAKE_HEAP_H #define _LIBCPP___ALGORITHM_MAKE_HEAP_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/sift_down.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -32,7 +35,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar // start from the first parent, there is no need to consider children for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) { - _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start); + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); } } } @@ -56,4 +59,6 @@ make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H diff --git a/include/__algorithm/max.h b/include/__algorithm/max.h index 0bbc971e0..2fa97cad8 100644 --- a/include/__algorithm/max.h +++ b/include/__algorithm/max.h @@ -9,10 +9,9 @@ #ifndef _LIBCPP___ALGORITHM_MAX_H #define _LIBCPP___ALGORITHM_MAX_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> -#include <__algorithm/max_element.h> #include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/max_element.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -50,8 +49,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t, _Compare __comp) { - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp); + return *_VSTD::max_element(__t.begin(), __t.end(), __comp); } template diff --git a/include/__algorithm/max_element.h b/include/__algorithm/max_element.h index db2937260..b93b67eac 100644 --- a/include/__algorithm/max_element.h +++ b/include/__algorithm/max_element.h @@ -9,20 +9,24 @@ #ifndef _LIBCPP___ALGORITHM_MAX_ELEMENT_H #define _LIBCPP___ALGORITHM_MAX_ELEMENT_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, "std::max_element requires a ForwardIterator"); @@ -36,17 +40,11 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp return __first; } -template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) -{ - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp); -} - template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::max_element(__first, __last, @@ -55,4 +53,6 @@ max_element(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H diff --git a/include/__algorithm/merge.h b/include/__algorithm/merge.h index 918264937..ea53ad68f 100644 --- a/include/__algorithm/merge.h +++ b/include/__algorithm/merge.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_MERGE_H #define _LIBCPP___ALGORITHM_MERGE_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -68,4 +71,6 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MERGE_H diff --git a/include/__algorithm/min.h b/include/__algorithm/min.h index ed2d3b878..9fea7f70a 100644 --- a/include/__algorithm/min.h +++ b/include/__algorithm/min.h @@ -9,10 +9,9 @@ #ifndef _LIBCPP___ALGORITHM_MIN_H #define _LIBCPP___ALGORITHM_MIN_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> -#include <__algorithm/min_element.h> #include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/min_element.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -50,8 +49,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t, _Compare __comp) { - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp); + return *_VSTD::min_element(__t.begin(), __t.end(), __comp); } template diff --git a/include/__algorithm/min_element.h b/include/__algorithm/min_element.h index 407c7f933..6bff140e5 100644 --- a/include/__algorithm/min_element.h +++ b/include/__algorithm/min_element.h @@ -9,20 +9,24 @@ #ifndef _LIBCPP___ALGORITHM_MIN_ELEMENT_H #define _LIBCPP___ALGORITHM_MIN_ELEMENT_H -#include <__algorithm/comp.h> -#include <__algorithm/comp_ref_type.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, "std::min_element requires a ForwardIterator"); @@ -36,16 +40,10 @@ __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp return __first; } -template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator -min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) -{ - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp); -} - template -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { return _VSTD::min_element(__first, __last, @@ -54,4 +52,6 @@ min_element(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H diff --git a/include/__algorithm/minmax.h b/include/__algorithm/minmax.h index 0bf88a70b..63753f2fe 100644 --- a/include/__algorithm/minmax.h +++ b/include/__algorithm/minmax.h @@ -9,15 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_MINMAX_H #define _LIBCPP___ALGORITHM_MINMAX_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include #include + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -92,4 +96,6 @@ minmax(initializer_list<_Tp> __t) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MINMAX_H diff --git a/include/__algorithm/minmax_element.h b/include/__algorithm/minmax_element.h index 5d7686038..1eba006de 100644 --- a/include/__algorithm/minmax_element.h +++ b/include/__algorithm/minmax_element.h @@ -9,8 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H #define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #include @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -82,4 +85,6 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H diff --git a/include/__algorithm/mismatch.h b/include/__algorithm/mismatch.h index 230ade03d..fdd2bc8c0 100644 --- a/include/__algorithm/mismatch.h +++ b/include/__algorithm/mismatch.h @@ -10,8 +10,8 @@ #ifndef _LIBCPP___ALGORITHM_MISMATCH_H #define _LIBCPP___ALGORITHM_MISMATCH_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #include @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -64,4 +67,6 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MISMATCH_H diff --git a/include/__algorithm/move.h b/include/__algorithm/move.h index fa118f471..f5fc74854 100644 --- a/include/__algorithm/move.h +++ b/include/__algorithm/move.h @@ -9,17 +9,20 @@ #ifndef _LIBCPP___ALGORITHM_MOVE_H #define _LIBCPP___ALGORITHM_MOVE_H -#include <__algorithm/unwrap_iter.h> #include <__config> +#include <__algorithm/unwrap_iter.h> #include <__utility/move.h> #include -#include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // move @@ -75,4 +78,6 @@ move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MOVE_H diff --git a/include/__algorithm/move_backward.h b/include/__algorithm/move_backward.h index a4e3828b6..1c93b9819 100644 --- a/include/__algorithm/move_backward.h +++ b/include/__algorithm/move_backward.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H -#include <__algorithm/unwrap_iter.h> #include <__config> +#include <__algorithm/unwrap_iter.h> #include -#include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -76,4 +79,6 @@ move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H diff --git a/include/__algorithm/next_permutation.h b/include/__algorithm/next_permutation.h index eb81cceb7..a337e5efa 100644 --- a/include/__algorithm/next_permutation.h +++ b/include/__algorithm/next_permutation.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H #define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/reverse.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -69,4 +72,6 @@ next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H diff --git a/include/__algorithm/none_of.h b/include/__algorithm/none_of.h index 10339e241..285691520 100644 --- a/include/__algorithm/none_of.h +++ b/include/__algorithm/none_of.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_NONE_OF_H diff --git a/include/__algorithm/nth_element.h b/include/__algorithm/nth_element.h index 3afbd6c61..67a03cfc3 100644 --- a/include/__algorithm/nth_element.h +++ b/include/__algorithm/nth_element.h @@ -9,21 +9,20 @@ #ifndef _LIBCPP___ALGORITHM_NTH_ELEMENT_H #define _LIBCPP___ALGORITHM_NTH_ELEMENT_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/sort.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> -#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) -# include <__algorithm/shuffle.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -226,13 +225,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { - _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); - _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __nth); - if (__nth != __last) { - _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last); - } + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); } template @@ -245,4 +239,6 @@ nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomA _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H diff --git a/include/__algorithm/partial_sort.h b/include/__algorithm/partial_sort.h index a92a7e566..4f9872c49 100644 --- a/include/__algorithm/partial_sort.h +++ b/include/__algorithm/partial_sort.h @@ -9,32 +9,29 @@ #ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_H #define _LIBCPP___ALGORITHM_PARTIAL_SORT_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/make_heap.h> #include <__algorithm/sift_down.h> #include <__algorithm/sort_heap.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> -#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) -# include <__algorithm/shuffle.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template _LIBCPP_CONSTEXPR_AFTER_CXX17 void __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, - _Compare __comp) + _Compare __comp) { - if (__first == __middle) - return; _VSTD::__make_heap<_Compare>(__first, __middle, __comp); typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) @@ -42,7 +39,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R if (__comp(*__i, *__first)) { swap(*__i, *__first); - _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first); + _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first); } } _VSTD::__sort_heap<_Compare>(__first, __middle, __comp); @@ -54,10 +51,8 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { - _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); - _LIBCPP_DEBUG_RANDOMIZE_RANGE(__middle, __last); + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); } template @@ -66,9 +61,11 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) { _VSTD::partial_sort(__first, __middle, __last, - __less::value_type>()); + __less::value_type>()); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H diff --git a/include/__algorithm/partial_sort_copy.h b/include/__algorithm/partial_sort_copy.h index 67a62bae1..31a12615f 100644 --- a/include/__algorithm/partial_sort_copy.h +++ b/include/__algorithm/partial_sort_copy.h @@ -9,18 +9,22 @@ #ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H #define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/make_heap.h> #include <__algorithm/sift_down.h> #include <__algorithm/sort_heap.h> -#include <__config> #include <__iterator/iterator_traits.h> +#include // swap #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -39,7 +43,7 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last, if (__comp(*__first, *__result_first)) { *__result_first = *__first; - _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first); + _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); } _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp); } @@ -68,4 +72,6 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H diff --git a/include/__algorithm/partition.h b/include/__algorithm/partition.h index 131c5d373..c859eaca2 100644 --- a/include/__algorithm/partition.h +++ b/include/__algorithm/partition.h @@ -12,11 +12,16 @@ #include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> +#include // pair +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -72,10 +77,12 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - return _VSTD::__partition<_Predicate&>( - __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); + return _VSTD::__partition::type> + (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PARTITION_H diff --git a/include/__algorithm/partition_copy.h b/include/__algorithm/partition_copy.h index d34944589..445eacdfb 100644 --- a/include/__algorithm/partition_copy.h +++ b/include/__algorithm/partition_copy.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template #include <__config> +#include <__algorithm/half_positive.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -43,4 +46,6 @@ partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __ _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H diff --git a/include/__algorithm/pop_heap.h b/include/__algorithm/pop_heap.h index c1cc8016a..7ebbef25e 100644 --- a/include/__algorithm/pop_heap.h +++ b/include/__algorithm/pop_heap.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___ALGORITHM_POP_HEAP_H #define _LIBCPP___ALGORITHM_POP_HEAP_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/sift_down.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -31,7 +34,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare if (__len > 1) { swap(*__first, *--__last); - _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first); + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); } } @@ -54,4 +57,6 @@ pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_POP_HEAP_H diff --git a/include/__algorithm/prev_permutation.h b/include/__algorithm/prev_permutation.h index 457c2695b..d6daa73ad 100644 --- a/include/__algorithm/prev_permutation.h +++ b/include/__algorithm/prev_permutation.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___ALGORITHM_PREV_PERMUTATION_H #define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/reverse.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -69,4 +72,6 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H diff --git a/include/__algorithm/push_heap.h b/include/__algorithm/push_heap.h index 864d419fa..82a7c123d 100644 --- a/include/__algorithm/push_heap.h +++ b/include/__algorithm/push_heap.h @@ -9,9 +9,9 @@ #ifndef _LIBCPP___ALGORITHM_PUSH_HEAP_H #define _LIBCPP___ALGORITHM_PUSH_HEAP_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/move.h> @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -67,4 +70,6 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H diff --git a/include/__algorithm/remove.h b/include/__algorithm/remove.h index 681b9cc76..4717d7d97 100644 --- a/include/__algorithm/remove.h +++ b/include/__algorithm/remove.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_REMOVE_H #define _LIBCPP___ALGORITHM_REMOVE_H +#include <__config> #include <__algorithm/find.h> #include <__algorithm/find_if.h> -#include <__config> #include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -42,4 +45,6 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REMOVE_H diff --git a/include/__algorithm/remove_copy.h b/include/__algorithm/remove_copy.h index 338ca9430..5d2b64034 100644 --- a/include/__algorithm/remove_copy.h +++ b/include/__algorithm/remove_copy.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -35,4 +38,6 @@ remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H diff --git a/include/__algorithm/remove_copy_if.h b/include/__algorithm/remove_copy_if.h index a55638722..44822564a 100644 --- a/include/__algorithm/remove_copy_if.h +++ b/include/__algorithm/remove_copy_if.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -35,4 +38,6 @@ remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __ _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H diff --git a/include/__algorithm/remove_if.h b/include/__algorithm/remove_if.h index 36f817cfa..e506b4c67 100644 --- a/include/__algorithm/remove_if.h +++ b/include/__algorithm/remove_if.h @@ -9,21 +9,26 @@ #ifndef _LIBCPP___ALGORITHM_REMOVE_IF_H #define _LIBCPP___ALGORITHM_REMOVE_IF_H -#include <__algorithm/find_if.h> #include <__config> +#include <__algorithm/find_if.h> #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); + __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type> + (__first, __last, __pred); if (__first != __last) { _ForwardIterator __i = __first; @@ -41,4 +46,6 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REMOVE_IF_H diff --git a/include/__algorithm/replace.h b/include/__algorithm/replace.h index 2bc96ffc8..b723ffeea 100644 --- a/include/__algorithm/replace.h +++ b/include/__algorithm/replace.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_valu _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REPLACE_H diff --git a/include/__algorithm/replace_copy.h b/include/__algorithm/replace_copy.h index c6c5fe32e..1923a57e4 100644 --- a/include/__algorithm/replace_copy.h +++ b/include/__algorithm/replace_copy.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -33,4 +36,6 @@ replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __re _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H diff --git a/include/__algorithm/replace_copy_if.h b/include/__algorithm/replace_copy_if.h index 274d8e630..72b6f7369 100644 --- a/include/__algorithm/replace_copy_if.h +++ b/include/__algorithm/replace_copy_if.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -33,4 +36,6 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _ _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H diff --git a/include/__algorithm/replace_if.h b/include/__algorithm/replace_if.h index bcc3feb2f..49101a5ce 100644 --- a/include/__algorithm/replace_if.h +++ b/include/__algorithm/replace_if.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REPLACE_IF_H diff --git a/include/__algorithm/reverse.h b/include/__algorithm/reverse.h index 1198aeaf4..e538de114 100644 --- a/include/__algorithm/reverse.h +++ b/include/__algorithm/reverse.h @@ -9,14 +9,17 @@ #ifndef _LIBCPP___ALGORITHM_REVERSE_H #define _LIBCPP___ALGORITHM_REVERSE_H -#include <__algorithm/iter_swap.h> #include <__config> +#include <__algorithm/iter_swap.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -53,4 +56,6 @@ reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REVERSE_H diff --git a/include/__algorithm/reverse_copy.h b/include/__algorithm/reverse_copy.h index 002c0344a..48ce60cf8 100644 --- a/include/__algorithm/reverse_copy.h +++ b/include/__algorithm/reverse_copy.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H diff --git a/include/__algorithm/rotate.h b/include/__algorithm/rotate.h index fd6d3e9c1..0c9ccd7bf 100644 --- a/include/__algorithm/rotate.h +++ b/include/__algorithm/rotate.h @@ -23,6 +23,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -197,4 +200,6 @@ rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __l _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ROTATE_H diff --git a/include/__algorithm/rotate_copy.h b/include/__algorithm/rotate_copy.h index f9e644c88..d5ab7d3b5 100644 --- a/include/__algorithm/rotate_copy.h +++ b/include/__algorithm/rotate_copy.h @@ -9,13 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_ROTATE_COPY_H #define _LIBCPP___ALGORITHM_ROTATE_COPY_H -#include <__algorithm/copy.h> #include <__config> +#include <__algorithm/copy.h> +#include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -28,4 +33,6 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H diff --git a/include/__algorithm/sample.h b/include/__algorithm/sample.h index 33264c4ea..2aac6ffa8 100644 --- a/include/__algorithm/sample.h +++ b/include/__algorithm/sample.h @@ -9,9 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_SAMPLE_H #define _LIBCPP___ALGORITHM_SAMPLE_H -#include <__algorithm/min.h> #include <__config> -#include <__debug> +#include <__algorithm/min.h> #include <__random/uniform_int_distribution.h> #include diff --git a/include/__algorithm/search.h b/include/__algorithm/search.h index cfaec0ed1..008b8ebb0 100644 --- a/include/__algorithm/search.h +++ b/include/__algorithm/search.h @@ -13,12 +13,16 @@ #include <__algorithm/comp.h> #include <__config> #include <__iterator/iterator_traits.h> +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -68,7 +72,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando const _D1 __len1 = __last1 - __first1; if (__len1 < __len2) return _VSTD::make_pair(__last1, __last1); - const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here + const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here while (true) { while (true) { @@ -83,7 +87,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando _RandomAccessIterator2 __m2 = __first2; while (true) { if (++__m2 == __last2) - return _VSTD::make_pair(__first1, __first1 + _D1(__len2)); + return _VSTD::make_pair(__first1, __first1 + __len2); ++__m1; // no need to check range on __m1 because __s guarantees we have enough source if (!__pred(*__m1, *__m2)) { ++__first1; @@ -97,7 +101,7 @@ template ( + return _VSTD::__search::type>( __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), typename iterator_traits<_ForwardIterator2>::iterator_category()).first; @@ -122,4 +126,6 @@ search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SEARCH_H diff --git a/include/__algorithm/search_n.h b/include/__algorithm/search_n.h index e4576cc76..1584e8e61 100644 --- a/include/__algorithm/search_n.h +++ b/include/__algorithm/search_n.h @@ -10,15 +10,18 @@ #ifndef _LIBCPP___ALGORITHM_SEARCH_N_H #define _LIBCPP___ALGORITHM_SEARCH_N_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> -#include // __convert_to_integral +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -59,13 +62,12 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter _RandomAccessIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred, random_access_iterator_tag) { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; if (__count <= 0) return __first; _Size __len = static_cast<_Size>(__last - __first); if (__len < __count) return __last; - const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here + const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here while (true) { // Find first element in sequence that matchs __value_, with a mininum of loop checks while (true) { @@ -95,7 +97,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter template _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n( _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) { - return _VSTD::__search_n<_BinaryPredicate&>( + return _VSTD::__search_n::type>( __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } @@ -109,4 +111,6 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SEARCH_N_H diff --git a/include/__algorithm/set_difference.h b/include/__algorithm/set_difference.h index 00f61e070..f4c985d97 100644 --- a/include/__algorithm/set_difference.h +++ b/include/__algorithm/set_difference.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_SET_DIFFERENCE_H #define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -69,4 +72,6 @@ set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H diff --git a/include/__algorithm/set_intersection.h b/include/__algorithm/set_intersection.h index f6aa38217..9d34b66c2 100644 --- a/include/__algorithm/set_intersection.h +++ b/include/__algorithm/set_intersection.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_SET_INTERSECTION_H #define _LIBCPP___ALGORITHM_SET_INTERSECTION_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -66,4 +69,6 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H diff --git a/include/__algorithm/set_symmetric_difference.h b/include/__algorithm/set_symmetric_difference.h index 5b5c2acff..5650b836a 100644 --- a/include/__algorithm/set_symmetric_difference.h +++ b/include/__algorithm/set_symmetric_difference.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H #define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -74,4 +77,6 @@ set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H diff --git a/include/__algorithm/set_union.h b/include/__algorithm/set_union.h index 5b3e3af79..c0874e957 100644 --- a/include/__algorithm/set_union.h +++ b/include/__algorithm/set_union.h @@ -9,16 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_SET_UNION_H #define _LIBCPP___ALGORITHM_SET_UNION_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/copy.h> -#include <__config> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -69,4 +72,6 @@ set_union(_InputIterator1 __first1, _InputIterator1 __last1, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SET_UNION_H diff --git a/include/__algorithm/shift_left.h b/include/__algorithm/shift_left.h index 0466a3188..961b89cb0 100644 --- a/include/__algorithm/shift_left.h +++ b/include/__algorithm/shift_left.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_SHIFT_LEFT_H #define _LIBCPP___ALGORITHM_SHIFT_LEFT_H -#include <__algorithm/move.h> #include <__config> +#include <__algorithm/move.h> #include <__iterator/iterator_traits.h> -#include +#include // swap #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 @@ -53,4 +56,6 @@ shift_left(_ForwardIterator __first, _ForwardIterator __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H diff --git a/include/__algorithm/shift_right.h b/include/__algorithm/shift_right.h index 121712e85..5cb419506 100644 --- a/include/__algorithm/shift_right.h +++ b/include/__algorithm/shift_right.h @@ -9,18 +9,20 @@ #ifndef _LIBCPP___ALGORITHM_SHIFT_RIGHT_H #define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H +#include <__config> #include <__algorithm/move.h> #include <__algorithm/move_backward.h> #include <__algorithm/swap_ranges.h> -#include <__config> #include <__iterator/iterator_traits.h> -#include <__utility/swap.h> -#include +#include // swap #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 @@ -99,4 +101,6 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H diff --git a/include/__algorithm/shuffle.h b/include/__algorithm/shuffle.h index 7f6ad50e2..637fca538 100644 --- a/include/__algorithm/shuffle.h +++ b/include/__algorithm/shuffle.h @@ -25,39 +25,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer { -public: - __libcpp_debug_randomizer() { - __state = __seed(); - __inc = __state + 0xda3e39cb94b95bdbULL; - __inc = (__inc << 1) | 1; - } - typedef uint_fast32_t result_type; - - static const result_type _Min = 0; - static const result_type _Max = 0xFFFFFFFF; - - _LIBCPP_HIDE_FROM_ABI result_type operator()() { - uint_fast64_t __oldstate = __state; - __state = __oldstate * 6364136223846793005ULL + __inc; - return __oldstate >> 32; - } - - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type min() { return _Min; } - static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; } - -private: - uint_fast64_t __state; - uint_fast64_t __inc; - _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() { -#ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED - return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED; -#else - static char __x; - return reinterpret_cast(&__x); -#endif - } -}; #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \ || defined(_LIBCPP_BUILDING_LIBRARY) diff --git a/include/__algorithm/sift_down.h b/include/__algorithm/sift_down.h index bf5447698..dd4b54ed8 100644 --- a/include/__algorithm/sift_down.h +++ b/include/__algorithm/sift_down.h @@ -17,11 +17,15 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template _LIBCPP_CONSTEXPR_AFTER_CXX11 void -__sift_down(_RandomAccessIterator __first, _Compare __comp, +__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, + _Compare __comp, typename iterator_traits<_RandomAccessIterator>::difference_type __len, _RandomAccessIterator __start) { @@ -37,7 +41,7 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, __child = 2 * __child + 1; _RandomAccessIterator __child_i = __first + __child; - if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { // right-child exists and is greater than left-child ++__child_i; ++__child; @@ -45,7 +49,7 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, // check if we are in heap-order if (__comp(*__child_i, *__start)) - // we are, __start is larger than its largest child + // we are, __start is larger than it's largest child return; value_type __top(_VSTD::move(*__start)); @@ -62,7 +66,7 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, __child = 2 * __child + 1; __child_i = __first + __child; - if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { // right-child exists and is greater than left-child ++__child_i; ++__child; @@ -75,4 +79,6 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H diff --git a/include/__algorithm/sort.h b/include/__algorithm/sort.h index 5e09b2800..39ec21302 100644 --- a/include/__algorithm/sort.h +++ b/include/__algorithm/sort.h @@ -9,23 +9,23 @@ #ifndef _LIBCPP___ALGORITHM_SORT_H #define _LIBCPP___ALGORITHM_SORT_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/min_element.h> #include <__algorithm/partial_sort.h> #include <__algorithm/unwrap_iter.h> -#include <__config> #include <__utility/swap.h> #include - -#if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) -# include <__algorithm/shuffle.h> -#endif +#include // swap #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // stable, 2-3 compares, 0-2 swaps @@ -131,7 +131,9 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _BidirectionalIterator __lm1 = __last; for (--__lm1; __first != __lm1; ++__first) { - _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp); + _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator, + typename add_lvalue_reference<_Compare>::type> + (__first, __last, __comp); if (__i != __first) swap(*__first, *__i); } @@ -160,11 +162,10 @@ template void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; - _RandomAccessIterator __j = __first+difference_type(2); - _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp); - for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i) + _RandomAccessIterator __j = __first+2; + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); + for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) { if (__comp(*__i, *__j)) { @@ -186,7 +187,6 @@ template bool __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; switch (__last - __first) { case 0: @@ -197,21 +197,21 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator swap(*__first, *__last); return true; case 3: - _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); + _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); return true; case 4: - _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); + _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); return true; case 5: - _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); + _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); return true; } typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; - _RandomAccessIterator __j = __first+difference_type(2); - _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp); + _RandomAccessIterator __j = __first+2; + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); const unsigned __limit = 8; unsigned __count = 0; - for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i) + for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) { if (__comp(*__i, *__j)) { @@ -269,8 +269,7 @@ __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __ template void -__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, - typename iterator_traits<_RandomAccessIterator>::difference_type __depth) +__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; @@ -290,13 +289,13 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar swap(*__first, *__last); return; case 3: - _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); + _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); return; case 4: - _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); + _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); return; case 5: - _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); + _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); return; } if (__len <= __limit) @@ -305,13 +304,6 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar return; } // __len > 5 - if (__depth == 0) - { - // Fallback to heap sort as Introsort suggests. - _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp); - return; - } - --__depth; _RandomAccessIterator __m = __first; _RandomAccessIterator __lm1 = __last; --__lm1; @@ -435,7 +427,7 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar if (__n_swaps == 0) { bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp); - if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp)) + if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp)) { if (__fs) return; @@ -454,34 +446,19 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar // sort smaller range with recursive call and larger with tail recursion elimination if (__i - __first < __last - __i) { - _VSTD::__introsort<_Compare>(__first, __i, __comp, __depth); - __first = ++__i; + _VSTD::__sort<_Compare>(__first, __i, __comp); + // _VSTD::__sort<_Compare>(__i+1, __last, __comp); + __first = ++__i; } else { - _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth); - __last = __i; + _VSTD::__sort<_Compare>(__i+1, __last, __comp); + // _VSTD::__sort<_Compare>(__first, __i, __comp); + __last = __i; } } } -template -inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) { - _Number __log2 = 0; - while (__n > 1) { - __log2++; - __n >>= 1; - } - return __log2; -} - -template -void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; - difference_type __depth_limit = 2 * __log2i(__last - __first); - _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit); -} - template inline _LIBCPP_INLINE_VISIBILITY void @@ -492,9 +469,7 @@ __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) } _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, char*>(char*, char*, __less&)) -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) -#endif _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, signed char*>(signed char*, signed char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, short*>(short*, short*, __less&)) @@ -510,9 +485,7 @@ _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, double*>(d _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long double*>(long double*, long double*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&)) -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) -#endif _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&)) @@ -534,13 +507,12 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { - _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); - typedef typename __comp_ref_type<_Compare>::type _Comp_ref; - if (__libcpp_is_constant_evaluated()) { - _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); - } else { - _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); - } + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + if (__libcpp_is_constant_evaluated()) { + _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); + } else { + _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); + } } template @@ -553,4 +525,6 @@ sort(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SORT_H diff --git a/include/__algorithm/sort_heap.h b/include/__algorithm/sort_heap.h index 64291ff2e..aa8ef762a 100644 --- a/include/__algorithm/sort_heap.h +++ b/include/__algorithm/sort_heap.h @@ -9,10 +9,10 @@ #ifndef _LIBCPP___ALGORITHM_SORT_HEAP_H #define _LIBCPP___ALGORITHM_SORT_HEAP_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/pop_heap.h> -#include <__config> #include <__iterator/iterator_traits.h> #include // swap @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -50,4 +53,6 @@ sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SORT_HEAP_H diff --git a/include/__algorithm/stable_partition.h b/include/__algorithm/stable_partition.h index 331f0fde7..931335f44 100644 --- a/include/__algorithm/stable_partition.h +++ b/include/__algorithm/stable_partition.h @@ -9,8 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H #define _LIBCPP___ALGORITHM_STABLE_PARTITION_H -#include <__algorithm/rotate.h> #include <__config> +#include <__algorithm/rotate.h> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> #include @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -82,7 +85,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate // recurse on [__first, __m), *__first know to be false // F????????????????? // f m l - _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m, __pred, __len2, __p, __fit); + typedef typename add_lvalue_reference<_Predicate>::type _PredRef; + _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); // TTTFFFFF?????????? // f ff m l // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true @@ -97,7 +101,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate } // TTTFFFFFTTTF?????? // f ff m m1 l - __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __fit); + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l @@ -133,7 +137,8 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } - return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag()); + return _VSTD::__stable_partition::type> + (__first, __last, __pred, __len, __p, forward_iterator_tag()); } template @@ -217,7 +222,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last } // F???TFFF?????????T // f m1 m l - __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m1, __pred, __len_half, __p, __bit); + typedef typename add_lvalue_reference<_Predicate>::type _PredRef; + __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); __first_half_done: // TTTFFFFF?????????T // f ff m l @@ -234,7 +240,7 @@ __first_half_done: } // TTTFFFFFTTTF?????T // f ff m m1 l - __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __bit); + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); __second_half_done: // TTTFFFFFTTTTTFFFFF // f ff m sf l @@ -279,7 +285,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last __p = _VSTD::get_temporary_buffer(__len); __h.reset(__p.first); } - return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); + return _VSTD::__stable_partition::type> + (__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); } template @@ -287,9 +294,12 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); + return _VSTD::__stable_partition::type> + (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H diff --git a/include/__algorithm/stable_sort.h b/include/__algorithm/stable_sort.h index 4ae17e0e4..32b239a0d 100644 --- a/include/__algorithm/stable_sort.h +++ b/include/__algorithm/stable_sort.h @@ -9,20 +9,23 @@ #ifndef _LIBCPP___ALGORITHM_STABLE_SORT_H #define _LIBCPP___ALGORITHM_STABLE_SORT_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/comp_ref_type.h> #include <__algorithm/inplace_merge.h> #include <__algorithm/sort.h> -#include <__config> #include <__iterator/iterator_traits.h> #include <__utility/swap.h> #include -#include +#include // swap #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -38,14 +41,14 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, { if (__first1 == __last1) { - for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr()) + for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr()) ::new ((void*)__result) value_type(_VSTD::move(*__first2)); __h.release(); return; } if (__first2 == __last2) { - for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr()) + for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr()) ::new ((void*)__result) value_type(_VSTD::move(*__first1)); __h.release(); return; @@ -227,4 +230,6 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_STABLE_SORT_H diff --git a/include/__algorithm/swap_ranges.h b/include/__algorithm/swap_ranges.h index 2b099c736..3c72dbd24 100644 --- a/include/__algorithm/swap_ranges.h +++ b/include/__algorithm/swap_ranges.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -29,4 +32,6 @@ swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardItera _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H diff --git a/include/__algorithm/transform.h b/include/__algorithm/transform.h index 494cb7128..218f0f12e 100644 --- a/include/__algorithm/transform.h +++ b/include/__algorithm/transform.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -40,4 +43,6 @@ transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __f _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_TRANSFORM_H diff --git a/include/__algorithm/unique.h b/include/__algorithm/unique.h index e17ff1567..fb6251a39 100644 --- a/include/__algorithm/unique.h +++ b/include/__algorithm/unique.h @@ -9,16 +9,20 @@ #ifndef _LIBCPP___ALGORITHM_UNIQUE_H #define _LIBCPP___ALGORITHM_UNIQUE_H -#include <__algorithm/adjacent_find.h> -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/adjacent_find.h> #include <__iterator/iterator_traits.h> #include <__utility/move.h> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // unique @@ -27,7 +31,8 @@ template _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { - __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred); + __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type> + (__first, __last, __pred); if (__first != __last) { // ... a a ? ... @@ -53,4 +58,6 @@ unique(_ForwardIterator __first, _ForwardIterator __last) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_UNIQUE_H diff --git a/include/__algorithm/unique_copy.h b/include/__algorithm/unique_copy.h index 4833ae9b5..974a7c4df 100644 --- a/include/__algorithm/unique_copy.h +++ b/include/__algorithm/unique_copy.h @@ -9,15 +9,19 @@ #ifndef _LIBCPP___ALGORITHM_UNIQUE_COPY_H #define _LIBCPP___ALGORITHM_UNIQUE_COPY_H -#include <__algorithm/comp.h> #include <__config> +#include <__algorithm/comp.h> #include <__iterator/iterator_traits.h> #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -87,7 +91,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) { - return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred, + return _VSTD::__unique_copy::type> + (__first, __last, __result, __pred, typename iterator_traits<_InputIterator>::iterator_category(), typename iterator_traits<_OutputIterator>::iterator_category()); } @@ -104,4 +109,6 @@ unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H diff --git a/include/__algorithm/unwrap_iter.h b/include/__algorithm/unwrap_iter.h index 35765330b..a45d45cdd 100644 --- a/include/__algorithm/unwrap_iter.h +++ b/include/__algorithm/unwrap_iter.h @@ -10,14 +10,17 @@ #define _LIBCPP___ALGORITHM_UNWRAP_ITER_H #include <__config> -#include <__memory/pointer_traits.h> #include +#include <__memory/pointer_traits.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // The job of __unwrap_iter is to lower contiguous iterators (such as @@ -64,14 +67,12 @@ __unwrap_iter(_Iter __i) _NOEXCEPT } template -_LIBCPP_HIDE_FROM_ABI _OrigIter __rewrap_iter(_OrigIter, _OrigIter __result) { return __result; } template -_LIBCPP_HIDE_FROM_ABI _OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) { // Precondition: __result is reachable from __first @@ -81,4 +82,6 @@ _OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H diff --git a/include/__algorithm/upper_bound.h b/include/__algorithm/upper_bound.h index c064f1e35..7be607f82 100644 --- a/include/__algorithm/upper_bound.h +++ b/include/__algorithm/upper_bound.h @@ -9,15 +9,18 @@ #ifndef _LIBCPP___ALGORITHM_UPPER_BOUND_H #define _LIBCPP___ALGORITHM_UPPER_BOUND_H +#include <__config> #include <__algorithm/comp.h> #include <__algorithm/half_positive.h> -#include <__config> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -48,7 +51,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { - return _VSTD::__upper_bound<_Compare&>(__first, __last, __value_, __comp); + typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp); } template @@ -63,4 +67,6 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H diff --git a/include/__availability b/include/__availability index 4652a6fd9..13d11950f 100644 --- a/include/__availability +++ b/include/__availability @@ -129,10 +129,6 @@ // This controls the availability of std::to_chars. # define _LIBCPP_AVAILABILITY_TO_CHARS - // This controls the availability of floating-point std::to_chars functions. - // These overloads were added later than the integer overloads. -# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT - // This controls the availability of the C++20 synchronization library, // which requires shared library support for various operations // (see libcxx/src/atomic.cpp). @@ -143,9 +139,9 @@ // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore // This controls the availability of the C++20 format library. - // The library is in development and not ABI stable yet. P2216 is - // retroactively accepted in C++20. This paper contains ABI breaking - // changes. + // The library is in development and not ABI stable yet. Currently + // P2216 is aiming to be retroactively accepted in C++20. This paper + // contains ABI breaking changes. # define _LIBCPP_AVAILABILITY_FORMAT // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format @@ -226,9 +222,6 @@ # define _LIBCPP_AVAILABILITY_TO_CHARS \ _LIBCPP_AVAILABILITY_FILESYSTEM -# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \ - __attribute__((unavailable)) - # define _LIBCPP_AVAILABILITY_SYNC \ __attribute__((availability(macosx,strict,introduced=11.0))) \ __attribute__((availability(ios,strict,introduced=14.0))) \ @@ -245,9 +238,9 @@ # endif // This controls the availability of the C++20 format library. - // The library is in development and not ABI stable yet. P2216 is - // retroactively accepted in C++20. This paper contains ABI breaking - // changes. + // The library is in development and not ABI stable yet. Currently + // P2216 is aiming to be retroactively accepted in C++20. This paper + // contains ABI breaking changes. # define _LIBCPP_AVAILABILITY_FORMAT \ __attribute__((unavailable)) # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format diff --git a/include/__bit/byteswap.h b/include/__bit/byteswap.h deleted file mode 100644 index 970074ed9..000000000 --- a/include/__bit/byteswap.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___BIT_BYTESWAP_H -#define _LIBCPP___BIT_BYTESWAP_H - -#include <__concepts/arithmetic.h> -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -_LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { - - if constexpr (sizeof(_Tp) == 1) { - return __val; - } else if constexpr (sizeof(_Tp) == 2) { - return __builtin_bswap16(__val); - } else if constexpr (sizeof(_Tp) == 4) { - return __builtin_bswap32(__val); - } else if constexpr (sizeof(_Tp) == 8) { - return __builtin_bswap64(__val); -#ifndef _LIBCPP_HAS_NO_INT128 - } else if constexpr (sizeof(_Tp) == 16) { -#if __has_builtin(__builtin_bswap128) - return __builtin_bswap128(__val); -#else - return static_cast<_Tp>(byteswap(static_cast(__val))) << 64 | - static_cast<_Tp>(byteswap(static_cast(__val >> 64))); -#endif // __has_builtin(__builtin_bswap128) -#endif // _LIBCPP_HAS_NO_INT128 - } else { - static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size"); - } -} - -#endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___BIT_BYTESWAP_H diff --git a/include/__bit_reference b/include/__bit_reference index a60a5c721..a02492c07 100644 --- a/include/__bit_reference +++ b/include/__bit_reference @@ -10,8 +10,8 @@ #ifndef _LIBCPP___BIT_REFERENCE #define _LIBCPP___BIT_REFERENCE -#include <__bits> #include <__config> +#include <__bits> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/include/__bsd_locale_defaults.h b/include/__bsd_locale_defaults.h index 0d6506c62..2ace2a21c 100644 --- a/include/__bsd_locale_defaults.h +++ b/include/__bsd_locale_defaults.h @@ -1,5 +1,5 @@ // -*- C++ -*- -//===----------------------------------------------------------------------===// +//===---------------------- __bsd_locale_defaults.h -----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/include/__bsd_locale_fallbacks.h b/include/__bsd_locale_fallbacks.h index a5788d977..ed0eabf60 100644 --- a/include/__bsd_locale_fallbacks.h +++ b/include/__bsd_locale_fallbacks.h @@ -1,5 +1,5 @@ // -*- C++ -*- -//===----------------------------------------------------------------------===// +//===---------------------- __bsd_locale_fallbacks.h ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -30,7 +30,6 @@ decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) return MB_CUR_MAX; } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_btowc_l(int __c, locale_t __l) { @@ -89,7 +88,6 @@ size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __libcpp_locale_guard __current(__l); return mbrlen(__s, __n, __ps); } -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_INLINE_VISIBILITY lconv *__libcpp_localeconv_l(locale_t __l) @@ -98,7 +96,6 @@ lconv *__libcpp_localeconv_l(locale_t __l) return localeconv(); } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS inline _LIBCPP_INLINE_VISIBILITY size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, mbstate_t *__ps, locale_t __l) @@ -106,9 +103,8 @@ size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, __libcpp_locale_guard __current(__l); return mbsrtowcs(__dest, __src, __len, __ps); } -#endif -inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) +inline int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) { va_list __va; va_start(__va, __format); @@ -118,7 +114,7 @@ int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__forma return __res; } -inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) +inline int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { va_list __va; va_start(__va, __format); @@ -128,7 +124,7 @@ int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { return __res; } -inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) +inline int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { va_list __va; va_start(__va, __format); diff --git a/include/__charconv/chars_format.h b/include/__charconv/chars_format.h deleted file mode 100644 index 22e70b56f..000000000 --- a/include/__charconv/chars_format.h +++ /dev/null @@ -1,77 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHARCONV_CHARS_FORMAT_H -#define _LIBCPP___CHARCONV_CHARS_FORMAT_H - -#include <__config> -#include <__utility/to_underlying.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#ifndef _LIBCPP_CXX03_LANG - -enum class _LIBCPP_ENUM_VIS chars_format -{ - scientific = 0x1, - fixed = 0x2, - hex = 0x4, - general = fixed | scientific -}; - -inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format -operator~(chars_format __x) { - return chars_format(~_VSTD::__to_underlying(__x)); -} - -inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format -operator&(chars_format __x, chars_format __y) { - return chars_format(_VSTD::__to_underlying(__x) & - _VSTD::__to_underlying(__y)); -} - -inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format -operator|(chars_format __x, chars_format __y) { - return chars_format(_VSTD::__to_underlying(__x) | - _VSTD::__to_underlying(__y)); -} - -inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format -operator^(chars_format __x, chars_format __y) { - return chars_format(_VSTD::__to_underlying(__x) ^ - _VSTD::__to_underlying(__y)); -} - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& -operator&=(chars_format& __x, chars_format __y) { - __x = __x & __y; - return __x; -} - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& -operator|=(chars_format& __x, chars_format __y) { - __x = __x | __y; - return __x; -} - -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& -operator^=(chars_format& __x, chars_format __y) { - __x = __x ^ __y; - return __x; -} - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H diff --git a/include/__charconv/from_chars_result.h b/include/__charconv/from_chars_result.h deleted file mode 100644 index fbd7d5081..000000000 --- a/include/__charconv/from_chars_result.h +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H -#define _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H - -#include <__config> -#include <__errc> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#ifndef _LIBCPP_CXX03_LANG - -struct _LIBCPP_TYPE_VIS from_chars_result -{ - const char* ptr; - errc ec; -# if _LIBCPP_STD_VER > 17 - _LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default; -# endif -}; - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H diff --git a/include/__charconv/to_chars_result.h b/include/__charconv/to_chars_result.h deleted file mode 100644 index f515ee312..000000000 --- a/include/__charconv/to_chars_result.h +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHARCONV_TO_CHARS_RESULT_H -#define _LIBCPP___CHARCONV_TO_CHARS_RESULT_H - -#include <__config> -#include <__errc> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#ifndef _LIBCPP_CXX03_LANG - -struct _LIBCPP_TYPE_VIS to_chars_result -{ - char* ptr; - errc ec; -# if _LIBCPP_STD_VER > 17 - _LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default; -# endif -}; - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H diff --git a/include/__chrono/calendar.h b/include/__chrono/calendar.h deleted file mode 100644 index 745f7f5cf..000000000 --- a/include/__chrono/calendar.h +++ /dev/null @@ -1,1276 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_CALENDAR_H -#define _LIBCPP___CHRONO_CALENDAR_H - -#include <__chrono/duration.h> -#include <__chrono/system_clock.h> -#include <__chrono/time_point.h> -#include <__config> -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -#if _LIBCPP_STD_VER > 17 - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -struct local_t {}; -template -using local_time = time_point; -using local_seconds = local_time; -using local_days = local_time; - -struct last_spec { explicit last_spec() = default; }; - -class day { -private: - unsigned char __d; -public: - day() = default; - explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast(__val)) {} - inline constexpr day& operator++() noexcept { ++__d; return *this; } - inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; } - inline constexpr day& operator--() noexcept { --__d; return *this; } - inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; } - constexpr day& operator+=(const days& __dd) noexcept; - constexpr day& operator-=(const days& __dd) noexcept; - explicit inline constexpr operator unsigned() const noexcept { return __d; } - inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; } - }; - - -inline constexpr -bool operator==(const day& __lhs, const day& __rhs) noexcept -{ return static_cast(__lhs) == static_cast(__rhs); } - -inline constexpr -bool operator!=(const day& __lhs, const day& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const day& __lhs, const day& __rhs) noexcept -{ return static_cast(__lhs) < static_cast(__rhs); } - -inline constexpr -bool operator> (const day& __lhs, const day& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const day& __lhs, const day& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const day& __lhs, const day& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr -day operator+ (const day& __lhs, const days& __rhs) noexcept -{ return day(static_cast(__lhs) + __rhs.count()); } - -inline constexpr -day operator+ (const days& __lhs, const day& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -day operator- (const day& __lhs, const days& __rhs) noexcept -{ return __lhs + -__rhs; } - -inline constexpr -days operator-(const day& __lhs, const day& __rhs) noexcept -{ return days(static_cast(static_cast(__lhs)) - - static_cast(static_cast(__rhs))); } - -inline constexpr day& day::operator+=(const days& __dd) noexcept -{ *this = *this + __dd; return *this; } - -inline constexpr day& day::operator-=(const days& __dd) noexcept -{ *this = *this - __dd; return *this; } - - -class month { -private: - unsigned char __m; -public: - month() = default; - explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast(__val)) {} - inline constexpr month& operator++() noexcept { ++__m; return *this; } - inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; } - inline constexpr month& operator--() noexcept { --__m; return *this; } - inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; } - constexpr month& operator+=(const months& __m1) noexcept; - constexpr month& operator-=(const months& __m1) noexcept; - explicit inline constexpr operator unsigned() const noexcept { return __m; } - inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; } -}; - - -inline constexpr -bool operator==(const month& __lhs, const month& __rhs) noexcept -{ return static_cast(__lhs) == static_cast(__rhs); } - -inline constexpr -bool operator!=(const month& __lhs, const month& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const month& __lhs, const month& __rhs) noexcept -{ return static_cast(__lhs) < static_cast(__rhs); } - -inline constexpr -bool operator> (const month& __lhs, const month& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const month& __lhs, const month& __rhs) noexcept -{ return !(__rhs < __lhs); } - -inline constexpr -bool operator>=(const month& __lhs, const month& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr -month operator+ (const month& __lhs, const months& __rhs) noexcept -{ - auto const __mu = static_cast(static_cast(__lhs)) + (__rhs.count() - 1); - auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12; - return month{static_cast(__mu - __yr * 12 + 1)}; -} - -inline constexpr -month operator+ (const months& __lhs, const month& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -month operator- (const month& __lhs, const months& __rhs) noexcept -{ return __lhs + -__rhs; } - -inline constexpr -months operator-(const month& __lhs, const month& __rhs) noexcept -{ - auto const __dm = static_cast(__lhs) - static_cast(__rhs); - return months(__dm <= 11 ? __dm : __dm + 12); -} - -inline constexpr month& month::operator+=(const months& __dm) noexcept -{ *this = *this + __dm; return *this; } - -inline constexpr month& month::operator-=(const months& __dm) noexcept -{ *this = *this - __dm; return *this; } - - -class year { -private: - short __y; -public: - year() = default; - explicit inline constexpr year(int __val) noexcept : __y(static_cast(__val)) {} - - inline constexpr year& operator++() noexcept { ++__y; return *this; } - inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; } - inline constexpr year& operator--() noexcept { --__y; return *this; } - inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; } - constexpr year& operator+=(const years& __dy) noexcept; - constexpr year& operator-=(const years& __dy) noexcept; - inline constexpr year operator+() const noexcept { return *this; } - inline constexpr year operator-() const noexcept { return year{-__y}; } - - inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); } - explicit inline constexpr operator int() const noexcept { return __y; } - constexpr bool ok() const noexcept; - static inline constexpr year min() noexcept { return year{-32767}; } - static inline constexpr year max() noexcept { return year{ 32767}; } -}; - - -inline constexpr -bool operator==(const year& __lhs, const year& __rhs) noexcept -{ return static_cast(__lhs) == static_cast(__rhs); } - -inline constexpr -bool operator!=(const year& __lhs, const year& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const year& __lhs, const year& __rhs) noexcept -{ return static_cast(__lhs) < static_cast(__rhs); } - -inline constexpr -bool operator> (const year& __lhs, const year& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const year& __lhs, const year& __rhs) noexcept -{ return !(__rhs < __lhs); } - -inline constexpr -bool operator>=(const year& __lhs, const year& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr -year operator+ (const year& __lhs, const years& __rhs) noexcept -{ return year(static_cast(__lhs) + __rhs.count()); } - -inline constexpr -year operator+ (const years& __lhs, const year& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year operator- (const year& __lhs, const years& __rhs) noexcept -{ return __lhs + -__rhs; } - -inline constexpr -years operator-(const year& __lhs, const year& __rhs) noexcept -{ return years{static_cast(__lhs) - static_cast(__rhs)}; } - - -inline constexpr year& year::operator+=(const years& __dy) noexcept -{ *this = *this + __dy; return *this; } - -inline constexpr year& year::operator-=(const years& __dy) noexcept -{ *this = *this - __dy; return *this; } - -inline constexpr bool year::ok() const noexcept -{ return static_cast(min()) <= __y && __y <= static_cast(max()); } - -class weekday_indexed; -class weekday_last; - -class weekday { -private: - unsigned char __wd; - static constexpr unsigned char __weekday_from_days(int __days) noexcept; -public: - weekday() = default; - inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast(__val == 7 ? 0 : __val)) {} - inline constexpr weekday(const sys_days& __sysd) noexcept - : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {} - inline explicit constexpr weekday(const local_days& __locd) noexcept - : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {} - - inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; } - inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; } - inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; } - inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; } - constexpr weekday& operator+=(const days& __dd) noexcept; - constexpr weekday& operator-=(const days& __dd) noexcept; - inline constexpr unsigned c_encoding() const noexcept { return __wd; } - inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; } - inline constexpr bool ok() const noexcept { return __wd <= 6; } - constexpr weekday_indexed operator[](unsigned __index) const noexcept; - constexpr weekday_last operator[](last_spec) const noexcept; -}; - - -// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days -inline constexpr -unsigned char weekday::__weekday_from_days(int __days) noexcept -{ - return static_cast( - static_cast(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6) - ); -} - -inline constexpr -bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept -{ return __lhs.c_encoding() == __rhs.c_encoding(); } - -inline constexpr -bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept -{ return __lhs.c_encoding() < __rhs.c_encoding(); } - -inline constexpr -bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept -{ return !(__lhs < __rhs); } - -constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept -{ - auto const __mu = static_cast(__lhs.c_encoding()) + __rhs.count(); - auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7; - return weekday{static_cast(__mu - __yr * 7)}; -} - -constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept -{ return __rhs + __lhs; } - -constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept -{ return __lhs + -__rhs; } - -constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept -{ - const int __wdu = __lhs.c_encoding() - __rhs.c_encoding(); - const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7; - return days{__wdu - __wk * 7}; -} - -inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept -{ *this = *this + __dd; return *this; } - -inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept -{ *this = *this - __dd; return *this; } - - -class weekday_indexed { -private: - chrono::weekday __wd; - unsigned char __idx; -public: - weekday_indexed() = default; - inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept - : __wd{__wdval}, __idx(__idxval) {} - inline constexpr chrono::weekday weekday() const noexcept { return __wd; } - inline constexpr unsigned index() const noexcept { return __idx; } - inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; } -}; - -inline constexpr -bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept -{ return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); } - -inline constexpr -bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept -{ return !(__lhs == __rhs); } - - -class weekday_last { -private: - chrono::weekday __wd; -public: - explicit constexpr weekday_last(const chrono::weekday& __val) noexcept - : __wd{__val} {} - constexpr chrono::weekday weekday() const noexcept { return __wd; } - constexpr bool ok() const noexcept { return __wd.ok(); } -}; - -inline constexpr -bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept -{ return __lhs.weekday() == __rhs.weekday(); } - -inline constexpr -bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; } - -inline constexpr -weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; } - - -inline constexpr last_spec last{}; -inline constexpr weekday Sunday{0}; -inline constexpr weekday Monday{1}; -inline constexpr weekday Tuesday{2}; -inline constexpr weekday Wednesday{3}; -inline constexpr weekday Thursday{4}; -inline constexpr weekday Friday{5}; -inline constexpr weekday Saturday{6}; - -inline constexpr month January{1}; -inline constexpr month February{2}; -inline constexpr month March{3}; -inline constexpr month April{4}; -inline constexpr month May{5}; -inline constexpr month June{6}; -inline constexpr month July{7}; -inline constexpr month August{8}; -inline constexpr month September{9}; -inline constexpr month October{10}; -inline constexpr month November{11}; -inline constexpr month December{12}; - - -class month_day { -private: - chrono::month __m; - chrono::day __d; -public: - month_day() = default; - constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept - : __m{__mval}, __d{__dval} {} - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::day day() const noexcept { return __d; } - constexpr bool ok() const noexcept; -}; - -inline constexpr -bool month_day::ok() const noexcept -{ - if (!__m.ok()) return false; - const unsigned __dval = static_cast(__d); - if (__dval < 1 || __dval > 31) return false; - if (__dval <= 29) return true; -// Now we've got either 30 or 31 - const unsigned __mval = static_cast(__m); - if (__mval == 2) return false; - if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11) - return __dval == 30; - return true; -} - -inline constexpr -bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept -{ return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } - -inline constexpr -bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -month_day operator/(const month& __lhs, const day& __rhs) noexcept -{ return month_day{__lhs, __rhs}; } - -constexpr -month_day operator/(const day& __lhs, const month& __rhs) noexcept -{ return __rhs / __lhs; } - -inline constexpr -month_day operator/(const month& __lhs, int __rhs) noexcept -{ return __lhs / day(__rhs); } - -constexpr -month_day operator/(int __lhs, const day& __rhs) noexcept -{ return month(__lhs) / __rhs; } - -constexpr -month_day operator/(const day& __lhs, int __rhs) noexcept -{ return month(__rhs) / __lhs; } - - -inline constexpr -bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept -{ return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); } - -inline constexpr -bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept -{ return !(__lhs < __rhs); } - - - -class month_day_last { -private: - chrono::month __m; -public: - explicit constexpr month_day_last(const chrono::month& __val) noexcept - : __m{__val} {} - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr bool ok() const noexcept { return __m.ok(); } -}; - -inline constexpr -bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return __lhs.month() == __rhs.month(); } - -inline constexpr -bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return __lhs.month() < __rhs.month(); } - -inline constexpr -bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr -month_day_last operator/(const month& __lhs, last_spec) noexcept -{ return month_day_last{__lhs}; } - -inline constexpr -month_day_last operator/(last_spec, const month& __rhs) noexcept -{ return month_day_last{__rhs}; } - -inline constexpr -month_day_last operator/(int __lhs, last_spec) noexcept -{ return month_day_last{month(__lhs)}; } - -inline constexpr -month_day_last operator/(last_spec, int __rhs) noexcept -{ return month_day_last{month(__rhs)}; } - - -class month_weekday { -private: - chrono::month __m; - chrono::weekday_indexed __wdi; -public: - constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept - : __m{__mval}, __wdi{__wdival} {} - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } - inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); } -}; - -inline constexpr -bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept -{ return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } - -inline constexpr -bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept -{ return month_weekday{__lhs, __rhs}; } - -inline constexpr -month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept -{ return month_weekday{month(__lhs), __rhs}; } - -inline constexpr -month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept -{ return month_weekday{__rhs, __lhs}; } - -inline constexpr -month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept -{ return month_weekday{month(__rhs), __lhs}; } - - -class month_weekday_last { - chrono::month __m; - chrono::weekday_last __wdl; - public: - constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept - : __m{__mval}, __wdl{__wdlval} {} - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } - inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); } -}; - -inline constexpr -bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept -{ return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } - -inline constexpr -bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept -{ return !(__lhs == __rhs); } - - -inline constexpr -month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept -{ return month_weekday_last{__lhs, __rhs}; } - -inline constexpr -month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept -{ return month_weekday_last{month(__lhs), __rhs}; } - -inline constexpr -month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept -{ return month_weekday_last{__rhs, __lhs}; } - -inline constexpr -month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept -{ return month_weekday_last{month(__rhs), __lhs}; } - - -class year_month { - chrono::year __y; - chrono::month __m; -public: - year_month() = default; - constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept - : __y{__yval}, __m{__mval} {} - inline constexpr chrono::year year() const noexcept { return __y; } - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; } - inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; } - inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; } - inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; } - inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); } -}; - -inline constexpr -year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; } - -inline constexpr -year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; } - -inline constexpr -bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept -{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); } - -inline constexpr -bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept -{ return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); } - -inline constexpr -bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept -{ return !(__lhs < __rhs); } - -constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept -{ - int __dmi = static_cast(static_cast(__lhs.month())) - 1 + __rhs.count(); - const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12; - __dmi = __dmi - __dy * 12 + 1; - return (__lhs.year() + years(__dy)) / month(static_cast(__dmi)); -} - -constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept -{ return __rhs + __lhs; } - -constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept -{ return (__lhs.year() + __rhs) / __lhs.month(); } - -constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept -{ return __rhs + __lhs; } - -constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept -{ return (__lhs.year() - __rhs.year()) + months(static_cast(__lhs.month()) - static_cast(__rhs.month())); } - -constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept -{ return __lhs + -__rhs; } - -constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept -{ return __lhs + -__rhs; } - -class year_month_day_last; - -class year_month_day { -private: - chrono::year __y; - chrono::month __m; - chrono::day __d; -public: - year_month_day() = default; - inline constexpr year_month_day( - const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept - : __y{__yval}, __m{__mval}, __d{__dval} {} - constexpr year_month_day(const year_month_day_last& __ymdl) noexcept; - inline constexpr year_month_day(const sys_days& __sysd) noexcept - : year_month_day(__from_days(__sysd.time_since_epoch())) {} - inline explicit constexpr year_month_day(const local_days& __locd) noexcept - : year_month_day(__from_days(__locd.time_since_epoch())) {} - - constexpr year_month_day& operator+=(const months& __dm) noexcept; - constexpr year_month_day& operator-=(const months& __dm) noexcept; - constexpr year_month_day& operator+=(const years& __dy) noexcept; - constexpr year_month_day& operator-=(const years& __dy) noexcept; - - inline constexpr chrono::year year() const noexcept { return __y; } - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::day day() const noexcept { return __d; } - inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } - inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } - - constexpr bool ok() const noexcept; - - static constexpr year_month_day __from_days(days __d) noexcept; - constexpr days __to_days() const noexcept; -}; - - -// https://howardhinnant.github.io/date_algorithms.html#civil_from_days -inline constexpr -year_month_day -year_month_day::__from_days(days __d) noexcept -{ - static_assert(numeric_limits::digits >= 18, ""); - static_assert(numeric_limits::digits >= 20 , ""); - const int __z = __d.count() + 719468; - const int __era = (__z >= 0 ? __z : __z - 146096) / 146097; - const unsigned __doe = static_cast(__z - __era * 146097); // [0, 146096] - const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399] - const int __yr = static_cast(__yoe) + __era * 400; - const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365] - const unsigned __mp = (5 * __doy + 2)/153; // [0, 11] - const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31] - const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12] - return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}}; -} - -// https://howardhinnant.github.io/date_algorithms.html#days_from_civil -inline constexpr days year_month_day::__to_days() const noexcept -{ - static_assert(numeric_limits::digits >= 18, ""); - static_assert(numeric_limits::digits >= 20 , ""); - - const int __yr = static_cast(__y) - (__m <= February); - const unsigned __mth = static_cast(__m); - const unsigned __dy = static_cast(__d); - - const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400; - const unsigned __yoe = static_cast(__yr - __era * 400); // [0, 399] - const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365] - const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096] - return days{__era * 146097 + static_cast(__doe) - 719468}; -} - -inline constexpr -bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } - -inline constexpr -bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ - if (__lhs.year() < __rhs.year()) return true; - if (__lhs.year() > __rhs.year()) return false; - if (__lhs.month() < __rhs.month()) return true; - if (__lhs.month() > __rhs.month()) return false; - return __lhs.day() < __rhs.day(); -} - -inline constexpr -bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr -year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept -{ return year_month_day{__lhs.year(), __lhs.month(), __rhs}; } - -inline constexpr -year_month_day operator/(const year_month& __lhs, int __rhs) noexcept -{ return __lhs / day(__rhs); } - -inline constexpr -year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept -{ return __lhs / __rhs.month() / __rhs.day(); } - -inline constexpr -year_month_day operator/(int __lhs, const month_day& __rhs) noexcept -{ return year(__lhs) / __rhs; } - -inline constexpr -year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept -{ return __rhs / __lhs; } - -inline constexpr -year_month_day operator/(const month_day& __lhs, int __rhs) noexcept -{ return year(__rhs) / __lhs; } - - -inline constexpr -year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept -{ return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); } - -inline constexpr -year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept -{ return __lhs + -__rhs; } - -inline constexpr -year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept -{ return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); } - -inline constexpr -year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept -{ return __lhs + -__rhs; } - -inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } -inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } -inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } -inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } - -class year_month_day_last { -private: - chrono::year __y; - chrono::month_day_last __mdl; -public: - constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept - : __y{__yval}, __mdl{__mdlval} {} - - constexpr year_month_day_last& operator+=(const months& __m) noexcept; - constexpr year_month_day_last& operator-=(const months& __m) noexcept; - constexpr year_month_day_last& operator+=(const years& __y) noexcept; - constexpr year_month_day_last& operator-=(const years& __y) noexcept; - - inline constexpr chrono::year year() const noexcept { return __y; } - inline constexpr chrono::month month() const noexcept { return __mdl.month(); } - inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; } - constexpr chrono::day day() const noexcept; - inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; } - inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; } - inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); } -}; - -inline constexpr -chrono::day year_month_day_last::day() const noexcept -{ - constexpr chrono::day __d[] = - { - chrono::day(31), chrono::day(28), chrono::day(31), - chrono::day(30), chrono::day(31), chrono::day(30), - chrono::day(31), chrono::day(31), chrono::day(30), - chrono::day(31), chrono::day(30), chrono::day(31) - }; - return (month() != February || !__y.is_leap()) && month().ok() ? - __d[static_cast(month()) - 1] : chrono::day{29}; -} - -inline constexpr -bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); } - -inline constexpr -bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ - if (__lhs.year() < __rhs.year()) return true; - if (__lhs.year() > __rhs.year()) return false; - return __lhs.month_day_last() < __rhs.month_day_last(); -} - -inline constexpr -bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ return __rhs < __lhs; } - -inline constexpr -bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ return !(__rhs < __lhs);} - -inline constexpr -bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept -{ return !(__lhs < __rhs); } - -inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept -{ return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; } - -inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept -{ return year_month_day_last{__lhs, __rhs}; } - -inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept -{ return year_month_day_last{year{__lhs}, __rhs}; } - -inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept -{ return __rhs / __lhs; } - -inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept -{ return year{__rhs} / __lhs; } - - -inline constexpr -year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept -{ return (__lhs.year() / __lhs.month() + __rhs) / last; } - -inline constexpr -year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept -{ return __lhs + (-__rhs); } - -inline constexpr -year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept -{ return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; } - -inline constexpr -year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept -{ return __lhs + (-__rhs); } - -inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } -inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } -inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } -inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } - -inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept - : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {} - -inline constexpr bool year_month_day::ok() const noexcept -{ - if (!__y.ok() || !__m.ok()) return false; - return chrono::day{1} <= __d && __d <= (__y / __m / last).day(); -} - -class year_month_weekday { - chrono::year __y; - chrono::month __m; - chrono::weekday_indexed __wdi; -public: - year_month_weekday() = default; - constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval, - const chrono::weekday_indexed& __wdival) noexcept - : __y{__yval}, __m{__mval}, __wdi{__wdival} {} - constexpr year_month_weekday(const sys_days& __sysd) noexcept - : year_month_weekday(__from_days(__sysd.time_since_epoch())) {} - inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept - : year_month_weekday(__from_days(__locd.time_since_epoch())) {} - constexpr year_month_weekday& operator+=(const months& m) noexcept; - constexpr year_month_weekday& operator-=(const months& m) noexcept; - constexpr year_month_weekday& operator+=(const years& y) noexcept; - constexpr year_month_weekday& operator-=(const years& y) noexcept; - - inline constexpr chrono::year year() const noexcept { return __y; } - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); } - inline constexpr unsigned index() const noexcept { return __wdi.index(); } - inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } - - inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } - inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } - inline constexpr bool ok() const noexcept - { - if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false; - if (__wdi.index() <= 4) return true; - auto __nth_weekday_day = - __wdi.weekday() - - chrono::weekday{static_cast(__y / __m / 1)} + - days{(__wdi.index() - 1) * 7 + 1}; - return static_cast(__nth_weekday_day.count()) <= - static_cast((__y / __m / last).day()); - } - - static constexpr year_month_weekday __from_days(days __d) noexcept; - constexpr days __to_days() const noexcept; -}; - -inline constexpr -year_month_weekday year_month_weekday::__from_days(days __d) noexcept -{ - const sys_days __sysd{__d}; - const chrono::weekday __wd = chrono::weekday(__sysd); - const year_month_day __ymd = year_month_day(__sysd); - return year_month_weekday{__ymd.year(), __ymd.month(), - __wd[(static_cast(__ymd.day())-1)/7+1]}; -} - -inline constexpr -days year_month_weekday::__to_days() const noexcept -{ - const sys_days __sysd = sys_days(__y/__m/1); - return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7})) - .time_since_epoch(); -} - -inline constexpr -bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept -{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } - -inline constexpr -bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept -{ return !(__lhs == __rhs); } - -inline constexpr -year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept -{ return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; } - -inline constexpr -year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept -{ return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; } - -inline constexpr -year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept -{ return year(__lhs) / __rhs; } - -inline constexpr -year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept -{ return __rhs / __lhs; } - -inline constexpr -year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept -{ return year(__rhs) / __lhs; } - - -inline constexpr -year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept -{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); } - -inline constexpr -year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept -{ return __lhs + (-__rhs); } - -inline constexpr -year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept -{ return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; } - -inline constexpr -year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept -{ return __lhs + (-__rhs); } - - -inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } -inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } -inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } -inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } - -class year_month_weekday_last { -private: - chrono::year __y; - chrono::month __m; - chrono::weekday_last __wdl; -public: - constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval, - const chrono::weekday_last& __wdlval) noexcept - : __y{__yval}, __m{__mval}, __wdl{__wdlval} {} - constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept; - constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept; - constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept; - constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept; - - inline constexpr chrono::year year() const noexcept { return __y; } - inline constexpr chrono::month month() const noexcept { return __m; } - inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); } - inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } - inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } - inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } - inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); } - - constexpr days __to_days() const noexcept; - -}; - -inline constexpr -days year_month_weekday_last::__to_days() const noexcept -{ - const sys_days __last = sys_days{__y/__m/last}; - return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch(); - -} - -inline constexpr -bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept -{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } - -inline constexpr -bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept -{ return !(__lhs == __rhs); } - - -inline constexpr -year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept -{ return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; } - -inline constexpr -year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept -{ return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; } - -inline constexpr -year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept -{ return year(__lhs) / __rhs; } - -inline constexpr -year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept -{ return __rhs / __lhs; } - -inline constexpr -year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept -{ return year(__rhs) / __lhs; } - - -inline constexpr -year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept -{ return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); } - -inline constexpr -year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept -{ return __lhs + (-__rhs); } - -inline constexpr -year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept -{ return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; } - -inline constexpr -year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept -{ return __rhs + __lhs; } - -inline constexpr -year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept -{ return __lhs + (-__rhs); } - -inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } -inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } -inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } -inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } - - -template -class hh_mm_ss -{ -private: - static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); - using __CommonType = common_type_t<_Duration, chrono::seconds>; - - static constexpr uint64_t __pow10(unsigned __exp) - { - uint64_t __ret = 1; - for (unsigned __i = 0; __i < __exp; ++__i) - __ret *= 10U; - return __ret; - } - - static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0) - { - if (__n >= 2 && __d != 0 && __w < 19) - return 1 + __width(__n, __d % __n * 10, __w+1); - return 0; - } - -public: - static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ? - __width(__CommonType::period::den) : 6u; - using precision = duration>; - - constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {} - - constexpr explicit hh_mm_ss(_Duration __d) noexcept : - __is_neg(__d < _Duration(0)), - __h(duration_cast (abs(__d))), - __m(duration_cast(abs(__d) - hours())), - __s(duration_cast(abs(__d) - hours() - minutes())), - __f(duration_cast (abs(__d) - hours() - minutes() - seconds())) - {} - - constexpr bool is_negative() const noexcept { return __is_neg; } - constexpr chrono::hours hours() const noexcept { return __h; } - constexpr chrono::minutes minutes() const noexcept { return __m; } - constexpr chrono::seconds seconds() const noexcept { return __s; } - constexpr precision subseconds() const noexcept { return __f; } - - constexpr precision to_duration() const noexcept - { - auto __dur = __h + __m + __s + __f; - return __is_neg ? -__dur : __dur; - } - - constexpr explicit operator precision() const noexcept { return to_duration(); } - -private: - bool __is_neg; - chrono::hours __h; - chrono::minutes __m; - chrono::seconds __s; - precision __f; -}; - -constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } -constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } - -constexpr hours make12(const hours& __h) noexcept -{ - if (__h == hours( 0)) return hours(12); - else if (__h <= hours(12)) return __h; - else return __h - hours(12); -} - -constexpr hours make24(const hours& __h, bool __is_pm) noexcept -{ - if (__is_pm) - return __h == hours(12) ? __h : __h + hours(12); - else - return __h == hours(12) ? hours(0) : __h; -} - -} // namespace chrono - -inline namespace literals -{ - inline namespace chrono_literals - { - constexpr chrono::day operator ""d(unsigned long long __d) noexcept - { - return chrono::day(static_cast(__d)); - } - - constexpr chrono::year operator ""y(unsigned long long __y) noexcept - { - return chrono::year(static_cast(__y)); - } -} // namespace chrono_literals -} // namespace literals - -namespace chrono { // hoist the literals into namespace std::chrono - using namespace literals::chrono_literals; -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___CHRONO_CALENDAR_H diff --git a/include/__chrono/convert_to_timespec.h b/include/__chrono/convert_to_timespec.h deleted file mode 100644 index 0106e6dec..000000000 --- a/include/__chrono/convert_to_timespec.h +++ /dev/null @@ -1,55 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -#ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H -#define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H - -#include <__chrono/duration.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -// Convert a nanoseconds duration to the given TimeSpec type, which must have -// the same properties as std::timespec. -template -_LIBCPP_HIDE_FROM_ABI inline -_TimeSpec __convert_to_timespec(const chrono::nanoseconds& __ns) -{ - using namespace chrono; - seconds __s = duration_cast(__ns); - _TimeSpec __ts; - typedef decltype(__ts.tv_sec) __ts_sec; - const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max(); - - if (__s.count() < __ts_sec_max) - { - __ts.tv_sec = static_cast<__ts_sec>(__s.count()); - __ts.tv_nsec = static_cast((__ns - __s).count()); - } - else - { - __ts.tv_sec = __ts_sec_max; - __ts.tv_nsec = 999999999; // (10^9 - 1) - } - - return __ts; -} - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H diff --git a/include/__chrono/duration.h b/include/__chrono/duration.h deleted file mode 100644 index b7d88cb52..000000000 --- a/include/__chrono/duration.h +++ /dev/null @@ -1,615 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_DURATION_H -#define _LIBCPP___CHRONO_DURATION_H - -#include <__config> -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -template > class _LIBCPP_TEMPLATE_VIS duration; - -template -struct __is_duration : false_type {}; - -template -struct __is_duration > : true_type {}; - -template -struct __is_duration > : true_type {}; - -template -struct __is_duration > : true_type {}; - -template -struct __is_duration > : true_type {}; - -} // namespace chrono - -template -struct _LIBCPP_TEMPLATE_VIS common_type, - chrono::duration<_Rep2, _Period2> > -{ - typedef chrono::duration::type, - typename __ratio_gcd<_Period1, _Period2>::type> type; -}; - -namespace chrono { - -// duration_cast - -template ::type, - bool = _Period::num == 1, - bool = _Period::den == 1> -struct __duration_cast; - -template -struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - return _ToDuration(static_cast(__fd.count())); - } -}; - -template -struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type::type _Ct; - return _ToDuration(static_cast( - static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); - } -}; - -template -struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type::type _Ct; - return _ToDuration(static_cast( - static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); - } -}; - -template -struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - _ToDuration operator()(const _FromDuration& __fd) const - { - typedef typename common_type::type _Ct; - return _ToDuration(static_cast( - static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) - / static_cast<_Ct>(_Period::den))); - } -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -duration_cast(const duration<_Rep, _Period>& __fd) -{ - return __duration_cast, _ToDuration>()(__fd); -} - -template -struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; -#endif - -template -struct _LIBCPP_TEMPLATE_VIS duration_values -{ -public: - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} -}; - -#if _LIBCPP_STD_VER > 14 -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -floor(const duration<_Rep, _Period>& __d) -{ - _ToDuration __t = duration_cast<_ToDuration>(__d); - if (__t > __d) - __t = __t - _ToDuration{1}; - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -ceil(const duration<_Rep, _Period>& __d) -{ - _ToDuration __t = duration_cast<_ToDuration>(__d); - if (__t < __d) - __t = __t + _ToDuration{1}; - return __t; -} - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type -round(const duration<_Rep, _Period>& __d) -{ - _ToDuration __lower = floor<_ToDuration>(__d); - _ToDuration __upper = __lower + _ToDuration{1}; - auto __lowerDiff = __d - __lower; - auto __upperDiff = __upper - __d; - if (__lowerDiff < __upperDiff) - return __lower; - if (__lowerDiff > __upperDiff) - return __upper; - return __lower.count() & 1 ? __upper : __lower; -} -#endif - -// duration - -template -class _LIBCPP_TEMPLATE_VIS duration -{ - static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); - static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); - static_assert(_Period::num > 0, "duration period must be positive"); - - template - struct __no_overflow - { - private: - static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; - static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; - static const intmax_t __n1 = _R1::num / __gcd_n1_n2; - static const intmax_t __d1 = _R1::den / __gcd_d1_d2; - static const intmax_t __n2 = _R2::num / __gcd_n1_n2; - static const intmax_t __d2 = _R2::den / __gcd_d1_d2; - static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); - - template - struct __mul // __overflow == false - { - static const intmax_t value = _Xp * _Yp; - }; - - template - struct __mul<_Xp, _Yp, true> - { - static const intmax_t value = 1; - }; - - public: - static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); - typedef ratio<__mul<__n1, __d2, !value>::value, - __mul<__n2, __d1, !value>::value> type; - }; - -public: - typedef _Rep rep; - typedef typename _Period::type period; -private: - rep __rep_; -public: - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -#ifndef _LIBCPP_CXX03_LANG - duration() = default; -#else - duration() {} -#endif - - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - explicit duration(const _Rep2& __r, - typename enable_if - < - is_convertible::value && - (treat_as_floating_point::value || - !treat_as_floating_point<_Rep2>::value) - >::type* = nullptr) - : __rep_(__r) {} - - // conversions - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - duration(const duration<_Rep2, _Period2>& __d, - typename enable_if - < - __no_overflow<_Period2, period>::value && ( - treat_as_floating_point::value || - (__no_overflow<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value)) - >::type* = nullptr) - : __rep_(chrono::duration_cast(__d).count()) {} - - // observer - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} - - // arithmetic - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type::type operator+() const {return typename common_type::type(*this);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type::type operator-() const {return typename common_type::type(-__rep_);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} - - // special values - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values::zero());} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values::min());} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values::max());} -}; - -typedef duration nanoseconds; -typedef duration microseconds; -typedef duration milliseconds; -typedef duration seconds; -typedef duration< long, ratio< 60> > minutes; -typedef duration< long, ratio<3600> > hours; -#if _LIBCPP_STD_VER > 17 -typedef duration< int, ratio_multiply, hours::period>> days; -typedef duration< int, ratio_multiply, days::period>> weeks; -typedef duration< int, ratio_multiply, days::period>> years; -typedef duration< int, ratio_divide>> months; -#endif -// Duration == - -template -struct __duration_eq -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const - { - typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; - return _Ct(__lhs).count() == _Ct(__rhs).count(); - } -}; - -template -struct __duration_eq<_LhsDuration, _LhsDuration> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const - {return __lhs.count() == __rhs.count();} -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __duration_eq, duration<_Rep2, _Period2> >()(__lhs, __rhs); -} - -// Duration != - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__lhs == __rhs); -} - -// Duration < - -template -struct __duration_lt -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const - { - typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; - return _Ct(__lhs).count() < _Ct(__rhs).count(); - } -}; - -template -struct __duration_lt<_LhsDuration, _LhsDuration> -{ - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const - {return __lhs.count() < __rhs.count();} -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __duration_lt, duration<_Rep2, _Period2> >()(__lhs, __rhs); -} - -// Duration > - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return __rhs < __lhs; -} - -// Duration <= - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__rhs < __lhs); -} - -// Duration >= - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -bool -operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - return !(__lhs < __rhs); -} - -// Duration + - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type, duration<_Rep2, _Period2> >::type -operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); -} - -// Duration - - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type, duration<_Rep2, _Period2> >::type -operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); -} - -// Duration * - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration::type, _Period> ->::type -operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, - duration::type, _Period> ->::type -operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) -{ - return __d * __s; -} - -// Duration / - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration::type, _Period> ->::type -operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type<_Rep1, _Rep2>::type -operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type, duration<_Rep2, _Period2> >::type _Ct; - return _Ct(__lhs).count() / _Ct(__rhs).count(); -} - -// Duration % - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration::type, _Period> ->::type -operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef duration<_Cr, _Period> _Cd; - return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR -typename common_type, duration<_Rep2, _Period2> >::type -operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef typename common_type<_Rep1, _Rep2>::type _Cr; - typedef typename common_type, duration<_Rep2, _Period2> >::type _Cd; - return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); -} - -} // namespace chrono - -#if _LIBCPP_STD_VER > 11 -// Suffixes for duration literals [time.duration.literals] -inline namespace literals -{ - inline namespace chrono_literals - { - - constexpr chrono::hours operator""h(unsigned long long __h) - { - return chrono::hours(static_cast(__h)); - } - - constexpr chrono::duration> operator""h(long double __h) - { - return chrono::duration>(__h); - } - - - constexpr chrono::minutes operator""min(unsigned long long __m) - { - return chrono::minutes(static_cast(__m)); - } - - constexpr chrono::duration> operator""min(long double __m) - { - return chrono::duration> (__m); - } - - - constexpr chrono::seconds operator""s(unsigned long long __s) - { - return chrono::seconds(static_cast(__s)); - } - - constexpr chrono::duration operator""s(long double __s) - { - return chrono::duration (__s); - } - - - constexpr chrono::milliseconds operator""ms(unsigned long long __ms) - { - return chrono::milliseconds(static_cast(__ms)); - } - - constexpr chrono::duration operator""ms(long double __ms) - { - return chrono::duration(__ms); - } - - - constexpr chrono::microseconds operator""us(unsigned long long __us) - { - return chrono::microseconds(static_cast(__us)); - } - - constexpr chrono::duration operator""us(long double __us) - { - return chrono::duration (__us); - } - - - constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) - { - return chrono::nanoseconds(static_cast(__ns)); - } - - constexpr chrono::duration operator""ns(long double __ns) - { - return chrono::duration (__ns); - } - -} // namespace chrono_literals -} // namespace literals - -namespace chrono { // hoist the literals into namespace std::chrono - using namespace literals::chrono_literals; -} // namespace chrono - -#endif // _LIBCPP_STD_VER > 11 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___CHRONO_DURATION_H diff --git a/include/__chrono/file_clock.h b/include/__chrono/file_clock.h deleted file mode 100644 index cd8758f81..000000000 --- a/include/__chrono/file_clock.h +++ /dev/null @@ -1,85 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_FILE_CLOCK_H -#define _LIBCPP___CHRONO_FILE_CLOCK_H - -#include <__availability> -#include <__chrono/duration.h> -#include <__chrono/system_clock.h> -#include <__chrono/time_point.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#ifndef _LIBCPP_CXX03_LANG -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -struct _FilesystemClock; -_LIBCPP_END_NAMESPACE_FILESYSTEM -#endif // !_LIBCPP_CXX03_LANG - -#if _LIBCPP_STD_VER > 17 - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -// [time.clock.file], type file_clock -using file_clock = _VSTD_FS::_FilesystemClock; - -template -using file_time = time_point; - -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER > 17 - -#ifndef _LIBCPP_CXX03_LANG -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -struct _FilesystemClock { -#if !defined(_LIBCPP_HAS_NO_INT128) - typedef __int128_t rep; - typedef nano period; -#else - typedef long long rep; - typedef nano period; -#endif - - typedef chrono::duration duration; - typedef chrono::time_point<_FilesystemClock> time_point; - - _LIBCPP_EXPORTED_FROM_ABI - static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; - - _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; - -#if _LIBCPP_STD_VER > 17 - template - _LIBCPP_HIDE_FROM_ABI - static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { - return chrono::sys_time<_Duration>(__t.time_since_epoch()); - } - - template - _LIBCPP_HIDE_FROM_ABI - static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) { - return chrono::file_time<_Duration>(__t.time_since_epoch()); - } -#endif // _LIBCPP_STD_VER > 17 -}; -_LIBCPP_END_NAMESPACE_FILESYSTEM -#endif // !_LIBCPP_CXX03_LANG - -#endif // _LIBCPP___CHRONO_FILE_CLOCK_H diff --git a/include/__chrono/high_resolution_clock.h b/include/__chrono/high_resolution_clock.h deleted file mode 100644 index f5cde4acb..000000000 --- a/include/__chrono/high_resolution_clock.h +++ /dev/null @@ -1,36 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H -#define _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H - -#include <__chrono/steady_clock.h> -#include <__chrono/system_clock.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK -typedef steady_clock high_resolution_clock; -#else -typedef system_clock high_resolution_clock; -#endif - -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H diff --git a/include/__chrono/steady_clock.h b/include/__chrono/steady_clock.h deleted file mode 100644 index 5ba911df8..000000000 --- a/include/__chrono/steady_clock.h +++ /dev/null @@ -1,44 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_STEADY_CLOCK_H -#define _LIBCPP___CHRONO_STEADY_CLOCK_H - -#include <__chrono/duration.h> -#include <__chrono/time_point.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK -class _LIBCPP_TYPE_VIS steady_clock -{ -public: - typedef nanoseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point time_point; - static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; - - static time_point now() _NOEXCEPT; -}; -#endif - -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHRONO_STEADY_CLOCK_H diff --git a/include/__chrono/system_clock.h b/include/__chrono/system_clock.h deleted file mode 100644 index 9c977d369..000000000 --- a/include/__chrono/system_clock.h +++ /dev/null @@ -1,54 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_SYSTEM_CLOCK_H -#define _LIBCPP___CHRONO_SYSTEM_CLOCK_H - -#include <__chrono/duration.h> -#include <__chrono/time_point.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -class _LIBCPP_TYPE_VIS system_clock -{ -public: - typedef microseconds duration; - typedef duration::rep rep; - typedef duration::period period; - typedef chrono::time_point time_point; - static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; - - static time_point now() _NOEXCEPT; - static time_t to_time_t (const time_point& __t) _NOEXCEPT; - static time_point from_time_t(time_t __t) _NOEXCEPT; -}; - -#if _LIBCPP_STD_VER > 17 - -template -using sys_time = time_point; -using sys_seconds = sys_time; -using sys_days = sys_time; - -#endif - -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CHRONO_SYSTEM_CLOCK_H diff --git a/include/__chrono/time_point.h b/include/__chrono/time_point.h deleted file mode 100644 index c042e1251..000000000 --- a/include/__chrono/time_point.h +++ /dev/null @@ -1,249 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CHRONO_TIME_POINT_H -#define _LIBCPP___CHRONO_TIME_POINT_H - -#include <__chrono/duration.h> -#include <__config> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace chrono -{ - -template -class _LIBCPP_TEMPLATE_VIS time_point -{ - static_assert(__is_duration<_Duration>::value, - "Second template parameter of time_point must be a std::chrono::duration"); -public: - typedef _Clock clock; - typedef _Duration duration; - typedef typename duration::rep rep; - typedef typename duration::period period; -private: - duration __d_; - -public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} - - // conversions - template - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 - time_point(const time_point& t, - typename enable_if - < - is_convertible<_Duration2, duration>::value - >::type* = nullptr) - : __d_(t.time_since_epoch()) {} - - // observer - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} - - // arithmetic - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} - - // special values - - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());} - _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());} -}; - -} // namespace chrono - -template -struct _LIBCPP_TEMPLATE_VIS common_type, - chrono::time_point<_Clock, _Duration2> > -{ - typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; -}; - -namespace chrono { - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, _ToDuration> -time_point_cast(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); -} - -#if _LIBCPP_STD_VER > 14 -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -floor(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; -} - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -ceil(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; -} - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type -round(const time_point<_Clock, _Duration>& __t) -{ - return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; -} - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - numeric_limits<_Rep>::is_signed, - duration<_Rep, _Period> ->::type -abs(duration<_Rep, _Period> __d) -{ - return __d >= __d.zero() ? +__d : -__d; -} -#endif // _LIBCPP_STD_VER > 14 - -// time_point == - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() == __rhs.time_since_epoch(); -} - -// time_point != - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__lhs == __rhs); -} - -// time_point < - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() < __rhs.time_since_epoch(); -} - -// time_point > - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __rhs < __lhs; -} - -// time_point <= - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__rhs < __lhs); -} - -// time_point >= - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -bool -operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return !(__lhs < __rhs); -} - -// time_point operator+(time_point x, duration y); - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> -operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; - return _Tr (__lhs.time_since_epoch() + __rhs); -} - -// time_point operator+(duration x, time_point y); - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type, _Duration2>::type> -operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __rhs + __lhs; -} - -// time_point operator-(time_point x, duration y); - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> -operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) -{ - typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; - return _Ret(__lhs.time_since_epoch() -__rhs); -} - -// duration operator-(time_point x, time_point y); - -template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 -typename common_type<_Duration1, _Duration2>::type -operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) -{ - return __lhs.time_since_epoch() - __rhs.time_since_epoch(); -} - -} // namespace chrono - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___CHRONO_TIME_POINT_H diff --git a/include/__compare/common_comparison_category.h b/include/__compare/common_comparison_category.h deleted file mode 100644 index 37a28db1d..000000000 --- a/include/__compare/common_comparison_category.h +++ /dev/null @@ -1,94 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H -#define _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H - -#include <__compare/ordering.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -namespace __comp_detail { - -enum _ClassifyCompCategory : unsigned { - _None, - _PartialOrd, - _WeakOrd, - _StrongOrd, - _CCC_Size -}; - -template -_LIBCPP_HIDE_FROM_ABI -constexpr _ClassifyCompCategory __type_to_enum() noexcept { - if (is_same_v<_Tp, partial_ordering>) - return _PartialOrd; - if (is_same_v<_Tp, weak_ordering>) - return _WeakOrd; - if (is_same_v<_Tp, strong_ordering>) - return _StrongOrd; - return _None; -} - -template -_LIBCPP_HIDE_FROM_ABI -constexpr _ClassifyCompCategory -__compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) { - int __seen[_CCC_Size] = {}; - for (auto __type : __types) - ++__seen[__type]; - if (__seen[_None]) - return _None; - if (__seen[_PartialOrd]) - return _PartialOrd; - if (__seen[_WeakOrd]) - return _WeakOrd; - return _StrongOrd; -} - -template -_LIBCPP_HIDE_FROM_ABI -constexpr auto __get_comp_type() { - using _CCC = _ClassifyCompCategory; - constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...}; - constexpr _CCC _Cat = __compute_comp_type(__type_kinds); - if constexpr (_Cat == _None) - return void(); - else if constexpr (_Cat == _PartialOrd) - return partial_ordering::equivalent; - else if constexpr (_Cat == _WeakOrd) - return weak_ordering::equivalent; - else if constexpr (_Cat == _StrongOrd) - return strong_ordering::equivalent; - else - static_assert(_False, "unhandled case"); -} -} // namespace __comp_detail - -// [cmp.common], common comparison category type -template -struct _LIBCPP_TEMPLATE_VIS common_comparison_category { - using type = decltype(__comp_detail::__get_comp_type<_Ts...>()); -}; - -template -using common_comparison_category_t = typename common_comparison_category<_Ts...>::type; - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H diff --git a/include/__compare/compare_partial_order_fallback.h b/include/__compare/compare_partial_order_fallback.h deleted file mode 100644 index 64937eaf3..000000000 --- a/include/__compare/compare_partial_order_fallback.h +++ /dev/null @@ -1,73 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK -#define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK - -#include <__compare/ordering.h> -#include <__compare/partial_order.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __compare_partial_order_fallback { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) - noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - -> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) - { return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : - _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : - partial_ordering::unordered)) - -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : - _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : - partial_ordering::unordered) - { - return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : - _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : - partial_ordering::unordered; - } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } - }; -} // namespace __compare_partial_order_fallback - -inline namespace __cpo { - inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK diff --git a/include/__compare/compare_strong_order_fallback.h b/include/__compare/compare_strong_order_fallback.h deleted file mode 100644 index b7abef26e..000000000 --- a/include/__compare/compare_strong_order_fallback.h +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK -#define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK - -#include <__compare/ordering.h> -#include <__compare/strong_order.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __compare_strong_order_fallback { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) - noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - -> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) - { return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : - strong_ordering::greater)) - -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : - strong_ordering::greater) - { - return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : - strong_ordering::greater; - } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } - }; -} // namespace __compare_strong_order_fallback - -inline namespace __cpo { - inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK diff --git a/include/__compare/compare_three_way.h b/include/__compare/compare_three_way.h deleted file mode 100644 index ddd37890a..000000000 --- a/include/__compare/compare_three_way.h +++ /dev/null @@ -1,41 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMPARE_THREE_WAY_H -#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_H - -#include <__compare/three_way_comparable.h> -#include <__config> -#include <__utility/forward.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -struct _LIBCPP_TEMPLATE_VIS compare_three_way -{ - template - requires three_way_comparable_with<_T1, _T2> - constexpr _LIBCPP_HIDE_FROM_ABI - auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u))) - { return _VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u); } - - using is_transparent = void; -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H diff --git a/include/__compare/compare_three_way_result.h b/include/__compare/compare_three_way_result.h deleted file mode 100644 index 14908c6bb..000000000 --- a/include/__compare/compare_three_way_result.h +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H -#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -template -struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { }; - -template -struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype( - declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void() -)> { - using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>()); -}; - -template -struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> { }; - -template -using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type; - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H diff --git a/include/__compare/compare_weak_order_fallback.h b/include/__compare/compare_weak_order_fallback.h deleted file mode 100644 index 5a1807e69..000000000 --- a/include/__compare/compare_weak_order_fallback.h +++ /dev/null @@ -1,70 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK -#define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK - -#include <__compare/ordering.h> -#include <__compare/weak_order.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __compare_weak_order_fallback { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) - noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - -> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) - { return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : - weak_ordering::greater)) - -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : - weak_ordering::greater) - { - return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : - _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : - weak_ordering::greater; - } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } - }; -} // namespace __compare_weak_order_fallback - -inline namespace __cpo { - inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK diff --git a/include/__compare/is_eq.h b/include/__compare/is_eq.h deleted file mode 100644 index 906cb0709..000000000 --- a/include/__compare/is_eq.h +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_IS_EQ_H -#define _LIBCPP___COMPARE_IS_EQ_H - -#include <__compare/ordering.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; } -_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; } - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_IS_EQ_H diff --git a/include/__compare/ordering.h b/include/__compare/ordering.h deleted file mode 100644 index d4087bc85..000000000 --- a/include/__compare/ordering.h +++ /dev/null @@ -1,319 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_ORDERING_H -#define _LIBCPP___COMPARE_ORDERING_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// exposition only -enum class _LIBCPP_ENUM_VIS _OrdResult : signed char { - __less = -1, - __equiv = 0, - __greater = 1 -}; - -enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char { - __unordered = -127 -}; - -class partial_ordering; -class weak_ordering; -class strong_ordering; - -template -inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); - -struct _CmpUnspecifiedParam { - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEVAL - _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} - - template>> - _CmpUnspecifiedParam(_Tp) = delete; -}; - -class partial_ordering { - using _ValueT = signed char; - - _LIBCPP_HIDE_FROM_ABI - explicit constexpr partial_ordering(_OrdResult __v) noexcept - : __value_(_ValueT(__v)) {} - - _LIBCPP_HIDE_FROM_ABI - explicit constexpr partial_ordering(_NCmpResult __v) noexcept - : __value_(_ValueT(__v)) {} - - _LIBCPP_HIDE_FROM_ABI - constexpr bool __is_ordered() const noexcept { - return __value_ != _ValueT(_NCmpResult::__unordered); - } -public: - // valid values - static const partial_ordering less; - static const partial_ordering equivalent; - static const partial_ordering greater; - static const partial_ordering unordered; - - // comparisons - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ == 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ < 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ <= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ > 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ >= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 < __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 <= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 > __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 >= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); - } -private: - _ValueT __value_; -}; - -inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less); -inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv); -inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); -inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); - -class weak_ordering { - using _ValueT = signed char; - - _LIBCPP_HIDE_FROM_ABI - explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} - -public: - static const weak_ordering less; - static const weak_ordering equivalent; - static const weak_ordering greater; - - _LIBCPP_HIDE_FROM_ABI - constexpr operator partial_ordering() const noexcept { - return __value_ == 0 ? partial_ordering::equivalent - : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); - } - - // comparisons - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default; - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ == 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ < 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ <= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ > 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ >= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 < __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 <= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 > __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 >= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); - } - -private: - _ValueT __value_; -}; - -inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less); -inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv); -inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); - -class strong_ordering { - using _ValueT = signed char; - - _LIBCPP_HIDE_FROM_ABI - explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} - -public: - static const strong_ordering less; - static const strong_ordering equal; - static const strong_ordering equivalent; - static const strong_ordering greater; - - // conversions - _LIBCPP_HIDE_FROM_ABI - constexpr operator partial_ordering() const noexcept { - return __value_ == 0 ? partial_ordering::equivalent - : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); - } - - _LIBCPP_HIDE_FROM_ABI - constexpr operator weak_ordering() const noexcept { - return __value_ == 0 ? weak_ordering::equivalent - : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater); - } - - // comparisons - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default; - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ == 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ < 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ <= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ > 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ >= 0; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 < __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 <= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 > __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 >= __v.__value_; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; - } - - _LIBCPP_HIDE_FROM_ABI - friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); - } - -private: - _ValueT __value_; -}; - -inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less); -inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv); -inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv); -inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater); - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_ORDERING_H diff --git a/include/__compare/partial_order.h b/include/__compare/partial_order.h deleted file mode 100644 index cbadfcde7..000000000 --- a/include/__compare/partial_order.h +++ /dev/null @@ -1,71 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_PARTIAL_ORDER -#define _LIBCPP___COMPARE_PARTIAL_ORDER - -#include <__compare/compare_three_way.h> -#include <__compare/ordering.h> -#include <__compare/weak_order.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __partial_order { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) - noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) - noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } - }; -} // namespace __partial_order - -inline namespace __cpo { - inline constexpr auto partial_order = __partial_order::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_PARTIAL_ORDER diff --git a/include/__compare/strong_order.h b/include/__compare/strong_order.h deleted file mode 100644 index a0dc07704..000000000 --- a/include/__compare/strong_order.h +++ /dev/null @@ -1,136 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_STRONG_ORDER -#define _LIBCPP___COMPARE_STRONG_ORDER - -#include <__bit/bit_cast.h> -#include <__compare/compare_three_way.h> -#include <__compare/ordering.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include -#include -#include -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __strong_order { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) - noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template> - requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> - _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept - { - if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) { - int32_t __rx = _VSTD::bit_cast(__t); - int32_t __ry = _VSTD::bit_cast(__u); - __rx = (__rx < 0) ? (numeric_limits::min() - __rx - 1) : __rx; - __ry = (__ry < 0) ? (numeric_limits::min() - __ry - 1) : __ry; - return (__rx <=> __ry); - } else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) { - int64_t __rx = _VSTD::bit_cast(__t); - int64_t __ry = _VSTD::bit_cast(__u); - __rx = (__rx < 0) ? (numeric_limits::min() - __rx - 1) : __rx; - __ry = (__ry < 0) ? (numeric_limits::min() - __ry - 1) : __ry; - return (__rx <=> __ry); - } else if (__t < __u) { - return strong_ordering::less; - } else if (__t > __u) { - return strong_ordering::greater; - } else if (__t == __u) { - if constexpr (numeric_limits<_Dp>::radix == 2) { - return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); - } else { - // This is bullet 3 of the IEEE754 algorithm, relevant - // only for decimal floating-point; - // see https://stackoverflow.com/questions/69068075/ - if (__t == 0 || _VSTD::isinf(__t)) { - return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); - } else { - int __texp, __uexp; - (void)_VSTD::frexp(__t, &__texp); - (void)_VSTD::frexp(__u, &__uexp); - return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); - } - } - } else { - // They're unordered, so one of them must be a NAN. - // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. - bool __t_is_nan = _VSTD::isnan(__t); - bool __u_is_nan = _VSTD::isnan(__u); - bool __t_is_negative = _VSTD::signbit(__t); - bool __u_is_negative = _VSTD::signbit(__u); - using _IntType = conditional_t< - sizeof(__t) == sizeof(int32_t), int32_t, conditional_t< - sizeof(__t) == sizeof(int64_t), int64_t, void> - >; - if constexpr (is_same_v<_IntType, void>) { - static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type"); - } else if (__t_is_nan && __u_is_nan) { - // Order by sign bit, then by "payload bits" (we'll just use bit_cast). - if (__t_is_negative != __u_is_negative) { - return (__u_is_negative <=> __t_is_negative); - } else { - return _VSTD::bit_cast<_IntType>(__t) <=> _VSTD::bit_cast<_IntType>(__u); - } - } else if (__t_is_nan) { - return __t_is_negative ? strong_ordering::less : strong_ordering::greater; - } else { - return __u_is_negative ? strong_ordering::greater : strong_ordering::less; - } - } - } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } - }; -} // namespace __strong_order - -inline namespace __cpo { - inline constexpr auto strong_order = __strong_order::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___COMPARE_STRONG_ORDER diff --git a/include/__compare/synth_three_way.h b/include/__compare/synth_three_way.h deleted file mode 100644 index b93d4932c..000000000 --- a/include/__compare/synth_three_way.h +++ /dev/null @@ -1,51 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_SYNTH_THREE_WAY_H -#define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H - -#include <__compare/ordering.h> -#include <__compare/three_way_comparable.h> -#include <__concepts/boolean_testable.h> -#include <__config> -#include <__utility/declval.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [expos.only.func] - -_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = - [](const _Tp& __t, const _Up& __u) - requires requires { - { __t < __u } -> __boolean_testable; - { __u < __t } -> __boolean_testable; - } - { - if constexpr (three_way_comparable_with<_Tp, _Up>) { - return __t <=> __u; - } else { - if (__t < __u) return weak_ordering::less; - if (__u < __t) return weak_ordering::greater; - return weak_ordering::equivalent; - } - }; - -template -using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>())); - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H diff --git a/include/__compare/three_way_comparable.h b/include/__compare/three_way_comparable.h deleted file mode 100644 index 548bf17f0..000000000 --- a/include/__compare/three_way_comparable.h +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H -#define _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H - -#include <__compare/common_comparison_category.h> -#include <__compare/ordering.h> -#include <__concepts/common_reference_with.h> -#include <__concepts/equality_comparable.h> -#include <__concepts/same_as.h> -#include <__concepts/totally_ordered.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -concept __compares_as = - same_as, _Cat>; - -template -concept three_way_comparable = - __weakly_equality_comparable_with<_Tp, _Tp> && - __partially_ordered_with<_Tp, _Tp> && - requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) { - { __a <=> __b } -> __compares_as<_Cat>; - }; - -template -concept three_way_comparable_with = - three_way_comparable<_Tp, _Cat> && - three_way_comparable<_Up, _Cat> && - common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && - three_way_comparable, __make_const_lvalue_ref<_Up>>, _Cat> && - __weakly_equality_comparable_with<_Tp, _Up> && - __partially_ordered_with<_Tp, _Up> && - requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { - { __t <=> __u } -> __compares_as<_Cat>; - { __u <=> __t } -> __compares_as<_Cat>; - }; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H diff --git a/include/__compare/weak_order.h b/include/__compare/weak_order.h deleted file mode 100644 index 1286f39b0..000000000 --- a/include/__compare/weak_order.h +++ /dev/null @@ -1,100 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COMPARE_WEAK_ORDER -#define _LIBCPP___COMPARE_WEAK_ORDER - -#include <__compare/compare_three_way.h> -#include <__compare/ordering.h> -#include <__compare/strong_order.h> -#include <__config> -#include <__utility/forward.h> -#include <__utility/priority_tag.h> -#include -#include - -#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [cmp.alg] -namespace __weak_order { - struct __fn { - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<3>) - noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template> - requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> - _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering - __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept - { - partial_ordering __po = (__t <=> __u); - if (__po == partial_ordering::less) { - return weak_ordering::less; - } else if (__po == partial_ordering::equivalent) { - return weak_ordering::equivalent; - } else if (__po == partial_ordering::greater) { - return weak_ordering::greater; - } else { - // Otherwise, at least one of them is a NaN. - bool __t_is_nan = _VSTD::isnan(__t); - bool __u_is_nan = _VSTD::isnan(__u); - bool __t_is_negative = _VSTD::signbit(__t); - bool __u_is_negative = _VSTD::signbit(__u); - if (__t_is_nan && __u_is_nan) { - return (__u_is_negative <=> __t_is_negative); - } else if (__t_is_nan) { - return __t_is_negative ? weak_ordering::less : weak_ordering::greater; - } else { - return __u_is_negative ? weak_ordering::greater : weak_ordering::less; - } - } - } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) - noexcept(noexcept(weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - requires is_same_v, decay_t<_Up>> - _LIBCPP_HIDE_FROM_ABI static constexpr auto - __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) - noexcept(noexcept(weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) - -> decltype( weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { return weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } - - template - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()))) - -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>())) - { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()); } - }; -} // namespace __weak_order - -inline namespace __cpo { - inline constexpr auto weak_order = __weak_order::__fn{}; -} // namespace __cpo - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___COMPARE_WEAK_ORDER diff --git a/include/__concepts/arithmetic.h b/include/__concepts/arithmetic.h deleted file mode 100644 index c2f94239a..000000000 --- a/include/__concepts/arithmetic.h +++ /dev/null @@ -1,48 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_ARITHMETIC_H -#define _LIBCPP___CONCEPTS_ARITHMETIC_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concepts.arithmetic], arithmetic concepts - -template -concept integral = is_integral_v<_Tp>; - -template -concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; - -template -concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; - -template -concept floating_point = is_floating_point_v<_Tp>; - -// Concept helpers for the internal type traits for the fundamental types. - -template -concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; -template -concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_ARITHMETIC_H diff --git a/include/__concepts/assignable.h b/include/__concepts/assignable.h deleted file mode 100644 index 62f39f1c8..000000000 --- a/include/__concepts/assignable.h +++ /dev/null @@ -1,40 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_ASSIGNABLE_H -#define _LIBCPP___CONCEPTS_ASSIGNABLE_H - -#include <__concepts/common_reference_with.h> -#include <__concepts/same_as.h> -#include <__config> -#include <__utility/forward.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.assignable] - -template -concept assignable_from = - is_lvalue_reference_v<_Lhs> && - common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> && - requires (_Lhs __lhs, _Rhs&& __rhs) { - { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>; - }; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_ASSIGNABLE_H diff --git a/include/__concepts/boolean_testable.h b/include/__concepts/boolean_testable.h deleted file mode 100644 index c04c30429..000000000 --- a/include/__concepts/boolean_testable.h +++ /dev/null @@ -1,38 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H -#define _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H - -#include <__concepts/convertible_to.h> -#include <__config> -#include <__utility/forward.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concepts.booleantestable] - -template -concept __boolean_testable_impl = convertible_to<_Tp, bool>; - -template -concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) { - { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl; -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H diff --git a/include/__concepts/class_or_enum.h b/include/__concepts/class_or_enum.h deleted file mode 100644 index 3d28a8ad9..000000000 --- a/include/__concepts/class_or_enum.h +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H -#define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// Whether a type is a class type or enumeration type according to the Core wording. - -template -concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; - -// Work around Clang bug https://llvm.org/PR52970 -template -concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H diff --git a/include/__concepts/common_reference_with.h b/include/__concepts/common_reference_with.h deleted file mode 100644 index 119d8fd8d..000000000 --- a/include/__concepts/common_reference_with.h +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H -#define _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H - -#include <__concepts/convertible_to.h> -#include <__concepts/same_as.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.commonref] - -template -concept common_reference_with = - same_as, common_reference_t<_Up, _Tp>> && - convertible_to<_Tp, common_reference_t<_Tp, _Up>> && - convertible_to<_Up, common_reference_t<_Tp, _Up>>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H diff --git a/include/__concepts/common_with.h b/include/__concepts/common_with.h deleted file mode 100644 index ecaa23b63..000000000 --- a/include/__concepts/common_with.h +++ /dev/null @@ -1,47 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_COMMON_WITH_H -#define _LIBCPP___CONCEPTS_COMMON_WITH_H - -#include <__concepts/common_reference_with.h> -#include <__concepts/same_as.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.common] - -template -concept common_with = - same_as, common_type_t<_Up, _Tp>> && - requires { - static_cast>(declval<_Tp>()); - static_cast>(declval<_Up>()); - } && - common_reference_with< - add_lvalue_reference_t, - add_lvalue_reference_t> && - common_reference_with< - add_lvalue_reference_t>, - common_reference_t< - add_lvalue_reference_t, - add_lvalue_reference_t>>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_COMMON_WITH_H diff --git a/include/__concepts/constructible.h b/include/__concepts/constructible.h deleted file mode 100644 index 49986bb24..000000000 --- a/include/__concepts/constructible.h +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H -#define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H - -#include <__concepts/convertible_to.h> -#include <__concepts/destructible.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.constructible] -template -concept constructible_from = - destructible<_Tp> && is_constructible_v<_Tp, _Args...>; - -// [concept.default.init] - -template -concept __default_initializable = requires { ::new _Tp; }; - -template -concept default_initializable = constructible_from<_Tp> && - requires { _Tp{}; } && __default_initializable<_Tp>; - -// [concept.moveconstructible] -template -concept move_constructible = - constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; - -// [concept.copyconstructible] -template -concept copy_constructible = - move_constructible<_Tp> && - constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> && - constructible_from<_Tp, const _Tp&> && convertible_to && - constructible_from<_Tp, const _Tp> && convertible_to; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H diff --git a/include/__concepts/convertible_to.h b/include/__concepts/convertible_to.h deleted file mode 100644 index 75f5da203..000000000 --- a/include/__concepts/convertible_to.h +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H -#define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H - -#include <__config> -#include <__utility/declval.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.convertible] - -template -concept convertible_to = - is_convertible_v<_From, _To> && - requires { - static_cast<_To>(declval<_From>()); - }; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H diff --git a/include/__concepts/copyable.h b/include/__concepts/copyable.h deleted file mode 100644 index c264b31a2..000000000 --- a/include/__concepts/copyable.h +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_COPYABLE_H -#define _LIBCPP___CONCEPTS_COPYABLE_H - -#include <__concepts/assignable.h> -#include <__concepts/constructible.h> -#include <__concepts/movable.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concepts.object] - -template -concept copyable = - copy_constructible<_Tp> && - movable<_Tp> && - assignable_from<_Tp&, _Tp&> && - assignable_from<_Tp&, const _Tp&> && - assignable_from<_Tp&, const _Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_COPYABLE_H diff --git a/include/__concepts/derived_from.h b/include/__concepts/derived_from.h deleted file mode 100644 index acd4ba473..000000000 --- a/include/__concepts/derived_from.h +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_DERIVED_FROM_H -#define _LIBCPP___CONCEPTS_DERIVED_FROM_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.derived] - -template -concept derived_from = - is_base_of_v<_Bp, _Dp> && - is_convertible_v; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_DERIVED_FROM_H diff --git a/include/__concepts/destructible.h b/include/__concepts/destructible.h deleted file mode 100644 index d57824be9..000000000 --- a/include/__concepts/destructible.h +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_DESTRUCTIBLE_H -#define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.destructible] - -template -concept destructible = is_nothrow_destructible_v<_Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_DESTRUCTIBLE_H diff --git a/include/__concepts/different_from.h b/include/__concepts/different_from.h deleted file mode 100644 index c8560baf8..000000000 --- a/include/__concepts/different_from.h +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_DIFFERENT_FROM_H -#define _LIBCPP___CONCEPTS_DIFFERENT_FROM_H - -#include <__concepts/same_as.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -concept __different_from = !same_as, remove_cvref_t<_Up>>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_DIFFERENT_FROM_H diff --git a/include/__concepts/equality_comparable.h b/include/__concepts/equality_comparable.h deleted file mode 100644 index 064143b89..000000000 --- a/include/__concepts/equality_comparable.h +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H -#define _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H - -#include <__concepts/boolean_testable.h> -#include <__concepts/common_reference_with.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.equalitycomparable] - -template -concept __weakly_equality_comparable_with = - requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { - { __t == __u } -> __boolean_testable; - { __t != __u } -> __boolean_testable; - { __u == __t } -> __boolean_testable; - { __u != __t } -> __boolean_testable; - }; - -template -concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; - -template -concept equality_comparable_with = - equality_comparable<_Tp> && equality_comparable<_Up> && - common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && - equality_comparable< - common_reference_t< - __make_const_lvalue_ref<_Tp>, - __make_const_lvalue_ref<_Up>>> && - __weakly_equality_comparable_with<_Tp, _Up>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H diff --git a/include/__concepts/invocable.h b/include/__concepts/invocable.h deleted file mode 100644 index e528258e3..000000000 --- a/include/__concepts/invocable.h +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_INVOCABLE_H -#define _LIBCPP___CONCEPTS_INVOCABLE_H - -#include <__config> -#include <__functional/invoke.h> -#include <__utility/forward.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.invocable] - -template -concept invocable = requires(_Fn&& __fn, _Args&&... __args) { - _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving -}; - -// [concept.regular.invocable] - -template -concept regular_invocable = invocable<_Fn, _Args...>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_INVOCABLE_H diff --git a/include/__concepts/movable.h b/include/__concepts/movable.h deleted file mode 100644 index fd8c2e7fa..000000000 --- a/include/__concepts/movable.h +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_MOVABLE_H -#define _LIBCPP___CONCEPTS_MOVABLE_H - -#include <__concepts/assignable.h> -#include <__concepts/constructible.h> -#include <__concepts/swappable.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concepts.object] - -template -concept movable = - is_object_v<_Tp> && - move_constructible<_Tp> && - assignable_from<_Tp&, _Tp> && - swappable<_Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_MOVABLE_H diff --git a/include/__concepts/predicate.h b/include/__concepts/predicate.h deleted file mode 100644 index 491a7d6c7..000000000 --- a/include/__concepts/predicate.h +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_PREDICATE_H -#define _LIBCPP___CONCEPTS_PREDICATE_H - -#include <__concepts/boolean_testable.h> -#include <__concepts/invocable.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.predicate] - -template -concept predicate = - regular_invocable<_Fn, _Args...> && __boolean_testable>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_PREDICATE_H diff --git a/include/__concepts/regular.h b/include/__concepts/regular.h deleted file mode 100644 index e8a87c97f..000000000 --- a/include/__concepts/regular.h +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_REGULAR_H -#define _LIBCPP___CONCEPTS_REGULAR_H - -#include <__concepts/equality_comparable.h> -#include <__concepts/semiregular.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.object] - -template -concept regular = semiregular<_Tp> && equality_comparable<_Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_REGULAR_H diff --git a/include/__concepts/relation.h b/include/__concepts/relation.h deleted file mode 100644 index fa7e5d17d..000000000 --- a/include/__concepts/relation.h +++ /dev/null @@ -1,44 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_RELATION_H -#define _LIBCPP___CONCEPTS_RELATION_H - -#include <__concepts/predicate.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.relation] - -template -concept relation = - predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> && - predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>; - -// [concept.equiv] - -template -concept equivalence_relation = relation<_Rp, _Tp, _Up>; - -// [concept.strictweakorder] - -template -concept strict_weak_order = relation<_Rp, _Tp, _Up>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_RELATION_H diff --git a/include/__concepts/same_as.h b/include/__concepts/same_as.h deleted file mode 100644 index ee86c44ea..000000000 --- a/include/__concepts/same_as.h +++ /dev/null @@ -1,35 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_SAME_AS_H -#define _LIBCPP___CONCEPTS_SAME_AS_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.same] - -template -concept __same_as_impl = _IsSame<_Tp, _Up>::value; - -template -concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_SAME_AS_H diff --git a/include/__concepts/semiregular.h b/include/__concepts/semiregular.h deleted file mode 100644 index 4797fc7ea..000000000 --- a/include/__concepts/semiregular.h +++ /dev/null @@ -1,33 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_SEMIREGULAR_H -#define _LIBCPP___CONCEPTS_SEMIREGULAR_H - -#include <__concepts/constructible.h> -#include <__concepts/copyable.h> -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.object] - -template -concept semiregular = copyable<_Tp> && default_initializable<_Tp>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_SEMIREGULAR_H diff --git a/include/__concepts/swappable.h b/include/__concepts/swappable.h deleted file mode 100644 index 6b8cf82b7..000000000 --- a/include/__concepts/swappable.h +++ /dev/null @@ -1,116 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_SWAPPABLE_H -#define _LIBCPP___CONCEPTS_SWAPPABLE_H - -#include <__concepts/assignable.h> -#include <__concepts/class_or_enum.h> -#include <__concepts/common_reference_with.h> -#include <__concepts/constructible.h> -#include <__config> -#include <__utility/exchange.h> -#include <__utility/forward.h> -#include <__utility/move.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.swappable] - -namespace ranges { -namespace __swap { - - template - void swap(_Tp&, _Tp&) = delete; - - template - concept __unqualified_swappable_with = - (__class_or_enum> || __class_or_enum>) && - requires(_Tp&& __t, _Up&& __u) { - swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); - }; - - struct __fn; - - template - concept __swappable_arrays = - !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> && - extent_v<_Tp> == extent_v<_Up> && - requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) { - __swap(__t[0], __u[0]); - }; - - template - concept __exchangeable = - !__unqualified_swappable_with<_Tp&, _Tp&> && - move_constructible<_Tp> && - assignable_from<_Tp&, _Tp>; - - struct __fn { - // 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and... - // *The name `swap` is used here unqualified. - template - requires __unqualified_swappable_with<_Tp, _Up> - constexpr void operator()(_Tp&& __t, _Up&& __u) const - noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) - { - swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); - } - - // 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and... - template - requires __swappable_arrays<_Tp, _Up, _Size> - constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const - noexcept(noexcept((*this)(*__t, *__u))) - { - // TODO(cjdb): replace with `ranges::swap_ranges`. - for (size_t __i = 0; __i < _Size; ++__i) { - (*this)(__t[__i], __u[__i]); - } - } - - // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models... - template<__exchangeable _Tp> - constexpr void operator()(_Tp& __x, _Tp& __y) const - noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>) - { - __y = _VSTD::exchange(__x, _VSTD::move(__y)); - } - }; -} // namespace __swap - -inline namespace __cpo { - inline constexpr auto swap = __swap::__fn{}; -} // namespace __cpo -} // namespace ranges - -template -concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; - -template -concept swappable_with = - common_reference_with<_Tp, _Up> && - requires(_Tp&& __t, _Up&& __u) { - ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t)); - ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u)); - ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); - ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t)); - }; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_SWAPPABLE_H diff --git a/include/__concepts/totally_ordered.h b/include/__concepts/totally_ordered.h deleted file mode 100644 index 58dcb42be..000000000 --- a/include/__concepts/totally_ordered.h +++ /dev/null @@ -1,57 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H -#define _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H - -#include <__concepts/boolean_testable.h> -#include <__concepts/equality_comparable.h> -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [concept.totallyordered] - -template -concept __partially_ordered_with = - requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { - { __t < __u } -> __boolean_testable; - { __t > __u } -> __boolean_testable; - { __t <= __u } -> __boolean_testable; - { __t >= __u } -> __boolean_testable; - { __u < __t } -> __boolean_testable; - { __u > __t } -> __boolean_testable; - { __u <= __t } -> __boolean_testable; - { __u >= __t } -> __boolean_testable; - }; - -template -concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>; - -template -concept totally_ordered_with = - totally_ordered<_Tp> && totally_ordered<_Up> && - equality_comparable_with<_Tp, _Up> && - totally_ordered< - common_reference_t< - __make_const_lvalue_ref<_Tp>, - __make_const_lvalue_ref<_Up>>> && - __partially_ordered_with<_Tp, _Up>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H diff --git a/include/__config b/include/__config index 458d0c1b8..97e33f315 100644 --- a/include/__config +++ b/include/__config @@ -1,5 +1,5 @@ // -*- C++ -*- -//===----------------------------------------------------------------------===// +//===--------------------------- __config ---------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -24,7 +24,17 @@ #ifdef __cplusplus -#define _LIBCPP_VERSION 14000 +#ifdef __GNUC__ +# define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) +// The _GNUC_VER_NEW macro better represents the new GCC versioning scheme +// introduced in GCC 5.0. +# define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) +#else +# define _GNUC_VER 0 +# define _GNUC_VER_NEW 0 +#endif + +#define _LIBCPP_VERSION 13000 #ifndef _LIBCPP_ABI_VERSION # define _LIBCPP_ABI_VERSION 1 @@ -74,15 +84,14 @@ # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE +// Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr +// provided under the alternate keyword __nullptr, which changes the mangling +// of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. +# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR // Define 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 -// 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 // Enable optimized version of __do_get_(un)signed which avoids redundant copies. # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET // In C++20 and later, don't derive std::plus from std::binary_function, @@ -107,17 +116,6 @@ # 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 -// 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 -// Remove basic_string common base -# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON -// Remove vector base class -# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support @@ -134,33 +132,11 @@ # endif #endif -// By default, don't use a nullptr_t emulation type in C++03. -// -// This is technically an ABI break from previous releases, however it is -// very unlikely to impact anyone. If a user is impacted by this break, -// they can return to using the C++03 nullptr emulation by defining -// _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. -// -// This switch will be removed entirely in favour of never providing a -// C++03 emulation after one release. -// -// IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE -// A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN -// IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. -#ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION -# define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR -#endif - #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _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 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_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y @@ -261,10 +237,6 @@ # 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 @@ -293,6 +265,9 @@ # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_BIG_ENDIAN # endif // _BYTE_ORDER == _LITTLE_ENDIAN +# ifndef __LONG_LONG_SUPPORTED +# define _LIBCPP_HAS_NO_LONG_LONG +# endif // __LONG_LONG_SUPPORTED #endif // __FreeBSD__ #if defined(__NetBSD__) || defined(__OpenBSD__) @@ -343,56 +318,18 @@ # 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 - -// Libc++ supports various implementations of std::random_device. -// -// _LIBCPP_USING_DEV_RANDOM -// Read entropy from the given file, by default `/dev/urandom`. -// If a token is provided, it is assumed to be the path to a file -// to read entropy from. This is the default behavior if nothing -// else is specified. This implementation requires storing state -// inside `std::random_device`. -// -// _LIBCPP_USING_ARC4_RANDOM -// Use arc4random(). This allows obtaining random data even when -// using sandboxing mechanisms. On some platforms like Apple, this -// is the recommended source of entropy for user-space programs. -// When this option is used, the token passed to `std::random_device`'s -// constructor *must* be "/dev/urandom" -- anything else is an error. -// -// _LIBCPP_USING_GETENTROPY -// Use getentropy(). -// When this option is used, the token passed to `std::random_device`'s -// constructor *must* be "/dev/urandom" -- anything else is an error. -// -// _LIBCPP_USING_FUCHSIA_CPRNG -// Use Fuchsia's zx_cprng_draw() system call, which is specified to -// deliver high-quality entropy and cannot fail. -// When this option is used, the token passed to `std::random_device`'s -// constructor *must* be "/dev/urandom" -- anything else is an error. -// -// _LIBCPP_USING_NACL_RANDOM -// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, -// including accesses to the special files under `/dev`. This implementation -// uses the NaCL syscall `nacl_secure_random_init()` to get entropy. -// When this option is used, the token passed to `std::random_device`'s -// constructor *must* be "/dev/urandom" -- anything else is an error. -// -// _LIBCPP_USING_WIN32_RANDOM -// 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(__OpenBSD__) || defined(__APPLE__) +#if defined(__OpenBSD__) || defined(__CloudABI__) + // Certain architectures provide arc4random(). Prefer using + // arc4random() over /dev/{u,}random to make it possible to obtain + // random data even when using sandboxing mechanisms such as chroots, + // Capsicum, etc. # define _LIBCPP_USING_ARC4_RANDOM -#elif defined(__wasi__) +#elif defined(__Fuchsia__) || defined(__wasi__) # define _LIBCPP_USING_GETENTROPY -#elif defined(__Fuchsia__) -# define _LIBCPP_USING_FUCHSIA_CPRNG #elif defined(__native_client__) + // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, + // including accesses to the special files under /dev. C++11's + // std::random_device is instead exposed through a NaCl syscall. # define _LIBCPP_USING_NACL_RANDOM #elif defined(_LIBCPP_WIN32API) # define _LIBCPP_USING_WIN32_RANDOM @@ -555,6 +492,14 @@ typedef __char32_t char32_t; # define _LIBCPP_HAS_BLOCKS_RUNTIME #endif +#if !(__has_feature(cxx_relaxed_constexpr)) +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#endif + +#if !(__has_feature(cxx_variable_templates)) +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif + #if !(__has_feature(cxx_noexcept)) #define _LIBCPP_HAS_NO_NOEXCEPT #endif @@ -568,8 +513,26 @@ typedef __char32_t char32_t; #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif +#if __has_builtin(__builtin_launder) +#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER +#endif + +#if __has_builtin(__builtin_constant_p) +#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P +#endif + +#if !__is_identifier(__has_unique_object_representations) +#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS +#endif + #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) +// Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1 +#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \ + (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001) +#define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS +#endif + #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ #elif defined(_LIBCPP_COMPILER_GCC) @@ -583,10 +546,26 @@ typedef __char32_t char32_t; # define _LIBCPP_NO_EXCEPTIONS #endif +// Determine if GCC supports relaxed constexpr +#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#endif + +// GCC 5 supports variable templates +#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif + #if !defined(__SANITIZE_ADDRESS__) #define _LIBCPP_HAS_NO_ASAN #endif +#if _GNUC_VER >= 700 +#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER +#define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P +#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS +#endif + #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ @@ -601,6 +580,8 @@ typedef __char32_t char32_t; #error "MSVC versions prior to Visual Studio 2015 are not supported" #endif +#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) @@ -624,6 +605,7 @@ typedef __char32_t char32_t; #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #if defined(_AIX) #define __MULTILOCALE_API @@ -823,10 +805,10 @@ typedef __char32_t char32_t; // 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 _VSTD std::_LIBCPP_ABI_NAMESPACE _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { #else @@ -854,7 +836,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; -#endif +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS #ifndef __SIZEOF_INT128__ #define _LIBCPP_HAS_NO_INT128 @@ -877,10 +859,26 @@ typedef unsigned int char32_t; # define _LIBCPP_CONSTEVAL consteval #endif -#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L +#if !defined(__cpp_concepts) || __cpp_concepts < 201907L #define _LIBCPP_HAS_NO_CONCEPTS #endif +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS) +#define _LIBCPP_HAS_NO_RANGES +#endif + +#ifdef _LIBCPP_CXX03_LANG +# define _LIBCPP_DEFAULT {} +#else +# define _LIBCPP_DEFAULT = default; +#endif + +#ifdef _LIBCPP_CXX03_LANG +# define _LIBCPP_EQUAL_DELETE +#else +# define _LIBCPP_EQUAL_DELETE = delete +#endif + #ifdef __GNUC__ # define _LIBCPP_NOALIAS __attribute__((__malloc__)) #else @@ -909,35 +907,16 @@ typedef unsigned int char32_t; // _LIBCPP_DEBUG potential values: // - undefined: No assertions. This is the default. // - 0: Basic assertions -// - 1: Basic assertions + iterator validity checks + unspecified behavior randomization. -# if !defined(_LIBCPP_DEBUG) -# define _LIBCPP_DEBUG_LEVEL 0 -# elif _LIBCPP_DEBUG == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG are 0 and 1 -# endif - -# if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY -# endif - -# if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) -# if defined(_LIBCPP_CXX03_LANG) -# error Support for unspecified stability is only for C++11 and higher -# endif -# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ - do { \ - if (!__builtin_is_constant_evaluated()) \ - _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \ - } while (false) -# else -# define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ - do { \ - } while (false) -# endif +// - 1: Basic assertions + iterator validity checks. +#if !defined(_LIBCPP_DEBUG) +# define _LIBCPP_DEBUG_LEVEL 0 +#elif _LIBCPP_DEBUG == 0 +# define _LIBCPP_DEBUG_LEVEL 1 +#elif _LIBCPP_DEBUG == 1 +# define _LIBCPP_DEBUG_LEVEL 2 +#else +# error Supported values for _LIBCPP_DEBUG are 0 and 1 +#endif // Libc++ allows disabling extern template instantiation declarations by // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE. @@ -961,7 +940,7 @@ typedef unsigned int char32_t; #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ - defined(__sun__) || defined(__NetBSD__) + defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif @@ -981,6 +960,13 @@ typedef unsigned int char32_t; # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION #endif +#if defined(__APPLE__) +# if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +# define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ +# endif +#endif // defined(__APPLE__) + #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION @@ -1063,50 +1049,64 @@ typedef unsigned int char32_t; # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #endif -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX14 #endif -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr #else # define _LIBCPP_CONSTEXPR_AFTER_CXX17 #endif +// The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other +// NODISCARD macros to the correct attribute. #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) -# define _LIBCPP_NODISCARD [[nodiscard]] +# define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]] #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) -# define _LIBCPP_NODISCARD [[clang::warn_unused_result]] +# define _LIBCPP_NODISCARD_ATTRIBUTE [[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 +# define _LIBCPP_NODISCARD_ATTRIBUTE #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 +# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE #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 +# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE #else # define _LIBCPP_NODISCARD_AFTER_CXX17 #endif +#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) +# define _LIBCPP_INLINE_VAR inline +#else +# define _LIBCPP_INLINE_VAR +#endif + +#if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) +# define _LIBCPP_CONSTEXPR_IF_NODEBUG +#else +# define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr +#endif + #if __has_attribute(no_destroy) # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) #else @@ -1144,9 +1144,11 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( defined(__linux__) || \ defined(__GNU__) || \ defined(__APPLE__) || \ + defined(__CloudABI__) || \ defined(__sun__) || \ defined(__MVS__) || \ - defined(_AIX) + defined(_AIX) || \ + (defined(__MINGW32__) && __has_include()) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) // TODO(44575): Switch to C11 thread API when possible. @@ -1216,6 +1218,21 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION #endif +// Systems that use capability-based security (FreeBSD with Capsicum, +// Nuxi CloudABI) may only provide local filesystem access (using *at()). +// Functions like open(), rename(), unlink() and stat() should not be +// used, as they attempt to access the global filesystem namespace. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE +#endif + +// CloudABI is intended for running networked services. Processes do not +// have standard input and output channels. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_STDIN +#define _LIBCPP_HAS_NO_STDOUT +#endif + // Some systems do not provide gets() in their C library, for security reasons. #if defined(_LIBCPP_MSVCRT) || \ (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ @@ -1223,21 +1240,28 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # define _LIBCPP_C_HAS_NO_GETS #endif -#if defined(__BIONIC__) || defined(__NuttX__) || \ - defined(__Fuchsia__) || defined(__wasi__) || \ - defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) +#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \ + defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \ + defined(__MVS__) || defined(__OpenBSD__) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif +// Thread-unsafe functions such as strtok() and localtime() +// are not available. +#ifdef __CloudABI__ +#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS +#endif + #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) # define _LIBCPP_HAS_C_ATOMIC_IMP #elif defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_HAS_GCC_ATOMIC_IMP #endif -#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ - !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ - !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) +#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ + !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ + !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \ + || defined(_LIBCPP_HAS_NO_THREADS) # define _LIBCPP_HAS_NO_ATOMIC_HEADER #else # ifndef _LIBCPP_ATOMIC_FLAG_TYPE @@ -1256,9 +1280,8 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # 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) +// of the types. +# if !defined(_LIBCPP_OBJECT_FORMAT_COFF) # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS # endif # endif @@ -1276,6 +1299,14 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # define _LIBCPP_SAFE_STATIC #endif +#if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 +#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF +#endif + +#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900 +#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED +#endif + #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) # define _LIBCPP_DIAGNOSE_WARNING(...) \ __attribute__((diagnose_if(__VA_ARGS__, "warning"))) @@ -1291,7 +1322,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # define _LIBCPP_FALLTHROUGH() [[fallthrough]] #elif __has_cpp_attribute(clang::fallthrough) # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] -#elif __has_attribute(__fallthrough__) +#elif __has_attribute(fallthrough) || _GNUC_VER >= 700 # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) #else # define _LIBCPP_FALLTHROUGH() ((void)0) @@ -1303,6 +1334,12 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #define _LIBCPP_NODEBUG #endif +#if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900) +# define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) +#else +# define _LIBCPP_NODEBUG_TYPE +#endif + #if __has_attribute(__standalone_debug__) #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) #else @@ -1315,16 +1352,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #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) @@ -1347,8 +1374,20 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #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 +#if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 +#define _LIBCPP_HAS_NO_DEDUCTION_GUIDES +#endif + +#if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) +#define _LIBCPP_HAS_NO_IS_AGGREGATE +#endif + +#if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L +#define _LIBCPP_HAS_NO_COROUTINES +#endif + +#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L +#define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR #endif #if defined(_LIBCPP_COMPILER_IBM) @@ -1402,6 +1441,12 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # define _LIBCPP_FOPEN_CLOEXEC_MODE #endif +#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P +#define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) +#else +#define _LIBCPP_BUILTIN_CONSTANT_P(x) false +#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. @@ -1410,24 +1455,16 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( #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 +# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) #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))) +#define _LIBCPP_FORMAT_PRINTF(a, b) \ + __attribute__((__format__(__printf__, a, b))) #else -# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ +#define _LIBCPP_FORMAT_PRINTF(a, b) #endif #endif // __cplusplus diff --git a/include/__config_site.in b/include/__config_site.in index 59ca22981..e202d923f 100644 --- a/include/__config_site.in +++ b/include/__config_site.in @@ -14,8 +14,12 @@ #cmakedefine _LIBCPP_ABI_FORCE_ITANIUM #cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT #cmakedefine _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT +#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE +#cmakedefine _LIBCPP_HAS_NO_STDIN +#cmakedefine _LIBCPP_HAS_NO_STDOUT #cmakedefine _LIBCPP_HAS_NO_THREADS #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK +#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #cmakedefine _LIBCPP_HAS_MUSL_LIBC #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL @@ -30,11 +34,9 @@ #cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS #cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE #cmakedefine _LIBCPP_HAS_NO_LOCALIZATION -#cmakedefine _LIBCPP_HAS_NO_WIDE_CHARACTERS #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FORMAT #cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_RANGES @_LIBCPP_ABI_DEFINES@ -@_LIBCPP_EXTRA_SITE_DEFINES@ #endif // _LIBCPP_CONFIG_SITE diff --git a/include/__coroutine/coroutine_handle.h b/include/__coroutine/coroutine_handle.h deleted file mode 100644 index 64657c058..000000000 --- a/include/__coroutine/coroutine_handle.h +++ /dev/null @@ -1,202 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H -#define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H - -#include <__config> -#include <__debug> -#include <__functional/hash.h> -#include <__memory/addressof.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -// [coroutine.handle] -template -struct _LIBCPP_TEMPLATE_VIS coroutine_handle; - -template <> -struct _LIBCPP_TEMPLATE_VIS coroutine_handle { -public: - // [coroutine.handle.con], construct/reset - _LIBCPP_HIDE_FROM_ABI - constexpr coroutine_handle() noexcept = default; - - _LIBCPP_HIDE_FROM_ABI - constexpr coroutine_handle(nullptr_t) noexcept {} - - _LIBCPP_HIDE_FROM_ABI - coroutine_handle& operator=(nullptr_t) noexcept { - __handle_ = nullptr; - return *this; - } - - // [coroutine.handle.export.import], export/import - _LIBCPP_HIDE_FROM_ABI - constexpr void* address() const noexcept { return __handle_; } - - _LIBCPP_HIDE_FROM_ABI - static constexpr coroutine_handle from_address(void* __addr) noexcept { - coroutine_handle __tmp; - __tmp.__handle_ = __addr; - return __tmp; - } - - // [coroutine.handle.observers], observers - _LIBCPP_HIDE_FROM_ABI - constexpr explicit operator bool() const noexcept { - return __handle_ != nullptr; - } - - _LIBCPP_HIDE_FROM_ABI - bool done() const { - _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines"); - return __builtin_coro_done(__handle_); - } - - // [coroutine.handle.resumption], resumption - _LIBCPP_HIDE_FROM_ABI - void operator()() const { resume(); } - - _LIBCPP_HIDE_FROM_ABI - void resume() const { - _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines"); - _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done"); - __builtin_coro_resume(__handle_); - } - - _LIBCPP_HIDE_FROM_ABI - void destroy() const { - _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines"); - __builtin_coro_destroy(__handle_); - } - -private: - bool __is_suspended() const { - // FIXME actually implement a check for if the coro is suspended. - return __handle_ != nullptr; - } - - void* __handle_ = nullptr; -}; - -// [coroutine.handle.compare] -inline _LIBCPP_HIDE_FROM_ABI -constexpr bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { - return __x.address() == __y.address(); -} -inline _LIBCPP_HIDE_FROM_ABI -constexpr strong_ordering operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { - return compare_three_way()(__x.address(), __y.address()); -} - -template -struct _LIBCPP_TEMPLATE_VIS coroutine_handle { -public: - // [coroutine.handle.con], construct/reset - _LIBCPP_HIDE_FROM_ABI - constexpr coroutine_handle() noexcept = default; - - _LIBCPP_HIDE_FROM_ABI - constexpr coroutine_handle(nullptr_t) noexcept {} - - _LIBCPP_HIDE_FROM_ABI - static coroutine_handle from_promise(_Promise& __promise) { - using _RawPromise = typename remove_cv<_Promise>::type; - coroutine_handle __tmp; - __tmp.__handle_ = - __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true); - return __tmp; - } - - _LIBCPP_HIDE_FROM_ABI - coroutine_handle& operator=(nullptr_t) noexcept { - __handle_ = nullptr; - return *this; - } - - // [coroutine.handle.export.import], export/import - _LIBCPP_HIDE_FROM_ABI - constexpr void* address() const noexcept { return __handle_; } - - _LIBCPP_HIDE_FROM_ABI - static constexpr coroutine_handle from_address(void* __addr) noexcept { - coroutine_handle __tmp; - __tmp.__handle_ = __addr; - return __tmp; - } - - // [coroutine.handle.conv], conversion - _LIBCPP_HIDE_FROM_ABI - constexpr operator coroutine_handle<>() const noexcept { - return coroutine_handle<>::from_address(address()); - } - - // [coroutine.handle.observers], observers - _LIBCPP_HIDE_FROM_ABI - constexpr explicit operator bool() const noexcept { - return __handle_ != nullptr; - } - - _LIBCPP_HIDE_FROM_ABI - bool done() const { - _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines"); - return __builtin_coro_done(__handle_); - } - - // [coroutine.handle.resumption], resumption - _LIBCPP_HIDE_FROM_ABI - void operator()() const { resume(); } - - _LIBCPP_HIDE_FROM_ABI - void resume() const { - _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines"); - _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done"); - __builtin_coro_resume(__handle_); - } - - _LIBCPP_HIDE_FROM_ABI - void destroy() const { - _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines"); - __builtin_coro_destroy(__handle_); - } - - // [coroutine.handle.promise], promise access - _LIBCPP_HIDE_FROM_ABI - _Promise& promise() const { - return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false)); - } - -private: - bool __is_suspended() const { - // FIXME actually implement a check for if the coro is suspended. - return __handle_ != nullptr; - } - void* __handle_ = nullptr; -}; - -// [coroutine.handle.hash] -template -struct hash> { - _LIBCPP_HIDE_FROM_ABI - size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { return hash()(__v.address()); } -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H diff --git a/include/__coroutine/coroutine_traits.h b/include/__coroutine/coroutine_traits.h deleted file mode 100644 index bfa69552b..000000000 --- a/include/__coroutine/coroutine_traits.h +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COROUTINE_COROUTINE_TRAITS_H -#define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H - -#include <__config> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -// [coroutine.traits] -// [coroutine.traits.primary] -// The header defined the primary template coroutine_traits such that -// if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type -// is valid and denotes a type ([temp.deduct]), then coroutine_traits -// has the following publicly accessible memebr: -// -// using promise_type = typename R::promise_type; -// -// Otherwise, coroutine_traits has no members. -template -struct __coroutine_traits_sfinae {}; - -template -struct __coroutine_traits_sfinae< - _Tp, typename __void_t::type> -{ - using promise_type = typename _Tp::promise_type; -}; - -template -struct coroutine_traits - : public __coroutine_traits_sfinae<_Ret> -{ -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H diff --git a/include/__coroutine/noop_coroutine_handle.h b/include/__coroutine/noop_coroutine_handle.h deleted file mode 100644 index a29e202f4..000000000 --- a/include/__coroutine/noop_coroutine_handle.h +++ /dev/null @@ -1,112 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H -#define _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H - -#include <__config> -#include <__coroutine/coroutine_handle.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) - -// [coroutine.noop] -// [coroutine.promise.noop] -struct noop_coroutine_promise {}; - -// [coroutine.handle.noop] -template <> -struct _LIBCPP_TEMPLATE_VIS coroutine_handle { -public: - // [coroutine.handle.noop.conv], conversion - _LIBCPP_HIDE_FROM_ABI - constexpr operator coroutine_handle<>() const noexcept { - return coroutine_handle<>::from_address(address()); - } - - // [coroutine.handle.noop.observers], observers - _LIBCPP_HIDE_FROM_ABI - constexpr explicit operator bool() const noexcept { return true; } - _LIBCPP_HIDE_FROM_ABI - constexpr bool done() const noexcept { return false; } - - // [coroutine.handle.noop.resumption], resumption - _LIBCPP_HIDE_FROM_ABI - constexpr void operator()() const noexcept {} - _LIBCPP_HIDE_FROM_ABI - constexpr void resume() const noexcept {} - _LIBCPP_HIDE_FROM_ABI - constexpr void destroy() const noexcept {} - - // [coroutine.handle.noop.promise], promise access - _LIBCPP_HIDE_FROM_ABI - noop_coroutine_promise& promise() const noexcept { - return *static_cast( - __builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false)); - } - - // [coroutine.handle.noop.address], address - _LIBCPP_HIDE_FROM_ABI - constexpr void* address() const noexcept { return __handle_; } - -private: - _LIBCPP_HIDE_FROM_ABI - friend coroutine_handle noop_coroutine() noexcept; - -#if __has_builtin(__builtin_coro_noop) - _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { - this->__handle_ = __builtin_coro_noop(); - } - - void* __handle_ = nullptr; - -#elif defined(_LIBCPP_COMPILER_GCC) - // GCC doesn't implement __builtin_coro_noop(). - // Construct the coroutine frame manually instead. - struct __noop_coroutine_frame_ty_ { - static void __dummy_resume_destroy_func() { } - - void (*__resume_)() = __dummy_resume_destroy_func; - void (*__destroy_)() = __dummy_resume_destroy_func; - struct noop_coroutine_promise __promise_; - }; - - static __noop_coroutine_frame_ty_ __noop_coroutine_frame_; - - void* __handle_ = &__noop_coroutine_frame_; - - _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default; - -#endif // __has_builtin(__builtin_coro_noop) -}; - -using noop_coroutine_handle = coroutine_handle; - -#if defined(_LIBCPP_COMPILER_GCC) -inline noop_coroutine_handle::__noop_coroutine_frame_ty_ - noop_coroutine_handle::__noop_coroutine_frame_{}; -#endif - -// [coroutine.noop.coroutine] -inline _LIBCPP_HIDE_FROM_ABI -noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } - -#endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) - -_LIBCPP_END_NAMESPACE_STD - -#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H diff --git a/include/__coroutine/trivial_awaitables.h b/include/__coroutine/trivial_awaitables.h deleted file mode 100644 index c434f83b7..000000000 --- a/include/__coroutine/trivial_awaitables.h +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H -#define __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H - -#include <__config> -#include <__coroutine/coroutine_handle.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -// [coroutine.trivial.awaitables] -struct suspend_never { - _LIBCPP_HIDE_FROM_ABI - constexpr bool await_ready() const noexcept { return true; } - _LIBCPP_HIDE_FROM_ABI - constexpr void await_suspend(coroutine_handle<>) const noexcept {} - _LIBCPP_HIDE_FROM_ABI - constexpr void await_resume() const noexcept {} -}; - -struct suspend_always { - _LIBCPP_HIDE_FROM_ABI - constexpr bool await_ready() const noexcept { return false; } - _LIBCPP_HIDE_FROM_ABI - constexpr void await_suspend(coroutine_handle<>) const noexcept {} - _LIBCPP_HIDE_FROM_ABI - constexpr void await_resume() const noexcept {} -}; - -_LIBCPP_END_NAMESPACE_STD - -#endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) - -#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H diff --git a/include/__debug b/include/__debug index a1e21a703..771e43163 100644 --- a/include/__debug +++ b/include/__debug @@ -1,5 +1,5 @@ // -*- C++ -*- -//===----------------------------------------------------------------------===// +//===--------------------------- __debug ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -12,7 +12,6 @@ #include <__config> #include -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -23,9 +22,9 @@ #endif #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) -# include -# include # include +# include +# include #endif #if _LIBCPP_DEBUG_LEVEL == 0 @@ -35,7 +34,7 @@ # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) #elif _LIBCPP_DEBUG_LEVEL == 2 -# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m) +# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) #else # error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2 @@ -269,26 +268,6 @@ _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); #endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) { -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__insert_c(__c); -#else - (void)(__c); -#endif -} - -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) { -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__insert_i(__i); -#else - (void)(__i); -#endif -} - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_DEBUG_H diff --git a/include/__errc b/include/__errc index 68d5fa320..81da2e197 100644 --- a/include/__errc +++ b/include/__errc @@ -1,5 +1,5 @@ // -*- C++ -*- -//===----------------------------------------------------------------------===// +//===---------------------------- __errc ----------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/include/__filesystem/copy_options.h b/include/__filesystem/copy_options.h deleted file mode 100644 index c0140d457..000000000 --- a/include/__filesystem/copy_options.h +++ /dev/null @@ -1,80 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_COPY_OPTIONS_H -#define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H - -#include <__availability> -#include <__config> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { - none = 0, - skip_existing = 1, - overwrite_existing = 2, - update_existing = 4, - recursive = 8, - copy_symlinks = 16, - skip_symlinks = 32, - directories_only = 64, - create_symlinks = 128, - create_hard_links = 256, - __in_recursive_copy = 512, -}; - -_LIBCPP_INLINE_VISIBILITY -inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) { - return static_cast(static_cast(_LHS) & - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) { - return static_cast(static_cast(_LHS) | - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) { - return static_cast(static_cast(_LHS) ^ - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr copy_options operator~(copy_options _LHS) { - return static_cast(~static_cast(_LHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) { - return _LHS = _LHS & _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) { - return _LHS = _LHS | _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { - return _LHS = _LHS ^ _RHS; -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_COPY_OPTIONS_H diff --git a/include/__filesystem/directory_entry.h b/include/__filesystem/directory_entry.h deleted file mode 100644 index 95e45c023..000000000 --- a/include/__filesystem/directory_entry.h +++ /dev/null @@ -1,511 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H -#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H - -#include <__availability> -#include <__config> -#include <__errc> -#include <__filesystem/file_status.h> -#include <__filesystem/file_time_type.h> -#include <__filesystem/file_type.h> -#include <__filesystem/filesystem_error.h> -#include <__filesystem/operations.h> -#include <__filesystem/path.h> -#include <__filesystem/perms.h> -#include -#include -#include -#include -#include - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - - -class directory_entry { - typedef _VSTD_FS::path _Path; - -public: - // constructors and destructors - directory_entry() noexcept = default; - directory_entry(directory_entry const&) = default; - directory_entry(directory_entry&&) noexcept = default; - - _LIBCPP_INLINE_VISIBILITY - explicit directory_entry(_Path const& __p) : __p_(__p) { - error_code __ec; - __refresh(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) { - __refresh(&__ec); - } - - ~directory_entry() {} - - directory_entry& operator=(directory_entry const&) = default; - directory_entry& operator=(directory_entry&&) noexcept = default; - - _LIBCPP_INLINE_VISIBILITY - void assign(_Path const& __p) { - __p_ = __p; - error_code __ec; - __refresh(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - void assign(_Path const& __p, error_code& __ec) { - __p_ = __p; - __refresh(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - void replace_filename(_Path const& __p) { - __p_.replace_filename(__p); - error_code __ec; - __refresh(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - void replace_filename(_Path const& __p, error_code& __ec) { - __p_ = __p_.parent_path() / __p; - __refresh(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - void refresh() { __refresh(); } - - _LIBCPP_INLINE_VISIBILITY - void refresh(error_code& __ec) noexcept { __refresh(&__ec); } - - _LIBCPP_INLINE_VISIBILITY - _Path const& path() const noexcept { return __p_; } - - _LIBCPP_INLINE_VISIBILITY - operator const _Path&() const noexcept { return __p_; } - - _LIBCPP_INLINE_VISIBILITY - bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); } - - _LIBCPP_INLINE_VISIBILITY - bool exists(error_code& __ec) const noexcept { - return _VSTD_FS::exists(file_status{__get_ft(&__ec)}); - } - - _LIBCPP_INLINE_VISIBILITY - bool is_block_file() const { return __get_ft() == file_type::block; } - - _LIBCPP_INLINE_VISIBILITY - bool is_block_file(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::block; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_character_file() const { return __get_ft() == file_type::character; } - - _LIBCPP_INLINE_VISIBILITY - bool is_character_file(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::character; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_directory() const { return __get_ft() == file_type::directory; } - - _LIBCPP_INLINE_VISIBILITY - bool is_directory(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::directory; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_fifo() const { return __get_ft() == file_type::fifo; } - - _LIBCPP_INLINE_VISIBILITY - bool is_fifo(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::fifo; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); } - - _LIBCPP_INLINE_VISIBILITY - bool is_other(error_code& __ec) const noexcept { - return _VSTD_FS::is_other(file_status{__get_ft(&__ec)}); - } - - _LIBCPP_INLINE_VISIBILITY - bool is_regular_file() const { return __get_ft() == file_type::regular; } - - _LIBCPP_INLINE_VISIBILITY - bool is_regular_file(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::regular; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_socket() const { return __get_ft() == file_type::socket; } - - _LIBCPP_INLINE_VISIBILITY - bool is_socket(error_code& __ec) const noexcept { - return __get_ft(&__ec) == file_type::socket; - } - - _LIBCPP_INLINE_VISIBILITY - bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } - - _LIBCPP_INLINE_VISIBILITY - bool is_symlink(error_code& __ec) const noexcept { - return __get_sym_ft(&__ec) == file_type::symlink; - } - _LIBCPP_INLINE_VISIBILITY - uintmax_t file_size() const { return __get_size(); } - - _LIBCPP_INLINE_VISIBILITY - uintmax_t file_size(error_code& __ec) const noexcept { - return __get_size(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - uintmax_t hard_link_count() const { return __get_nlink(); } - - _LIBCPP_INLINE_VISIBILITY - uintmax_t hard_link_count(error_code& __ec) const noexcept { - return __get_nlink(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - file_time_type last_write_time() const { return __get_write_time(); } - - _LIBCPP_INLINE_VISIBILITY - file_time_type last_write_time(error_code& __ec) const noexcept { - return __get_write_time(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - file_status status() const { return __get_status(); } - - _LIBCPP_INLINE_VISIBILITY - file_status status(error_code& __ec) const noexcept { - return __get_status(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - file_status symlink_status() const { return __get_symlink_status(); } - - _LIBCPP_INLINE_VISIBILITY - file_status symlink_status(error_code& __ec) const noexcept { - return __get_symlink_status(&__ec); - } - - _LIBCPP_INLINE_VISIBILITY - bool operator<(directory_entry const& __rhs) const noexcept { - return __p_ < __rhs.__p_; - } - - _LIBCPP_INLINE_VISIBILITY - bool operator==(directory_entry const& __rhs) const noexcept { - return __p_ == __rhs.__p_; - } - - _LIBCPP_INLINE_VISIBILITY - bool operator!=(directory_entry const& __rhs) const noexcept { - return __p_ != __rhs.__p_; - } - - _LIBCPP_INLINE_VISIBILITY - bool operator<=(directory_entry const& __rhs) const noexcept { - return __p_ <= __rhs.__p_; - } - - _LIBCPP_INLINE_VISIBILITY - bool operator>(directory_entry const& __rhs) const noexcept { - return __p_ > __rhs.__p_; - } - - _LIBCPP_INLINE_VISIBILITY - bool operator>=(directory_entry const& __rhs) const noexcept { - return __p_ >= __rhs.__p_; - } - - template - _LIBCPP_INLINE_VISIBILITY - friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) { - return __os << __d.path(); - } - -private: - friend class directory_iterator; - friend class recursive_directory_iterator; - friend class _LIBCPP_HIDDEN __dir_stream; - - enum _CacheType : unsigned char { - _Empty, - _IterSymlink, - _IterNonSymlink, - _RefreshSymlink, - _RefreshSymlinkUnresolved, - _RefreshNonSymlink - }; - - struct __cached_data { - uintmax_t __size_; - uintmax_t __nlink_; - file_time_type __write_time_; - perms __sym_perms_; - perms __non_sym_perms_; - file_type __type_; - _CacheType __cache_type_; - - _LIBCPP_INLINE_VISIBILITY - __cached_data() noexcept { __reset(); } - - _LIBCPP_INLINE_VISIBILITY - void __reset() { - __cache_type_ = _Empty; - __type_ = file_type::none; - __sym_perms_ = __non_sym_perms_ = perms::unknown; - __size_ = __nlink_ = uintmax_t(-1); - __write_time_ = file_time_type::min(); - } - }; - - _LIBCPP_INLINE_VISIBILITY - static __cached_data __create_iter_result(file_type __ft) { - __cached_data __data; - __data.__type_ = __ft; - __data.__cache_type_ = [&]() { - switch (__ft) { - case file_type::none: - return _Empty; - case file_type::symlink: - return _IterSymlink; - default: - return _IterNonSymlink; - } - }(); - return __data; - } - - _LIBCPP_INLINE_VISIBILITY - void __assign_iter_entry(_Path&& __p, __cached_data __dt) { - __p_ = _VSTD::move(__p); - __data_ = __dt; - } - - _LIBCPP_FUNC_VIS - error_code __do_refresh() noexcept; - - _LIBCPP_INLINE_VISIBILITY - static bool __is_dne_error(error_code const& __ec) { - if (!__ec) - return true; - switch (static_cast(__ec.value())) { - case errc::no_such_file_or_directory: - case errc::not_a_directory: - return true; - default: - return false; - } - } - - _LIBCPP_INLINE_VISIBILITY - void __handle_error(const char* __msg, error_code* __dest_ec, - error_code const& __ec, bool __allow_dne = false) const { - if (__dest_ec) { - *__dest_ec = __ec; - return; - } - if (__ec && (!__allow_dne || !__is_dne_error(__ec))) - __throw_filesystem_error(__msg, __p_, __ec); - } - - _LIBCPP_INLINE_VISIBILITY - void __refresh(error_code* __ec = nullptr) { - __handle_error("in directory_entry::refresh", __ec, __do_refresh(), - /*allow_dne*/ true); - } - - _LIBCPP_INLINE_VISIBILITY - file_type __get_sym_ft(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - return __symlink_status(__p_, __ec).type(); - case _IterSymlink: - case _RefreshSymlink: - case _RefreshSymlinkUnresolved: - if (__ec) - __ec->clear(); - return file_type::symlink; - case _IterNonSymlink: - case _RefreshNonSymlink: - file_status __st(__data_.__type_); - if (__ec && !_VSTD_FS::exists(__st)) - *__ec = make_error_code(errc::no_such_file_or_directory); - else if (__ec) - __ec->clear(); - return __data_.__type_; - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - file_type __get_ft(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterSymlink: - case _RefreshSymlinkUnresolved: - return __status(__p_, __ec).type(); - case _IterNonSymlink: - case _RefreshNonSymlink: - case _RefreshSymlink: { - file_status __st(__data_.__type_); - if (__ec && !_VSTD_FS::exists(__st)) - *__ec = make_error_code(errc::no_such_file_or_directory); - else if (__ec) - __ec->clear(); - return __data_.__type_; - } - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - file_status __get_status(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterNonSymlink: - case _IterSymlink: - case _RefreshSymlinkUnresolved: - return __status(__p_, __ec); - case _RefreshNonSymlink: - case _RefreshSymlink: - return file_status(__get_ft(__ec), __data_.__non_sym_perms_); - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - file_status __get_symlink_status(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterNonSymlink: - case _IterSymlink: - return __symlink_status(__p_, __ec); - case _RefreshNonSymlink: - return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); - case _RefreshSymlink: - case _RefreshSymlinkUnresolved: - return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - uintmax_t __get_size(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterNonSymlink: - case _IterSymlink: - case _RefreshSymlinkUnresolved: - return _VSTD_FS::__file_size(__p_, __ec); - case _RefreshSymlink: - case _RefreshNonSymlink: { - error_code __m_ec; - file_status __st(__get_ft(&__m_ec)); - __handle_error("in directory_entry::file_size", __ec, __m_ec); - if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) { - errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory - : errc::not_supported; - __handle_error("in directory_entry::file_size", __ec, - make_error_code(__err_kind)); - } - return __data_.__size_; - } - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - uintmax_t __get_nlink(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterNonSymlink: - case _IterSymlink: - case _RefreshSymlinkUnresolved: - return _VSTD_FS::__hard_link_count(__p_, __ec); - case _RefreshSymlink: - case _RefreshNonSymlink: { - error_code __m_ec; - (void)__get_ft(&__m_ec); - __handle_error("in directory_entry::hard_link_count", __ec, __m_ec); - return __data_.__nlink_; - } - } - _LIBCPP_UNREACHABLE(); - } - - _LIBCPP_INLINE_VISIBILITY - file_time_type __get_write_time(error_code* __ec = nullptr) const { - switch (__data_.__cache_type_) { - case _Empty: - case _IterNonSymlink: - case _IterSymlink: - case _RefreshSymlinkUnresolved: - return _VSTD_FS::__last_write_time(__p_, __ec); - case _RefreshSymlink: - case _RefreshNonSymlink: { - error_code __m_ec; - file_status __st(__get_ft(&__m_ec)); - __handle_error("in directory_entry::last_write_time", __ec, __m_ec); - if (_VSTD_FS::exists(__st) && - __data_.__write_time_ == file_time_type::min()) - __handle_error("in directory_entry::last_write_time", __ec, - make_error_code(errc::value_too_large)); - return __data_.__write_time_; - } - } - _LIBCPP_UNREACHABLE(); - } - -private: - _Path __p_; - __cached_data __data_; -}; - -class __dir_element_proxy { -public: - inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() { - return _VSTD::move(__elem_); - } - -private: - friend class directory_iterator; - friend class recursive_directory_iterator; - explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {} - __dir_element_proxy(__dir_element_proxy&& __o) - : __elem_(_VSTD::move(__o.__elem_)) {} - directory_entry __elem_; -}; - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H diff --git a/include/__filesystem/directory_iterator.h b/include/__filesystem/directory_iterator.h deleted file mode 100644 index cfaf2064b..000000000 --- a/include/__filesystem/directory_iterator.h +++ /dev/null @@ -1,150 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H -#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H - -#include <__availability> -#include <__config> -#include <__debug> -#include <__filesystem/directory_entry.h> -#include <__filesystem/directory_options.h> -#include <__filesystem/path.h> -#include <__iterator/iterator_traits.h> -#include <__memory/shared_ptr.h> -#include <__ranges/enable_borrowed_range.h> -#include <__ranges/enable_view.h> -#include -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -class _LIBCPP_HIDDEN __dir_stream; -class directory_iterator { -public: - typedef directory_entry value_type; - typedef ptrdiff_t difference_type; - typedef value_type const* pointer; - typedef value_type const& reference; - typedef input_iterator_tag iterator_category; - -public: - //ctor & dtor - directory_iterator() noexcept {} - - explicit directory_iterator(const path& __p) - : directory_iterator(__p, nullptr) {} - - directory_iterator(const path& __p, directory_options __opts) - : directory_iterator(__p, nullptr, __opts) {} - - directory_iterator(const path& __p, error_code& __ec) - : directory_iterator(__p, &__ec) {} - - directory_iterator(const path& __p, directory_options __opts, - error_code& __ec) - : directory_iterator(__p, &__ec, __opts) {} - - directory_iterator(const directory_iterator&) = default; - directory_iterator(directory_iterator&&) = default; - directory_iterator& operator=(const directory_iterator&) = default; - - directory_iterator& operator=(directory_iterator&& __o) noexcept { - // non-default implementation provided to support self-move assign. - if (this != &__o) { - __imp_ = _VSTD::move(__o.__imp_); - } - return *this; - } - - ~directory_iterator() = default; - - const directory_entry& operator*() const { - _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); - return __dereference(); - } - - const directory_entry* operator->() const { return &**this; } - - directory_iterator& operator++() { return __increment(); } - - __dir_element_proxy operator++(int) { - __dir_element_proxy __p(**this); - __increment(); - return __p; - } - - directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } - -private: - inline _LIBCPP_INLINE_VISIBILITY friend bool - operator==(const directory_iterator& __lhs, - const directory_iterator& __rhs) noexcept; - - // construct the dir_stream - _LIBCPP_FUNC_VIS - directory_iterator(const path&, error_code*, - directory_options = directory_options::none); - - _LIBCPP_FUNC_VIS - directory_iterator& __increment(error_code* __ec = nullptr); - - _LIBCPP_FUNC_VIS - const directory_entry& __dereference() const; - -private: - shared_ptr<__dir_stream> __imp_; -}; - -inline _LIBCPP_INLINE_VISIBILITY bool -operator==(const directory_iterator& __lhs, - const directory_iterator& __rhs) noexcept { - return __lhs.__imp_ == __rhs.__imp_; -} - -inline _LIBCPP_INLINE_VISIBILITY bool -operator!=(const directory_iterator& __lhs, - const directory_iterator& __rhs) noexcept { - return !(__lhs == __rhs); -} - -// enable directory_iterator range-based for statements -inline _LIBCPP_INLINE_VISIBILITY directory_iterator -begin(directory_iterator __iter) noexcept { - return __iter; -} - -inline _LIBCPP_INLINE_VISIBILITY directory_iterator -end(directory_iterator) noexcept { - return directory_iterator(); -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template <> -_LIBCPP_AVAILABILITY_FILESYSTEM -inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::directory_iterator> = true; - -template <> -_LIBCPP_AVAILABILITY_FILESYSTEM -inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H diff --git a/include/__filesystem/directory_options.h b/include/__filesystem/directory_options.h deleted file mode 100644 index 79c0c2cba..000000000 --- a/include/__filesystem/directory_options.h +++ /dev/null @@ -1,78 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H -#define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H - -#include <__availability> -#include <__config> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { - none = 0, - follow_directory_symlink = 1, - skip_permission_denied = 2 -}; - -_LIBCPP_INLINE_VISIBILITY -inline constexpr directory_options operator&(directory_options _LHS, - directory_options _RHS) { - return static_cast(static_cast(_LHS) & - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr directory_options operator|(directory_options _LHS, - directory_options _RHS) { - return static_cast(static_cast(_LHS) | - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr directory_options operator^(directory_options _LHS, - directory_options _RHS) { - return static_cast(static_cast(_LHS) ^ - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr directory_options operator~(directory_options _LHS) { - return static_cast(~static_cast(_LHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline directory_options& operator&=(directory_options& _LHS, - directory_options _RHS) { - return _LHS = _LHS & _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline directory_options& operator|=(directory_options& _LHS, - directory_options _RHS) { - return _LHS = _LHS | _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline directory_options& operator^=(directory_options& _LHS, - directory_options _RHS) { - return _LHS = _LHS ^ _RHS; -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H diff --git a/include/__filesystem/file_status.h b/include/__filesystem/file_status.h deleted file mode 100644 index a8f653ab4..000000000 --- a/include/__filesystem/file_status.h +++ /dev/null @@ -1,68 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H -#define _LIBCPP___FILESYSTEM_FILE_STATUS_H - -#include <__availability> -#include <__config> -#include <__filesystem/file_type.h> -#include <__filesystem/perms.h> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -class _LIBCPP_TYPE_VIS file_status { -public: - // constructors - _LIBCPP_INLINE_VISIBILITY - file_status() noexcept : file_status(file_type::none) {} - _LIBCPP_INLINE_VISIBILITY - explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept - : __ft_(__ft), - __prms_(__prms) {} - - file_status(const file_status&) noexcept = default; - file_status(file_status&&) noexcept = default; - - _LIBCPP_INLINE_VISIBILITY - ~file_status() {} - - file_status& operator=(const file_status&) noexcept = default; - file_status& operator=(file_status&&) noexcept = default; - - // observers - _LIBCPP_INLINE_VISIBILITY - file_type type() const noexcept { return __ft_; } - - _LIBCPP_INLINE_VISIBILITY - perms permissions() const noexcept { return __prms_; } - - // modifiers - _LIBCPP_INLINE_VISIBILITY - void type(file_type __ft) noexcept { __ft_ = __ft; } - - _LIBCPP_INLINE_VISIBILITY - void permissions(perms __p) noexcept { __prms_ = __p; } - -private: - file_type __ft_; - perms __prms_; -}; - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H diff --git a/include/__filesystem/file_time_type.h b/include/__filesystem/file_time_type.h deleted file mode 100644 index 590146a06..000000000 --- a/include/__filesystem/file_time_type.h +++ /dev/null @@ -1,27 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H -#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H - -#include <__availability> -#include <__config> -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -typedef chrono::time_point<_FilesystemClock> file_time_type; - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H diff --git a/include/__filesystem/file_type.h b/include/__filesystem/file_type.h deleted file mode 100644 index 93bee86ad..000000000 --- a/include/__filesystem/file_type.h +++ /dev/null @@ -1,39 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_FILE_TYPE_H -#define _LIBCPP___FILESYSTEM_FILE_TYPE_H - -#include <__availability> -#include <__config> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -// On Windows, the library never identifies files as block, character, fifo -// or socket. -enum class _LIBCPP_ENUM_VIS file_type : signed char { - none = 0, - not_found = -1, - regular = 1, - directory = 2, - symlink = 3, - block = 4, - character = 5, - fifo = 6, - socket = 7, - unknown = 8 -}; - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_FILE_TYPE_H diff --git a/include/__filesystem/filesystem_error.h b/include/__filesystem/filesystem_error.h deleted file mode 100644 index 0b1874b0e..000000000 --- a/include/__filesystem/filesystem_error.h +++ /dev/null @@ -1,99 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H -#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H - -#include <__availability> -#include <__config> -#include <__filesystem/path.h> -#include <__memory/shared_ptr.h> -#include -#include -#include -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { -public: - _LIBCPP_INLINE_VISIBILITY - filesystem_error(const string& __what, error_code __ec) - : system_error(__ec, __what), - __storage_(make_shared<_Storage>(path(), path())) { - __create_what(0); - } - - _LIBCPP_INLINE_VISIBILITY - filesystem_error(const string& __what, const path& __p1, error_code __ec) - : system_error(__ec, __what), - __storage_(make_shared<_Storage>(__p1, path())) { - __create_what(1); - } - - _LIBCPP_INLINE_VISIBILITY - filesystem_error(const string& __what, const path& __p1, const path& __p2, - error_code __ec) - : system_error(__ec, __what), - __storage_(make_shared<_Storage>(__p1, __p2)) { - __create_what(2); - } - - _LIBCPP_INLINE_VISIBILITY - const path& path1() const noexcept { return __storage_->__p1_; } - - _LIBCPP_INLINE_VISIBILITY - const path& path2() const noexcept { return __storage_->__p2_; } - - filesystem_error(const filesystem_error&) = default; - ~filesystem_error() override; // key function - - _LIBCPP_INLINE_VISIBILITY - const char* what() const noexcept override { - return __storage_->__what_.c_str(); - } - - void __create_what(int __num_paths); - -private: - struct _LIBCPP_HIDDEN _Storage { - _LIBCPP_INLINE_VISIBILITY - _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {} - - path __p1_; - path __p2_; - string __what_; - }; - shared_ptr<_Storage> __storage_; -}; - -// TODO(ldionne): We need to pop the pragma and push it again after -// filesystem_error to work around PR41078. -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -template -_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_NO_EXCEPTIONS -void __throw_filesystem_error(_Args&&... __args) { - throw filesystem_error(_VSTD::forward<_Args>(__args)...); -} -#else -void __throw_filesystem_error(_Args&&...) { - _VSTD::abort(); -} -#endif -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H diff --git a/include/__filesystem/operations.h b/include/__filesystem/operations.h deleted file mode 100644 index 918b4f936..000000000 --- a/include/__filesystem/operations.h +++ /dev/null @@ -1,197 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H -#define _LIBCPP___FILESYSTEM_OPERATIONS_H - -#include <__availability> -#include <__config> -#include <__filesystem/copy_options.h> -#include <__filesystem/file_status.h> -#include <__filesystem/file_time_type.h> -#include <__filesystem/file_type.h> -#include <__filesystem/path.h> -#include <__filesystem/perm_options.h> -#include <__filesystem/perms.h> -#include <__filesystem/space_info.h> -#include -#include -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -_LIBCPP_FUNC_VIS path __absolute(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS void __current_path(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS bool __equivalent(const path&, const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr); -_LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS void __rename(const path& from, const path& to, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr); -_LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr); - -inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { return __absolute(__p); } -inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { return __canonical(__p); } -inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); } -inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); } -inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); } -inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); } -inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); } -inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { return __create_directories(__p); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); } -inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { return __create_directory(__p); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); } -inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); } -inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); } -inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY path current_path() { return __current_path(); } -inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { return __current_path(&__ec); } -inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { __current_path(__p); } -inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); } -inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; } -inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; } -inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { return exists(__status(__p)); } - -inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept { - auto __s = __status(__p, &__ec); - if (status_known(__s)) - __ec.clear(); - return exists(__s); -} - -inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { return __file_size(__p); } -inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } -inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; } -inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; } -inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { return is_character_file(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; } -inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { return is_directory(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); } -_LIBCPP_FUNC_VIS bool __fs_is_empty(const path& p, error_code* ec = nullptr); -inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { return __fs_is_empty(__p); } -inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } -inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; } -inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; } -inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); } -inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { return is_other(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; } -inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { return is_socket(__status(__p)); } -inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); } -inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p) { return __last_write_time(__p); } -inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } -inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); } -_LIBCPP_FUNC_VIS void __permissions(const path&, perms, perm_options, error_code* = nullptr); -inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); } -inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); } - -inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) { - path __tmp = __weakly_canonical(__p, &__ec); - if (__ec) - return {}; - path __tmp_base = __weakly_canonical(__base, &__ec); - if (__ec) - return {}; - return __tmp.lexically_proximate(__tmp_base); -} - -inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); } -inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); } -inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { return __read_symlink(__p); } -inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); } - -inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) { - path __tmp = __weakly_canonical(__p, &__ec); - if (__ec) - return path(); - path __tmpbase = __weakly_canonical(__base, &__ec); - if (__ec) - return path(); - return __tmp.lexically_relative(__tmpbase); -} - -inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); } -inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); } -inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { return __remove_all(__p); } -inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { return __remove(__p); } -inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to) { return __rename(__from, __to); } -inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); } -inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); } -_LIBCPP_FUNC_VIS space_info __space(const path&, error_code* __ec = nullptr); -inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { return __space(__p); } -inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { return __status(__p); } -inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { return __symlink_status(__p); } -inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); } -inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { return __temp_directory_path(); } -inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); } -inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } -inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); } - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_OPERATIONS_H diff --git a/include/__filesystem/path.h b/include/__filesystem/path.h deleted file mode 100644 index 77547cbac..000000000 --- a/include/__filesystem/path.h +++ /dev/null @@ -1,1018 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_PATH_H -#define _LIBCPP___FILESYSTEM_PATH_H - -#include <__availability> -#include <__config> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/iterator_traits.h> -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -# include // for quoted -# include -#endif - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -template -struct __can_convert_char { - static const bool value = false; -}; -template -struct __can_convert_char : public __can_convert_char<_Tp> {}; -template <> -struct __can_convert_char { - static const bool value = true; - using __char_type = char; -}; -template <> -struct __can_convert_char { - static const bool value = true; - using __char_type = wchar_t; -}; -#ifndef _LIBCPP_HAS_NO_CHAR8_T -template <> -struct __can_convert_char { - static const bool value = true; - using __char_type = char8_t; -}; -#endif -template <> -struct __can_convert_char { - static const bool value = true; - using __char_type = char16_t; -}; -template <> -struct __can_convert_char { - static const bool value = true; - using __char_type = char32_t; -}; - -template -typename enable_if<__can_convert_char<_ECharT>::value, bool>::type -__is_separator(_ECharT __e) { -#if defined(_LIBCPP_WIN32API) - return __e == _ECharT('/') || __e == _ECharT('\\'); -#else - return __e == _ECharT('/'); -#endif -} - -#ifndef _LIBCPP_HAS_NO_CHAR8_T -typedef u8string __u8_string; -#else -typedef string __u8_string; -#endif - -struct _NullSentinel {}; - -template -using _Void = void; - -template -struct __is_pathable_string : public false_type {}; - -template -struct __is_pathable_string< - basic_string<_ECharT, _Traits, _Alloc>, - _Void::__char_type> > - : public __can_convert_char<_ECharT> { - using _Str = basic_string<_ECharT, _Traits, _Alloc>; - using _Base = __can_convert_char<_ECharT>; - static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } - static _ECharT const* __range_end(_Str const& __s) { - return __s.data() + __s.length(); - } - static _ECharT __first_or_null(_Str const& __s) { - return __s.empty() ? _ECharT{} : __s[0]; - } -}; - -template -struct __is_pathable_string< - basic_string_view<_ECharT, _Traits>, - _Void::__char_type> > - : public __can_convert_char<_ECharT> { - using _Str = basic_string_view<_ECharT, _Traits>; - using _Base = __can_convert_char<_ECharT>; - static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } - static _ECharT const* __range_end(_Str const& __s) { - return __s.data() + __s.length(); - } - static _ECharT __first_or_null(_Str const& __s) { - return __s.empty() ? _ECharT{} : __s[0]; - } -}; - -template ::type, - class _UnqualPtrType = - typename remove_const::type>::type, - bool _IsCharPtr = is_pointer<_DS>::value&& - __can_convert_char<_UnqualPtrType>::value> -struct __is_pathable_char_array : false_type {}; - -template -struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> - : __can_convert_char::type> { - using _Base = __can_convert_char::type>; - - static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } - static _ECharT const* __range_end(const _ECharT* __b) { - using _Iter = const _ECharT*; - const _ECharT __sentinel = _ECharT{}; - _Iter __e = __b; - for (; *__e != __sentinel; ++__e) - ; - return __e; - } - - static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } -}; - -template ::value, - class = void> -struct __is_pathable_iter : false_type {}; - -template -struct __is_pathable_iter< - _Iter, true, - _Void::value_type>::__char_type> > - : __can_convert_char::value_type> { - using _ECharT = typename iterator_traits<_Iter>::value_type; - using _Base = __can_convert_char<_ECharT>; - - static _Iter __range_begin(_Iter __b) { return __b; } - static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; } - - static _ECharT __first_or_null(_Iter __b) { return *__b; } -}; - -template ::value, - bool _IsCharIterT = __is_pathable_char_array<_Tp>::value, - bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value> -struct __is_pathable : false_type { - static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false"); -}; - -template -struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; - -template -struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> { -}; - -template -struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; - -#if defined(_LIBCPP_WIN32API) -typedef wstring __path_string; -typedef wchar_t __path_value; -#else -typedef string __path_string; -typedef char __path_value; -#endif - -#if defined(_LIBCPP_WIN32API) -_LIBCPP_FUNC_VIS -size_t __wide_to_char(const wstring&, char*, size_t); -_LIBCPP_FUNC_VIS -size_t __char_to_wide(const string&, wchar_t*, size_t); -#endif - -template -struct _PathCVT; - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) -template -struct _PathCVT { - static_assert(__can_convert_char<_ECharT>::value, - "Char type not convertible"); - - typedef __narrow_to_utf8 _Narrower; -#if defined(_LIBCPP_WIN32API) - typedef __widen_from_utf8 _Widener; -#endif - - static void __append_range(__path_string& __dest, _ECharT const* __b, - _ECharT const* __e) { -#if defined(_LIBCPP_WIN32API) - string __utf8; - _Narrower()(back_inserter(__utf8), __b, __e); - _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); -#else - _Narrower()(back_inserter(__dest), __b, __e); -#endif - } - - template - static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { - static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); - if (__b == __e) - return; - basic_string<_ECharT> __tmp(__b, __e); -#if defined(_LIBCPP_WIN32API) - string __utf8; - _Narrower()(back_inserter(__utf8), __tmp.data(), - __tmp.data() + __tmp.length()); - _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); -#else - _Narrower()(back_inserter(__dest), __tmp.data(), - __tmp.data() + __tmp.length()); -#endif - } - - template - static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { - static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); - const _ECharT __sentinel = _ECharT{}; - if (*__b == __sentinel) - return; - basic_string<_ECharT> __tmp; - for (; *__b != __sentinel; ++__b) - __tmp.push_back(*__b); -#if defined(_LIBCPP_WIN32API) - string __utf8; - _Narrower()(back_inserter(__utf8), __tmp.data(), - __tmp.data() + __tmp.length()); - _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); -#else - _Narrower()(back_inserter(__dest), __tmp.data(), - __tmp.data() + __tmp.length()); -#endif - } - - template - static void __append_source(__path_string& __dest, _Source const& __s) { - using _Traits = __is_pathable<_Source>; - __append_range(__dest, _Traits::__range_begin(__s), - _Traits::__range_end(__s)); - } -}; -#endif // !_LIBCPP_HAS_NO_LOCALIZATION - -template <> -struct _PathCVT<__path_value> { - - template - static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type - __append_range(__path_string& __dest, _Iter __b, _Iter __e) { - for (; __b != __e; ++__b) - __dest.push_back(*__b); - } - - template - static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type - __append_range(__path_string& __dest, _Iter __b, _Iter __e) { - __dest.append(__b, __e); - } - - template - static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { - const char __sentinel = char{}; - for (; *__b != __sentinel; ++__b) - __dest.push_back(*__b); - } - - template - static void __append_source(__path_string& __dest, _Source const& __s) { - using _Traits = __is_pathable<_Source>; - __append_range(__dest, _Traits::__range_begin(__s), - _Traits::__range_end(__s)); - } -}; - -#if defined(_LIBCPP_WIN32API) -template <> -struct _PathCVT { - - static void - __append_string(__path_string& __dest, const basic_string &__str) { - size_t __size = __char_to_wide(__str, nullptr, 0); - size_t __pos = __dest.size(); - __dest.resize(__pos + __size); - __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size); - } - - template - static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type - __append_range(__path_string& __dest, _Iter __b, _Iter __e) { - basic_string __tmp(__b, __e); - __append_string(__dest, __tmp); - } - - template - static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type - __append_range(__path_string& __dest, _Iter __b, _Iter __e) { - basic_string __tmp(__b, __e); - __append_string(__dest, __tmp); - } - - template - static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { - const char __sentinel = char{}; - basic_string __tmp; - for (; *__b != __sentinel; ++__b) - __tmp.push_back(*__b); - __append_string(__dest, __tmp); - } - - template - static void __append_source(__path_string& __dest, _Source const& __s) { - using _Traits = __is_pathable<_Source>; - __append_range(__dest, _Traits::__range_begin(__s), - _Traits::__range_end(__s)); - } -}; - -template -struct _PathExport { - typedef __narrow_to_utf8 _Narrower; - typedef __widen_from_utf8 _Widener; - - template - static void __append(_Str& __dest, const __path_string& __src) { - string __utf8; - _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size()); - _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); - } -}; - -template <> -struct _PathExport { - template - static void __append(_Str& __dest, const __path_string& __src) { - size_t __size = __wide_to_char(__src, nullptr, 0); - size_t __pos = __dest.size(); - __dest.resize(__size); - __wide_to_char(__src, const_cast(__dest.data()) + __pos, __size); - } -}; - -template <> -struct _PathExport { - template - static void __append(_Str& __dest, const __path_string& __src) { - __dest.append(__src.begin(), __src.end()); - } -}; - -template <> -struct _PathExport { - template - static void __append(_Str& __dest, const __path_string& __src) { - __dest.append(__src.begin(), __src.end()); - } -}; - -#ifndef _LIBCPP_HAS_NO_CHAR8_T -template <> -struct _PathExport { - typedef __narrow_to_utf8 _Narrower; - - template - static void __append(_Str& __dest, const __path_string& __src) { - _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); - } -}; -#endif /* !_LIBCPP_HAS_NO_CHAR8_T */ -#endif /* _LIBCPP_WIN32API */ - -class _LIBCPP_TYPE_VIS path { - template - using _EnableIfPathable = - typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; - - template - using _SourceChar = typename __is_pathable<_Tp>::__char_type; - - template - using _SourceCVT = _PathCVT<_SourceChar<_Tp> >; - -public: -#if defined(_LIBCPP_WIN32API) - typedef wchar_t value_type; - static constexpr value_type preferred_separator = L'\\'; -#else - typedef char value_type; - static constexpr value_type preferred_separator = '/'; -#endif - typedef basic_string string_type; - typedef basic_string_view __string_view; - - enum _LIBCPP_ENUM_VIS format : unsigned char { - auto_format, - native_format, - generic_format - }; - - // constructors and destructor - _LIBCPP_INLINE_VISIBILITY path() noexcept {} - _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {} - _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept - : __pn_(_VSTD::move(__p.__pn_)) {} - - _LIBCPP_INLINE_VISIBILITY - path(string_type&& __s, format = format::auto_format) noexcept - : __pn_(_VSTD::move(__s)) {} - - template > - path(const _Source& __src, format = format::auto_format) { - _SourceCVT<_Source>::__append_source(__pn_, __src); - } - - template - path(_InputIt __first, _InputIt __last, format = format::auto_format) { - typedef typename iterator_traits<_InputIt>::value_type _ItVal; - _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); - } - -/* -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - // TODO Implement locale conversions. - template > - path(const _Source& __src, const locale& __loc, format = format::auto_format); - template - path(_InputIt __first, _InputIt _last, const locale& __loc, - format = format::auto_format); -#endif -*/ - - _LIBCPP_INLINE_VISIBILITY - ~path() = default; - - // assignments - _LIBCPP_INLINE_VISIBILITY - path& operator=(const path& __p) { - __pn_ = __p.__pn_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator=(path&& __p) noexcept { - __pn_ = _VSTD::move(__p.__pn_); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator=(string_type&& __s) noexcept { - __pn_ = _VSTD::move(__s); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& assign(string_type&& __s) noexcept { - __pn_ = _VSTD::move(__s); - return *this; - } - - template - _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> - operator=(const _Source& __src) { - return this->assign(__src); - } - - template - _EnableIfPathable<_Source> assign(const _Source& __src) { - __pn_.clear(); - _SourceCVT<_Source>::__append_source(__pn_, __src); - return *this; - } - - template - path& assign(_InputIt __first, _InputIt __last) { - typedef typename iterator_traits<_InputIt>::value_type _ItVal; - __pn_.clear(); - _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); - return *this; - } - -public: - // appends -#if defined(_LIBCPP_WIN32API) - path& operator/=(const path& __p) { - auto __p_root_name = __p.__root_name(); - auto __p_root_name_size = __p_root_name.size(); - if (__p.is_absolute() || - (!__p_root_name.empty() && __p_root_name != __string_view(root_name().__pn_))) { - __pn_ = __p.__pn_; - return *this; - } - if (__p.has_root_directory()) { - path __root_name_str = root_name(); - __pn_ = __root_name_str.native(); - __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); - return *this; - } - if (has_filename() || (!has_root_directory() && is_absolute())) - __pn_ += preferred_separator; - __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); - return *this; - } - template - _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> - operator/=(const _Source& __src) { - return operator/=(path(__src)); - } - - template - _EnableIfPathable<_Source> append(const _Source& __src) { - return operator/=(path(__src)); - } - - template - path& append(_InputIt __first, _InputIt __last) { - return operator/=(path(__first, __last)); - } -#else - path& operator/=(const path& __p) { - if (__p.is_absolute()) { - __pn_ = __p.__pn_; - return *this; - } - if (has_filename()) - __pn_ += preferred_separator; - __pn_ += __p.native(); - return *this; - } - - // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src - // is known at compile time to be "/' since the user almost certainly intended - // to append a separator instead of overwriting the path with "/" - template - _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> - operator/=(const _Source& __src) { - return this->append(__src); - } - - template - _EnableIfPathable<_Source> append(const _Source& __src) { - using _Traits = __is_pathable<_Source>; - using _CVT = _PathCVT<_SourceChar<_Source> >; - bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src)); - if (__source_is_absolute) - __pn_.clear(); - else if (has_filename()) - __pn_ += preferred_separator; - _CVT::__append_source(__pn_, __src); - return *this; - } - - template - path& append(_InputIt __first, _InputIt __last) { - typedef typename iterator_traits<_InputIt>::value_type _ItVal; - static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); - using _CVT = _PathCVT<_ItVal>; - if (__first != __last && __is_separator(*__first)) - __pn_.clear(); - else if (has_filename()) - __pn_ += preferred_separator; - _CVT::__append_range(__pn_, __first, __last); - return *this; - } -#endif - - // concatenation - _LIBCPP_INLINE_VISIBILITY - path& operator+=(const path& __x) { - __pn_ += __x.__pn_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator+=(const string_type& __x) { - __pn_ += __x; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator+=(__string_view __x) { - __pn_ += __x; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator+=(const value_type* __x) { - __pn_ += __x; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& operator+=(value_type __x) { - __pn_ += __x; - return *this; - } - - template - typename enable_if<__can_convert_char<_ECharT>::value, path&>::type - operator+=(_ECharT __x) { - _PathCVT<_ECharT>::__append_source(__pn_, - basic_string_view<_ECharT>(&__x, 1)); - return *this; - } - - template - _EnableIfPathable<_Source> operator+=(const _Source& __x) { - return this->concat(__x); - } - - template - _EnableIfPathable<_Source> concat(const _Source& __x) { - _SourceCVT<_Source>::__append_source(__pn_, __x); - return *this; - } - - template - path& concat(_InputIt __first, _InputIt __last) { - typedef typename iterator_traits<_InputIt>::value_type _ItVal; - _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); - return *this; - } - - // modifiers - _LIBCPP_INLINE_VISIBILITY - void clear() noexcept { __pn_.clear(); } - - path& make_preferred() { -#if defined(_LIBCPP_WIN32API) - _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\'); -#endif - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - path& remove_filename() { - auto __fname = __filename(); - if (!__fname.empty()) - __pn_.erase(__fname.data() - __pn_.data()); - return *this; - } - - path& replace_filename(const path& __replacement) { - remove_filename(); - return (*this /= __replacement); - } - - path& replace_extension(const path& __replacement = path()); - - _LIBCPP_INLINE_VISIBILITY - void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); } - - // private helper to allow reserving memory in the path - _LIBCPP_INLINE_VISIBILITY - void __reserve(size_t __s) { __pn_.reserve(__s); } - - // native format observers - _LIBCPP_INLINE_VISIBILITY - const string_type& native() const noexcept { return __pn_; } - - _LIBCPP_INLINE_VISIBILITY - const value_type* c_str() const noexcept { return __pn_.c_str(); } - - _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } - -#if defined(_LIBCPP_WIN32API) - _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; } - - _VSTD::wstring generic_wstring() const { - _VSTD::wstring __s; - __s.resize(__pn_.size()); - _VSTD::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/'); - return __s; - } - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - template , - class _Allocator = allocator<_ECharT> > - basic_string<_ECharT, _Traits, _Allocator> - string(const _Allocator& __a = _Allocator()) const { - using _Str = basic_string<_ECharT, _Traits, _Allocator>; - _Str __s(__a); - __s.reserve(__pn_.size()); - _PathExport<_ECharT>::__append(__s, __pn_); - return __s; - } - - _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { - return string(); - } - _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const { - using _CVT = __narrow_to_utf8; - __u8_string __s; - __s.reserve(__pn_.size()); - _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); - return __s; - } - - _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { - return string(); - } - _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { - return string(); - } - - // generic format observers - template , - class _Allocator = allocator<_ECharT> > - basic_string<_ECharT, _Traits, _Allocator> - generic_string(const _Allocator& __a = _Allocator()) const { - using _Str = basic_string<_ECharT, _Traits, _Allocator>; - _Str __s = string<_ECharT, _Traits, _Allocator>(__a); - // Note: This (and generic_u8string below) is slightly suboptimal as - // it iterates twice over the string; once to convert it to the right - // character type, and once to replace path delimiters. - _VSTD::replace(__s.begin(), __s.end(), - static_cast<_ECharT>('\\'), static_cast<_ECharT>('/')); - return __s; - } - - _VSTD::string generic_string() const { return generic_string(); } - _VSTD::u16string generic_u16string() const { return generic_string(); } - _VSTD::u32string generic_u32string() const { return generic_string(); } - __u8_string generic_u8string() const { - __u8_string __s = u8string(); - _VSTD::replace(__s.begin(), __s.end(), '\\', '/'); - return __s; - } -#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ -#else /* _LIBCPP_WIN32API */ - - _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; } -#ifndef _LIBCPP_HAS_NO_CHAR8_T - _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } -#else - _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; } -#endif - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - template , - class _Allocator = allocator<_ECharT> > - basic_string<_ECharT, _Traits, _Allocator> - string(const _Allocator& __a = _Allocator()) const { - using _CVT = __widen_from_utf8; - using _Str = basic_string<_ECharT, _Traits, _Allocator>; - _Str __s(__a); - __s.reserve(__pn_.size()); - _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); - return __s; - } - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { - return string(); - } -#endif - _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { - return string(); - } - _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { - return string(); - } -#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ - - // generic format observers - _VSTD::string generic_string() const { return __pn_; } -#ifndef _LIBCPP_HAS_NO_CHAR8_T - _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } -#else - _VSTD::string generic_u8string() const { return __pn_; } -#endif - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - template , - class _Allocator = allocator<_ECharT> > - basic_string<_ECharT, _Traits, _Allocator> - generic_string(const _Allocator& __a = _Allocator()) const { - return string<_ECharT, _Traits, _Allocator>(__a); - } - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS - _VSTD::wstring generic_wstring() const { return string(); } -#endif - _VSTD::u16string generic_u16string() const { return string(); } - _VSTD::u32string generic_u32string() const { return string(); } -#endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ -#endif /* !_LIBCPP_WIN32API */ - -private: - int __compare(__string_view) const; - __string_view __root_name() const; - __string_view __root_directory() const; - __string_view __root_path_raw() const; - __string_view __relative_path() const; - __string_view __parent_path() const; - __string_view __filename() const; - __string_view __stem() const; - __string_view __extension() const; - -public: - // compare - _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept { - return __compare(__p.__pn_); - } - _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { - return __compare(__s); - } - _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { - return __compare(__s); - } - _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { - return __compare(__s); - } - - // decomposition - _LIBCPP_INLINE_VISIBILITY path root_name() const { - return string_type(__root_name()); - } - _LIBCPP_INLINE_VISIBILITY path root_directory() const { - return string_type(__root_directory()); - } - _LIBCPP_INLINE_VISIBILITY path root_path() const { -#if defined(_LIBCPP_WIN32API) - return string_type(__root_path_raw()); -#else - return root_name().append(string_type(__root_directory())); -#endif - } - _LIBCPP_INLINE_VISIBILITY path relative_path() const { - return string_type(__relative_path()); - } - _LIBCPP_INLINE_VISIBILITY path parent_path() const { - return string_type(__parent_path()); - } - _LIBCPP_INLINE_VISIBILITY path filename() const { - return string_type(__filename()); - } - _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); } - _LIBCPP_INLINE_VISIBILITY path extension() const { - return string_type(__extension()); - } - - // query - _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool - empty() const noexcept { - return __pn_.empty(); - } - - _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { - return !__root_name().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { - return !__root_directory().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { - return !__root_path_raw().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { - return !__relative_path().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { - return !__parent_path().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_filename() const { - return !__filename().empty(); - } - _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } - _LIBCPP_INLINE_VISIBILITY bool has_extension() const { - return !__extension().empty(); - } - - _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { -#if defined(_LIBCPP_WIN32API) - __string_view __root_name_str = __root_name(); - __string_view __root_dir = __root_directory(); - if (__root_name_str.size() == 2 && __root_name_str[1] == ':') { - // A drive letter with no root directory is relative, e.g. x:example. - return !__root_dir.empty(); - } - // If no root name, it's relative, e.g. \example is relative to the current drive - if (__root_name_str.empty()) - return false; - if (__root_name_str.size() < 3) - return false; - // A server root name, like \\server, is always absolute - if (__root_name_str[0] != '/' && __root_name_str[0] != '\\') - return false; - if (__root_name_str[1] != '/' && __root_name_str[1] != '\\') - return false; - // Seems to be a server root name - return true; -#else - return has_root_directory(); -#endif - } - _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } - - // relative paths - path lexically_normal() const; - path lexically_relative(const path& __base) const; - - _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const { - path __result = this->lexically_relative(__base); - if (__result.native().empty()) - return *this; - return __result; - } - - // iterators - class _LIBCPP_TYPE_VIS iterator; - typedef iterator const_iterator; - - iterator begin() const; - iterator end() const; - -#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - template - _LIBCPP_INLINE_VISIBILITY friend - typename enable_if::value && - is_same<_Traits, char_traits >::value, - basic_ostream<_CharT, _Traits>&>::type - operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { - __os << _VSTD::__quoted(__p.native()); - return __os; - } - - template - _LIBCPP_INLINE_VISIBILITY friend - typename enable_if::value || - !is_same<_Traits, char_traits >::value, - basic_ostream<_CharT, _Traits>&>::type - operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { - __os << _VSTD::__quoted(__p.string<_CharT, _Traits>()); - return __os; - } - - template - _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>& - operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { - basic_string<_CharT, _Traits> __tmp; - __is >> __quoted(__tmp); - __p = __tmp; - return __is; - } -#endif // !_LIBCPP_HAS_NO_LOCALIZATION - - friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) == 0; - } - friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) != 0; - } - friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) < 0; - } - friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) <= 0; - } - friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) > 0; - } - friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept { - return __lhs.__compare(__rhs.__pn_) >= 0; - } - - friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, - const path& __rhs) { - path __result(__lhs); - __result /= __rhs; - return __result; - } -private: - inline _LIBCPP_INLINE_VISIBILITY path& - __assign_view(__string_view const& __s) noexcept { - __pn_ = string_type(__s); - return *this; - } - string_type __pn_; -}; - -inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { - __lhs.swap(__rhs); -} - -_LIBCPP_FUNC_VIS -size_t hash_value(const path& __p) noexcept; - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_PATH_H diff --git a/include/__filesystem/path_iterator.h b/include/__filesystem/path_iterator.h deleted file mode 100644 index 08039e4c8..000000000 --- a/include/__filesystem/path_iterator.h +++ /dev/null @@ -1,130 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H -#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H - -#include <__availability> -#include <__config> -#include <__debug> -#include <__filesystem/path.h> -#include <__iterator/iterator_traits.h> -#include -#include -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -class _LIBCPP_TYPE_VIS path::iterator { -public: - enum _ParserState : unsigned char { - _Singular, - _BeforeBegin, - _InRootName, - _InRootDir, - _InFilenames, - _InTrailingSep, - _AtEnd - }; - -public: - typedef input_iterator_tag iterator_category; - typedef bidirectional_iterator_tag iterator_concept; - - typedef path value_type; - typedef ptrdiff_t difference_type; - typedef const path* pointer; - typedef path reference; - -public: - _LIBCPP_INLINE_VISIBILITY - iterator() - : __stashed_elem_(), __path_ptr_(nullptr), __entry_(), - __state_(_Singular) {} - - iterator(const iterator&) = default; - ~iterator() = default; - - iterator& operator=(const iterator&) = default; - - _LIBCPP_INLINE_VISIBILITY - reference operator*() const { return __stashed_elem_; } - - _LIBCPP_INLINE_VISIBILITY - pointer operator->() const { return &__stashed_elem_; } - - _LIBCPP_INLINE_VISIBILITY - iterator& operator++() { - _LIBCPP_ASSERT(__state_ != _Singular, - "attempting to increment a singular iterator"); - _LIBCPP_ASSERT(__state_ != _AtEnd, - "attempting to increment the end iterator"); - return __increment(); - } - - _LIBCPP_INLINE_VISIBILITY - iterator operator++(int) { - iterator __it(*this); - this->operator++(); - return __it; - } - - _LIBCPP_INLINE_VISIBILITY - iterator& operator--() { - _LIBCPP_ASSERT(__state_ != _Singular, - "attempting to decrement a singular iterator"); - _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(), - "attempting to decrement the begin iterator"); - return __decrement(); - } - - _LIBCPP_INLINE_VISIBILITY - iterator operator--(int) { - iterator __it(*this); - this->operator--(); - return __it; - } - -private: - friend class path; - - inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, - const iterator&); - - iterator& __increment(); - iterator& __decrement(); - - path __stashed_elem_; - const path* __path_ptr_; - path::__string_view __entry_; - _ParserState __state_; -}; - -inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs, - const path::iterator& __rhs) { - return __lhs.__path_ptr_ == __rhs.__path_ptr_ && - __lhs.__entry_.data() == __rhs.__entry_.data(); -} - -inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs, - const path::iterator& __rhs) { - return !(__lhs == __rhs); -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_PATH_ITERATOR_H diff --git a/include/__filesystem/perm_options.h b/include/__filesystem/perm_options.h deleted file mode 100644 index 62cd8f575..000000000 --- a/include/__filesystem/perm_options.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H -#define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H - -#include <__availability> -#include <__config> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { - replace = 1, - add = 2, - remove = 4, - nofollow = 8 -}; - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) { - return static_cast(static_cast(_LHS) & - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) { - return static_cast(static_cast(_LHS) | - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) { - return static_cast(static_cast(_LHS) ^ - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perm_options operator~(perm_options _LHS) { - return static_cast(~static_cast(_LHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) { - return _LHS = _LHS & _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) { - return _LHS = _LHS | _RHS; -} - -_LIBCPP_INLINE_VISIBILITY -inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) { - return _LHS = _LHS ^ _RHS; -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_PERM_OPTIONS_H diff --git a/include/__filesystem/perms.h b/include/__filesystem/perms.h deleted file mode 100644 index 832f8b07e..000000000 --- a/include/__filesystem/perms.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_PERMS_H -#define _LIBCPP___FILESYSTEM_PERMS_H - -#include <__availability> -#include <__config> - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -// On Windows, these permission bits map to one single readonly flag per -// file, and the executable bit is always returned as set. When setting -// permissions, as long as the write bit is set for either owner, group or -// others, the readonly flag is cleared. -enum class _LIBCPP_ENUM_VIS perms : unsigned { - none = 0, - - owner_read = 0400, - owner_write = 0200, - owner_exec = 0100, - owner_all = 0700, - - group_read = 040, - group_write = 020, - group_exec = 010, - group_all = 070, - - others_read = 04, - others_write = 02, - others_exec = 01, - others_all = 07, - - all = 0777, - - set_uid = 04000, - set_gid = 02000, - sticky_bit = 01000, - mask = 07777, - unknown = 0xFFFF, -}; - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perms operator&(perms _LHS, perms _RHS) { - return static_cast(static_cast(_LHS) & - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perms operator|(perms _LHS, perms _RHS) { - return static_cast(static_cast(_LHS) | - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perms operator^(perms _LHS, perms _RHS) { - return static_cast(static_cast(_LHS) ^ - static_cast(_RHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline constexpr perms operator~(perms _LHS) { - return static_cast(~static_cast(_LHS)); -} - -_LIBCPP_INLINE_VISIBILITY -inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } - -_LIBCPP_INLINE_VISIBILITY -inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } - -_LIBCPP_INLINE_VISIBILITY -inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_PERMS_H diff --git a/include/__filesystem/recursive_directory_iterator.h b/include/__filesystem/recursive_directory_iterator.h deleted file mode 100644 index b80d59750..000000000 --- a/include/__filesystem/recursive_directory_iterator.h +++ /dev/null @@ -1,181 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H -#define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H - -#include <__availability> -#include <__config> -#include <__filesystem/directory_entry.h> -#include <__filesystem/directory_options.h> -#include <__filesystem/path.h> -#include <__iterator/iterator_traits.h> -#include <__memory/shared_ptr.h> -#include <__ranges/enable_borrowed_range.h> -#include <__ranges/enable_view.h> -#include -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -class recursive_directory_iterator { -public: - using value_type = directory_entry; - using difference_type = ptrdiff_t; - using pointer = directory_entry const*; - using reference = directory_entry const&; - using iterator_category = input_iterator_tag; - -public: - // constructors and destructor - _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator() noexcept : __rec_(false) {} - - _LIBCPP_INLINE_VISIBILITY - explicit recursive_directory_iterator( - const path& __p, directory_options __xoptions = directory_options::none) - : recursive_directory_iterator(__p, __xoptions, nullptr) {} - - _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator(const path& __p, directory_options __xoptions, - error_code& __ec) - : recursive_directory_iterator(__p, __xoptions, &__ec) {} - - _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator(const path& __p, error_code& __ec) - : recursive_directory_iterator(__p, directory_options::none, &__ec) {} - - recursive_directory_iterator(const recursive_directory_iterator&) = default; - recursive_directory_iterator(recursive_directory_iterator&&) = default; - - recursive_directory_iterator& - operator=(const recursive_directory_iterator&) = default; - - _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator& - operator=(recursive_directory_iterator&& __o) noexcept { - // non-default implementation provided to support self-move assign. - if (this != &__o) { - __imp_ = _VSTD::move(__o.__imp_); - __rec_ = __o.__rec_; - } - return *this; - } - - ~recursive_directory_iterator() = default; - - _LIBCPP_INLINE_VISIBILITY - const directory_entry& operator*() const { return __dereference(); } - - _LIBCPP_INLINE_VISIBILITY - const directory_entry* operator->() const { return &__dereference(); } - - recursive_directory_iterator& operator++() { return __increment(); } - - _LIBCPP_INLINE_VISIBILITY - __dir_element_proxy operator++(int) { - __dir_element_proxy __p(**this); - __increment(); - return __p; - } - - _LIBCPP_INLINE_VISIBILITY - recursive_directory_iterator& increment(error_code& __ec) { - return __increment(&__ec); - } - - _LIBCPP_FUNC_VIS directory_options options() const; - _LIBCPP_FUNC_VIS int depth() const; - - _LIBCPP_INLINE_VISIBILITY - void pop() { __pop(); } - - _LIBCPP_INLINE_VISIBILITY - void pop(error_code& __ec) { __pop(&__ec); } - - _LIBCPP_INLINE_VISIBILITY - bool recursion_pending() const { return __rec_; } - - _LIBCPP_INLINE_VISIBILITY - void disable_recursion_pending() { __rec_ = false; } - -private: - _LIBCPP_FUNC_VIS - recursive_directory_iterator(const path& __p, directory_options __opt, - error_code* __ec); - - _LIBCPP_FUNC_VIS - const directory_entry& __dereference() const; - - _LIBCPP_FUNC_VIS - bool __try_recursion(error_code* __ec); - - _LIBCPP_FUNC_VIS - void __advance(error_code* __ec = nullptr); - - _LIBCPP_FUNC_VIS - recursive_directory_iterator& __increment(error_code* __ec = nullptr); - - _LIBCPP_FUNC_VIS - void __pop(error_code* __ec = nullptr); - - inline _LIBCPP_INLINE_VISIBILITY friend bool - operator==(const recursive_directory_iterator&, - const recursive_directory_iterator&) noexcept; - - struct _LIBCPP_HIDDEN __shared_imp; - shared_ptr<__shared_imp> __imp_; - bool __rec_; -}; // class recursive_directory_iterator - -inline _LIBCPP_INLINE_VISIBILITY bool -operator==(const recursive_directory_iterator& __lhs, - const recursive_directory_iterator& __rhs) noexcept { - return __lhs.__imp_ == __rhs.__imp_; -} - -_LIBCPP_INLINE_VISIBILITY -inline bool operator!=(const recursive_directory_iterator& __lhs, - const recursive_directory_iterator& __rhs) noexcept { - return !(__lhs == __rhs); -} -// enable recursive_directory_iterator range-based for statements -inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator -begin(recursive_directory_iterator __iter) noexcept { - return __iter; -} - -inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator -end(recursive_directory_iterator) noexcept { - return recursive_directory_iterator(); -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template <> -_LIBCPP_AVAILABILITY_FILESYSTEM -inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::recursive_directory_iterator> = true; - -template <> -_LIBCPP_AVAILABILITY_FILESYSTEM -inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H diff --git a/include/__filesystem/space_info.h b/include/__filesystem/space_info.h deleted file mode 100644 index 098f08567..000000000 --- a/include/__filesystem/space_info.h +++ /dev/null @@ -1,35 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_SPACE_INFO_H -#define _LIBCPP___FILESYSTEM_SPACE_INFO_H - -#include <__availability> -#include <__config> -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -struct _LIBCPP_TYPE_VIS space_info { - uintmax_t capacity; - uintmax_t free; - uintmax_t available; -}; - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_SPACE_INFO_H diff --git a/include/__filesystem/u8path.h b/include/__filesystem/u8path.h deleted file mode 100644 index dca3b0c50..000000000 --- a/include/__filesystem/u8path.h +++ /dev/null @@ -1,96 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FILESYSTEM_U8PATH_H -#define _LIBCPP___FILESYSTEM_U8PATH_H - -#include <__availability> -#include <__config> -#include <__filesystem/path.h> -#include - -#ifndef _LIBCPP_CXX03_LANG - -_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM - -_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH - -template -_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_InputIt>::value, path>::type - u8path(_InputIt __f, _InputIt __l) { - static_assert( -#ifndef _LIBCPP_HAS_NO_CHAR8_T - is_same::__char_type, char8_t>::value || -#endif - is_same::__char_type, char>::value, - "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" - " or 'char8_t'"); -#if defined(_LIBCPP_WIN32API) - string __tmp(__f, __l); - using _CVT = __widen_from_utf8; - _VSTD::wstring __w; - __w.reserve(__tmp.size()); - _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); - return path(__w); -#else - return path(__f, __l); -#endif /* !_LIBCPP_WIN32API */ -} - -#if defined(_LIBCPP_WIN32API) -template -_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_InputIt>::value, path>::type - u8path(_InputIt __f, _NullSentinel) { - static_assert( -#ifndef _LIBCPP_HAS_NO_CHAR8_T - is_same::__char_type, char8_t>::value || -#endif - is_same::__char_type, char>::value, - "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" - " or 'char8_t'"); - string __tmp; - const char __sentinel = char{}; - for (; *__f != __sentinel; ++__f) - __tmp.push_back(*__f); - using _CVT = __widen_from_utf8; - _VSTD::wstring __w; - __w.reserve(__tmp.size()); - _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); - return path(__w); -} -#endif /* _LIBCPP_WIN32API */ - -template -_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_Source>::value, path>::type - u8path(const _Source& __s) { - static_assert( -#ifndef _LIBCPP_HAS_NO_CHAR8_T - is_same::__char_type, char8_t>::value || -#endif - is_same::__char_type, char>::value, - "u8path(Source const&) requires Source have a character type of type " - "'char' or 'char8_t'"); -#if defined(_LIBCPP_WIN32API) - using _Traits = __is_pathable<_Source>; - return u8path(_VSTD::__unwrap_iter(_Traits::__range_begin(__s)), _VSTD::__unwrap_iter(_Traits::__range_end(__s))); -#else - return path(__s); -#endif -} - -_LIBCPP_AVAILABILITY_FILESYSTEM_POP - -_LIBCPP_END_NAMESPACE_FILESYSTEM - -#endif // _LIBCPP_CXX03_LANG - -#endif // _LIBCPP___FILESYSTEM_U8PATH_H diff --git a/include/__format/format_arg.h b/include/__format/format_arg.h deleted file mode 100644 index e76b0dd50..000000000 --- a/include/__format/format_arg.h +++ /dev/null @@ -1,292 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H -#define _LIBCPP___FORMAT_FORMAT_ARG_H - -#include <__concepts/arithmetic.h> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/format_parse_context.h> -#include <__functional_base> -#include <__memory/addressof.h> -#include <__variant/monostate.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format { -/// The type stored in @ref basic_format_arg. -/// -/// @note The 128-bit types are unconditionally in the list to avoid the values -/// of the enums to depend on the availability of 128-bit integers. -enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { - __none, - __boolean, - __char_type, - __int, - __long_long, - __i128, - __unsigned, - __unsigned_long_long, - __u128, - __float, - __double, - __long_double, - __const_char_type_ptr, - __string_view, - __ptr, - __handle -}; -} // namespace __format - -template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) -visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { - switch (__arg.__type_) { - case __format::__arg_t::__none: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{}); - case __format::__arg_t::__boolean: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean); - case __format::__arg_t::__char_type: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type); - case __format::__arg_t::__int: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int); - case __format::__arg_t::__long_long: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long); - case __format::__arg_t::__i128: -#ifndef _LIBCPP_HAS_NO_INT128 - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128); -#else - _LIBCPP_UNREACHABLE(); -#endif - case __format::__arg_t::__unsigned: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned); - case __format::__arg_t::__unsigned_long_long: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), - __arg.__unsigned_long_long); - case __format::__arg_t::__u128: -#ifndef _LIBCPP_HAS_NO_INT128 - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128); -#else - _LIBCPP_UNREACHABLE(); -#endif - case __format::__arg_t::__float: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float); - case __format::__arg_t::__double: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double); - case __format::__arg_t::__long_double: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double); - case __format::__arg_t::__const_char_type_ptr: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), - __arg.__const_char_type_ptr); - case __format::__arg_t::__string_view: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view); - case __format::__arg_t::__ptr: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr); - case __format::__arg_t::__handle: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle); - } - _LIBCPP_UNREACHABLE(); -} - -template -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg { -public: - class _LIBCPP_TEMPLATE_VIS handle; - - _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept - : __type_{__format::__arg_t::__none} {} - - _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { - return __type_ != __format::__arg_t::__none; - } - -private: - using char_type = typename _Context::char_type; - - // TODO FMT Implement constrain [format.arg]/4 - // Constraints: The template specialization - // typename Context::template formatter_type - // meets the Formatter requirements ([formatter.requirements]). The extent - // to which an implementation determines that the specialization meets the - // Formatter requirements is unspecified, except that as a minimum the - // expression - // typename Context::template formatter_type() - // .format(declval(), declval()) - // shall be well-formed when treated as an unevaluated operand. - - template - _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...> - make_format_args(const _Args&...); - - template - _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto) - visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg); - - union { - bool __boolean; - char_type __char_type; - int __int; - unsigned __unsigned; - long long __long_long; - unsigned long long __unsigned_long_long; -#ifndef _LIBCPP_HAS_NO_INT128 - __int128_t __i128; - __uint128_t __u128; -#endif - float __float; - double __double; - long double __long_double; - const char_type* __const_char_type_ptr; - basic_string_view __string_view; - const void* __ptr; - handle __handle; - }; - __format::__arg_t __type_; - - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept - : __boolean(__v), __type_(__format::__arg_t::__boolean) {} - - template - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept - requires(same_as<_Tp, char_type> || - (same_as<_Tp, char> && same_as)) - : __char_type(__v), __type_(__format::__arg_t::__char_type) {} - - template <__libcpp_signed_integer _Tp> - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept { - if constexpr (sizeof(_Tp) <= sizeof(int)) { - __int = static_cast(__v); - __type_ = __format::__arg_t::__int; - } else if constexpr (sizeof(_Tp) <= sizeof(long long)) { - __long_long = static_cast(__v); - __type_ = __format::__arg_t::__long_long; - } -#ifndef _LIBCPP_HAS_NO_INT128 - else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) { - __i128 = __v; - __type_ = __format::__arg_t::__i128; - } -#endif - else - static_assert(sizeof(_Tp) == 0, "An unsupported signed integer was used"); - } - - template <__libcpp_unsigned_integer _Tp> - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp __v) noexcept { - if constexpr (sizeof(_Tp) <= sizeof(unsigned)) { - __unsigned = static_cast(__v); - __type_ = __format::__arg_t::__unsigned; - } else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) { - __unsigned_long_long = static_cast(__v); - __type_ = __format::__arg_t::__unsigned_long_long; - } -#ifndef _LIBCPP_HAS_NO_INT128 - else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) { - __u128 = __v; - __type_ = __format::__arg_t::__u128; - } -#endif - else - static_assert(sizeof(_Tp) == 0, - "An unsupported unsigned integer was used"); - } - - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(float __v) noexcept - : __float(__v), __type_(__format::__arg_t::__float) {} - - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(double __v) noexcept - : __double(__v), __type_(__format::__arg_t::__double) {} - - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(long double __v) noexcept - : __long_double(__v), __type_(__format::__arg_t::__long_double) {} - - // Note not a 'noexcept' function. - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const char_type* __s) - : __const_char_type_ptr(__s), - __type_(__format::__arg_t::__const_char_type_ptr) { - _LIBCPP_ASSERT(__s, "Used a nullptr argument to initialize a C-string"); - } - - template - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg( - basic_string_view __s) noexcept - : __string_view{__s.data(), __s.size()}, - __type_(__format::__arg_t::__string_view) {} - - template - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg( - const basic_string& __s) noexcept - : __string_view{__s.data(), __s.size()}, - __type_(__format::__arg_t::__string_view) {} - - _LIBCPP_HIDE_FROM_ABI - explicit basic_format_arg(nullptr_t) noexcept - : __ptr(nullptr), __type_(__format::__arg_t::__ptr) {} - - template - requires is_void_v<_Tp> _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp* __p) noexcept - : __ptr(__p), __type_(__format::__arg_t::__ptr) {} - - template - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept - : __handle(__v), __type_(__format::__arg_t::__handle) {} -}; - -template -class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { - friend class basic_format_arg<_Context>; - -public: - _LIBCPP_HIDE_FROM_ABI - void format(basic_format_parse_context& __parse_ctx, _Context& __ctx) const { - __format_(__parse_ctx, __ctx, __ptr_); - } - -private: - const void* __ptr_; - void (*__format_)(basic_format_parse_context&, _Context&, const void*); - - template - _LIBCPP_HIDE_FROM_ABI explicit handle(const _Tp& __v) noexcept - : __ptr_(_VSTD::addressof(__v)), - __format_([](basic_format_parse_context& __parse_ctx, _Context& __ctx, const void* __ptr) { - typename _Context::template formatter_type<_Tp> __f; - __parse_ctx.advance_to(__f.parse(__parse_ctx)); - __ctx.advance_to(__f.format(*static_cast(__ptr), __ctx)); - }) {} -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMAT_ARG_H diff --git a/include/__format/format_args.h b/include/__format/format_args.h deleted file mode 100644 index 0a26b95d1..000000000 --- a/include/__format/format_args.h +++ /dev/null @@ -1,71 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H -#define _LIBCPP___FORMAT_FORMAT_ARGS_H - -#include <__availability> -#include <__config> -#include <__format/format_fwd.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args { -public: - // TODO FMT Implement [format.args]/5 - // [Note 1: Implementations are encouraged to optimize the representation of - // basic_format_args for small number of formatting arguments by storing - // indices of type alternatives separately from values and packing the - // former. - end note] - // Note: Change __format_arg_store to use a built-in array. - _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default; - - template - _LIBCPP_HIDE_FROM_ABI basic_format_args( - const __format_arg_store<_Context, _Args...>& __store) noexcept - : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {} - - _LIBCPP_HIDE_FROM_ABI - basic_format_arg<_Context> get(size_t __id) const noexcept { - return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{}; - } - - _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; } - -private: - size_t __size_{0}; - const basic_format_arg<_Context>* __data_{nullptr}; -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H diff --git a/include/__format/format_context.h b/include/__format/format_context.h deleted file mode 100644 index 570bf7e90..000000000 --- a/include/__format/format_context.h +++ /dev/null @@ -1,165 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_CONTEXT_H -#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H - -#include <__availability> -#include <__config> -#include <__format/format_args.h> -#include <__format/format_fwd.h> -#include <__iterator/back_insert_iterator.h> -#include <__iterator/concepts.h> -#include - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -#include -#include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -requires output_iterator<_OutIt, const _CharT&> -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context; - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -/** - * Helper to create a basic_format_context. - * - * This is needed since the constructor is private. - */ -template -_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT> -__format_context_create( - _OutIt __out_it, - basic_format_args> __args, - optional<_VSTD::locale>&& __loc = nullopt) { - return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, - _VSTD::move(__loc)); -} -#else -template -_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT> -__format_context_create( - _OutIt __out_it, - basic_format_args> __args) { - return _VSTD::basic_format_context(_VSTD::move(__out_it), __args); -} -#endif - -// TODO FMT Implement [format.context]/4 -// [Note 1: For a given type charT, implementations are encouraged to provide a -// single instantiation of basic_format_context for appending to -// basic_string, vector, or any other container with contiguous -// storage by wrapping those in temporary objects with a uniform interface -// (such as a span) and polymorphic reallocation. - end note] - -using format_context = basic_format_context, char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wformat_context = basic_format_context, wchar_t>; -#endif - -template -requires output_iterator<_OutIt, const _CharT&> -class - // clang-format off - _LIBCPP_TEMPLATE_VIS - _LIBCPP_AVAILABILITY_FORMAT - _LIBCPP_PREFERRED_NAME(format_context) - _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) - // clang-format on - basic_format_context { -public: - using iterator = _OutIt; - using char_type = _CharT; - template - using formatter_type = formatter<_Tp, _CharT>; - - basic_format_context(const basic_format_context&) = delete; - basic_format_context& operator=(const basic_format_context&) = delete; - - _LIBCPP_HIDE_FROM_ABI basic_format_arg - arg(size_t __id) const { - return __args_.get(__id); - } -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() { - if (!__loc_) - __loc_ = _VSTD::locale{}; - return *__loc_; - } -#endif - _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; } - _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; } - -private: - iterator __out_it_; - basic_format_args __args_; -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - - // The Standard doesn't specify how the locale is stored. - // [format.context]/6 - // std::locale locale(); - // Returns: The locale passed to the formatting function if the latter - // takes one, and std::locale() otherwise. - // This is done by storing the locale of the constructor in this optional. If - // locale() is called and the optional has no value the value will be created. - // This allows the implementation to lazily create the locale. - // TODO FMT Validate whether lazy creation is the best solution. - optional<_VSTD::locale> __loc_; - - template - friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - __format_context_create(__OutIt, basic_format_args>, - optional<_VSTD::locale>&&); - - // Note: the Standard doesn't specify the required constructors. - _LIBCPP_HIDE_FROM_ABI - explicit basic_format_context(_OutIt __out_it, - basic_format_args __args, - optional<_VSTD::locale>&& __loc) - : __out_it_(_VSTD::move(__out_it)), __args_(__args), - __loc_(_VSTD::move(__loc)) {} -#else - template - friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> - __format_context_create(__OutIt, basic_format_args>); - - _LIBCPP_HIDE_FROM_ABI - explicit basic_format_context(_OutIt __out_it, - basic_format_args __args) - : __out_it_(_VSTD::move(__out_it)), __args_(__args) {} -#endif -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H diff --git a/include/__format/format_error.h b/include/__format/format_error.h index ac1d70803..f983d0ce4 100644 --- a/include/__format/format_error.h +++ b/include/__format/format_error.h @@ -21,6 +21,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 @@ -48,4 +51,6 @@ __throw_format_error(const char* __s) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___FORMAT_FORMAT_ERROR_H diff --git a/include/__format/format_fwd.h b/include/__format/format_fwd.h deleted file mode 100644 index 7da30aec5..000000000 --- a/include/__format/format_fwd.h +++ /dev/null @@ -1,56 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_FWD_H -#define _LIBCPP___FORMAT_FORMAT_FWD_H - -#include <__availability> -#include <__config> -#include <__iterator/concepts.h> -#include <__utility/forward.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg; - -template -struct _LIBCPP_TEMPLATE_VIS __format_arg_store; - -template -_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Ctx, _Args...> -make_format_args(const _Args&...); - -template -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMAT_FWD_H diff --git a/include/__format/format_parse_context.h b/include/__format/format_parse_context.h index 289cab9f0..db39c1b54 100644 --- a/include/__format/format_parse_context.h +++ b/include/__format/format_parse_context.h @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 @@ -26,7 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD // If the compiler has no concepts support, the format header will be disabled. // Without concepts support enable_if needs to be used and that too much effort // to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && \ + !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) template class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context { @@ -96,14 +100,14 @@ private: }; using format_parse_context = basic_format_parse_context; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using wformat_parse_context = basic_format_parse_context; -#endif -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) #endif //_LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H diff --git a/include/__format/format_string.h b/include/__format/format_string.h deleted file mode 100644 index 885e572fc..000000000 --- a/include/__format/format_string.h +++ /dev/null @@ -1,169 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H -#define _LIBCPP___FORMAT_FORMAT_STRING_H - -#include <__config> -#include <__debug> -#include <__format/format_error.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format { - -template -struct _LIBCPP_TEMPLATE_VIS __parse_number_result { - const _CharT* __ptr; - uint32_t __value; -}; - -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_number(const _CharT* __begin, const _CharT* __end); - -/** - * The maximum value of a numeric argument. - * - * This is used for: - * * arg-id - * * width as value or arg-id. - * * precision as value or arg-id. - * - * The value is compatible with the maximum formatting width and precision - * using the `%*` syntax on a 32-bit system. - */ -inline constexpr uint32_t __number_max = INT32_MAX; - -namespace __detail { -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_zero(const _CharT* __begin, const _CharT*, auto& __parse_ctx) { - __parse_ctx.check_arg_id(0); - return {++__begin, 0}; // can never be larger than the maximum. -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) { - size_t __value = __parse_ctx.next_arg_id(); - _LIBCPP_ASSERT(__value <= __number_max, - "Compilers don't support this number of arguments"); - - return {__begin, uint32_t(__value)}; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { - __parse_number_result<_CharT> __r = __parse_number(__begin, __end); - __parse_ctx.check_arg_id(__r.__value); - return __r; -} - -} // namespace __detail - -/** - * Parses a number. - * - * The number is used for the 31-bit values @em width and @em precision. This - * allows a maximum value of 2147483647. - */ -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_number(const _CharT* __begin, const _CharT* __end_input) { - static_assert(__format::__number_max == INT32_MAX, - "The algorithm is implemented based on this value."); - /* - * Limit the input to 9 digits, otherwise we need two checks during every - * iteration: - * - Are we at the end of the input? - * - Does the value exceed width of an uint32_t? (Switching to uint64_t would - * have the same issue, but with a higher maximum.) - */ - const _CharT* __end = __end_input - __begin > 9 ? __begin + 9 : __end_input; - uint32_t __value = *__begin - _CharT('0'); - while (++__begin != __end) { - if (*__begin < _CharT('0') || *__begin > _CharT('9')) - return {__begin, __value}; - - __value = __value * 10 + *__begin - _CharT('0'); - } - - if (__begin != __end_input && *__begin >= _CharT('0') && - *__begin <= _CharT('9')) { - - /* - * There are more than 9 digits, do additional validations: - * - Does the 10th digit exceed the maximum allowed value? - * - Are there more than 10 digits? - * (More than 10 digits always overflows the maximum.) - */ - uint64_t __v = uint64_t(__value) * 10 + *__begin++ - _CharT('0'); - if (__v > __number_max || - (__begin != __end_input && *__begin >= _CharT('0') && - *__begin <= _CharT('9'))) - __throw_format_error("The numeric value of the format-spec is too large"); - - __value = __v; - } - - return {__begin, __value}; -} - -/** - * Multiplexer for all parse functions. - * - * The parser will return a pointer beyond the last consumed character. This - * should be the closing '}' of the arg-id. - */ -template -_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> -__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { - switch (*__begin) { - case _CharT('0'): - return __detail::__parse_zero(__begin, __end, __parse_ctx); - - case _CharT(':'): - // This case is conditionally valid. It's allowed in an arg-id in the - // replacement-field, but not in the std-format-spec. The caller can - // provide a better diagnostic, so accept it here unconditionally. - case _CharT('}'): - return __detail::__parse_automatic(__begin, __end, __parse_ctx); - } - if (*__begin < _CharT('0') || *__begin > _CharT('9')) - __throw_format_error( - "The arg-id of the format-spec starts with an invalid character"); - - return __detail::__parse_manual(__begin, __end, __parse_ctx); -} - -} // namespace __format - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMAT_STRING_H diff --git a/include/__format/format_to_n_result.h b/include/__format/format_to_n_result.h deleted file mode 100644 index b973dc5c1..000000000 --- a/include/__format/format_to_n_result.h +++ /dev/null @@ -1,41 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H -#define _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H - -#include <__config> -#include <__iterator/incrementable_traits.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -struct _LIBCPP_TEMPLATE_VIS format_to_n_result { - _OutIt out; - iter_difference_t<_OutIt> size; -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H diff --git a/include/__format/formatter.h b/include/__format/formatter.h deleted file mode 100644 index 38b73bba3..000000000 --- a/include/__format/formatter.h +++ /dev/null @@ -1,290 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_H -#define _LIBCPP___FORMAT_FORMATTER_H - -#include <__algorithm/copy.h> -#include <__algorithm/fill_n.h> -#include <__availability> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/format_string.h> -#include <__format/parser_std_format_spec.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -/// The default formatter template. -/// -/// [format.formatter.spec]/5 -/// If F is a disabled specialization of formatter, these values are false: -/// - is_default_constructible_v, -/// - is_copy_constructible_v, -/// - is_move_constructible_v, -/// - is_copy_assignable, and -/// - is_move_assignable. -template -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter { - formatter() = delete; - formatter(const formatter&) = delete; - formatter& operator=(const formatter&) = delete; -}; - -namespace __format_spec { - -_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, - _Flags::_Sign __sign) { - if (__negative) - *__buf++ = '-'; - else - switch (__sign) { - case _Flags::_Sign::__default: - case _Flags::_Sign::__minus: - // No sign added. - break; - case _Flags::_Sign::__plus: - *__buf++ = '+'; - break; - case _Flags::_Sign::__space: - *__buf++ = ' '; - break; - } - - return __buf; -} - -_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) { - switch (c) { - case 'a': - return 'A'; - case 'b': - return 'B'; - case 'c': - return 'C'; - case 'd': - return 'D'; - case 'e': - return 'E'; - case 'f': - return 'F'; - } - return c; -} - -} // namespace __format_spec - -namespace __formatter { - -/** The character types that formatters are specialized for. */ -template -concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>; - -struct _LIBCPP_TEMPLATE_VIS __padding_size_result { - size_t __before; - size_t __after; -}; - -_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result -__padding_size(size_t __size, size_t __width, - __format_spec::_Flags::_Alignment __align) { - _LIBCPP_ASSERT(__width > __size, - "Don't call this function when no padding is required"); - _LIBCPP_ASSERT( - __align != __format_spec::_Flags::_Alignment::__default, - "Caller should adjust the default to the value required by the type"); - - size_t __fill = __width - __size; - switch (__align) { - case __format_spec::_Flags::_Alignment::__default: - _LIBCPP_UNREACHABLE(); - - case __format_spec::_Flags::_Alignment::__left: - return {0, __fill}; - - case __format_spec::_Flags::_Alignment::__center: { - // The extra padding is divided per [format.string.std]/3 - // __before = floor(__fill, 2); - // __after = ceil(__fill, 2); - size_t __before = __fill / 2; - size_t __after = __fill - __before; - return {__before, __after}; - } - case __format_spec::_Flags::_Alignment::__right: - return {__fill, 0}; - } - _LIBCPP_UNREACHABLE(); -} - -/** - * Writes the input to the output with the required padding. - * - * Since the output column width is specified the function can be used for - * ASCII and Unicode input. - * - * @pre [@a __first, @a __last) is a valid range. - * @pre @a __size <= @a __width. Using this function when this pre-condition - * doesn't hold incurs an unwanted overhead. - * - * @param __out_it The output iterator to write to. - * @param __first Pointer to the first element to write. - * @param __last Pointer beyond the last element to write. - * @param __size The (estimated) output column width. When the elements - * to be written are ASCII the following condition holds - * @a __size == @a __last - @a __first. - * @param __width The number of output columns to write. - * @param __fill The character used for the alignment of the output. - * TODO FMT Will probably change to support Unicode grapheme - * cluster. - * @param __alignment The requested alignment. - * - * @returns An iterator pointing beyond the last element written. - * - * @note The type of the elements in range [@a __first, @a __last) can differ - * from the type of @a __fill. Integer output uses @c std::to_chars for its - * conversion, which means the [@a __first, @a __last) always contains elements - * of the type @c char. - */ -template -_LIBCPP_HIDE_FROM_ABI auto -__write(output_iterator auto __out_it, const _CharT* __first, - const _CharT* __last, size_t __size, size_t __width, _Fill __fill, - __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) { - - _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); - _LIBCPP_ASSERT(__size < __width, "Precondition failure"); - - __padding_size_result __padding = - __padding_size(__size, __width, __alignment); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); - __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it)); - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); -} - -/** - * @overload - * - * Writes additional zero's for the precision before the exponent. - * This is used when the precision requested in the format string is larger - * than the maximum precision of the floating-point type. These precision - * digits are always 0. - * - * @param __exponent The location of the exponent character. - * @param __num_trailing_zeros The number of 0's to write before the exponent - * character. - */ -template -_LIBCPP_HIDE_FROM_ABI auto __write(output_iterator auto __out_it, const _CharT* __first, - const _CharT* __last, size_t __size, size_t __width, _Fill __fill, - __format_spec::_Flags::_Alignment __alignment, const _CharT* __exponent, - size_t __num_trailing_zeros) -> decltype(__out_it) { - _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); - _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used"); - - __padding_size_result __padding = __padding_size(__size + __num_trailing_zeros, __width, __alignment); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); - __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it)); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0')); - __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it)); - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); -} - -/** - * @overload - * - * Uses a transformation operation before writing an element. - * - * TODO FMT Fill will probably change to support Unicode grapheme cluster. - */ -template -_LIBCPP_HIDE_FROM_ABI auto -__write(output_iterator auto __out_it, const _CharT* __first, - const _CharT* __last, size_t __size, _UnaryOperation __op, - size_t __width, _Fill __fill, - __format_spec::_Flags::_Alignment __alignment) -> decltype(__out_it) { - - _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); - _LIBCPP_ASSERT(__size < __width, "Precondition failure"); - - __padding_size_result __padding = - __padding_size(__size, __width, __alignment); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); - __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op); - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); -} - -/** - * Writes Unicode input to the output with the required padding. - * - * This function does almost the same as the @ref __write function, but handles - * the width estimation of the Unicode input. - * - * @param __str The range [@a __first, @a __last). - * @param __precision The width to truncate the input string to, use @c -1 for - * no limit. - */ -template -_LIBCPP_HIDE_FROM_ABI auto -__write_unicode(output_iterator auto __out_it, - basic_string_view<_CharT> __str, ptrdiff_t __width, - ptrdiff_t __precision, _Fill __fill, - __format_spec::_Flags::_Alignment __alignment) - -> decltype(__out_it) { - - // This value changes when there Unicode column width limits the output - // size. - auto __last = __str.end(); - if (__width != 0 || __precision != -1) { - __format_spec::__string_alignment<_CharT> __format_traits = - __format_spec::__get_string_alignment(__str.begin(), __str.end(), - __width, __precision); - - if (__format_traits.__align) - return __write(_VSTD::move(__out_it), __str.begin(), - __format_traits.__last, __format_traits.__size, __width, - __fill, __alignment); - - // No alignment required update the output based on the precision. - // This might be the same as __str.end(). - __last = __format_traits.__last; - } - - // Copy the input to the output. The output size might be limited by the - // precision. - return _VSTD::copy(__str.begin(), __last, _VSTD::move(__out_it)); -} - -} // namespace __formatter - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMATTER_H diff --git a/include/__format/formatter_bool.h b/include/__format/formatter_bool.h deleted file mode 100644 index 1e40bc0a4..000000000 --- a/include/__format/formatter_bool.h +++ /dev/null @@ -1,147 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H -#define _LIBCPP___FORMAT_FORMATTER_BOOL_H - -#include <__availability> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> -#include <__format/formatter_integral.h> -#include <__format/parser_std_format_spec.h> -#include - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -#include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template -class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> { -public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__string; - [[fallthrough]]; - case _Flags::_Type::__string: - this->__handle_bool(); - break; - - case _Flags::_Type::__char: - this->__handle_char(); - break; - - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; - - default: - __throw_format_error( - "The format-spec type has a type not supported for a bool argument"); - } - - return __it; - } -}; - -template -struct _LIBCPP_TEMPLATE_VIS __bool_strings; - -template <> -struct _LIBCPP_TEMPLATE_VIS __bool_strings { - static constexpr string_view __true{"true"}; - static constexpr string_view __false{"false"}; -}; - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -template <> -struct _LIBCPP_TEMPLATE_VIS __bool_strings { - static constexpr wstring_view __true{L"true"}; - static constexpr wstring_view __false{L"false"}; -}; -#endif - -template -using __formatter_bool = __formatter_integral<__parser_bool<_CharT>>; - -} //namespace __format_spec - -// [format.formatter.spec]/2.3 -// For each charT, for each cv-unqualified arithmetic type ArithmeticT other -// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization - -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_bool<_CharT> { - using _Base = __format_spec::__formatter_bool<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__type != __format_spec::_Flags::_Type::__string) - return _Base::format(static_cast(__value), __ctx); - - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - if (this->__locale_specific_form) { - const auto& __np = use_facet>(__ctx.locale()); - basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename(); - return __formatter::__write_unicode( - __ctx.out(), basic_string_view<_CharT>{__str}, this->__width, -1, - this->__fill, this->__alignment); - } -#endif - basic_string_view<_CharT> __str = - __value ? __format_spec::__bool_strings<_CharT>::__true - : __format_spec::__bool_strings<_CharT>::__false; - - // The output only uses ASCII so every character is one column. - unsigned __size = __str.size(); - if (__size >= this->__width) - return _VSTD::copy(__str.begin(), __str.end(), __ctx.out()); - - return __formatter::__write(__ctx.out(), __str.begin(), __str.end(), __size, - this->__width, this->__fill, this->__alignment); - } -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMATTER_BOOL_H diff --git a/include/__format/formatter_char.h b/include/__format/formatter_char.h deleted file mode 100644 index 2131de077..000000000 --- a/include/__format/formatter_char.h +++ /dev/null @@ -1,104 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_CHAR_H -#define _LIBCPP___FORMAT_FORMATTER_CHAR_H - -#include <__availability> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> -#include <__format/formatter_integral.h> -#include <__format/parser_std_format_spec.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template -class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> { -public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__char; - [[fallthrough]]; - case _Flags::_Type::__char: - this->__handle_char(); - break; - - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; - - default: - __throw_format_error( - "The format-spec type has a type not supported for a char argument"); - } - - return __it; - } -}; - -template -using __formatter_char = __formatter_integral<__parser_char<_CharT>>; - -} // namespace __format_spec - -// [format.formatter.spec]/2.1 The specializations - -template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_char {}; - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_char { - using _Base = __format_spec::__formatter_char; - - _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) - -> decltype(__ctx.out()) { - return _Base::format(static_cast(__value), __ctx); - } -}; - -template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_char {}; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMATTER_CHAR_H diff --git a/include/__format/formatter_floating_point.h b/include/__format/formatter_floating_point.h deleted file mode 100644 index 2e710b409..000000000 --- a/include/__format/formatter_floating_point.h +++ /dev/null @@ -1,717 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H -#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H - -#include <__algorithm/copy.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/find.h> -#include <__algorithm/min.h> -#include <__algorithm/rotate.h> -#include <__algorithm/transform.h> -#include <__concepts/arithmetic.h> -#include <__config> -#include <__debug> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/format_string.h> -#include <__format/formatter.h> -#include <__format/formatter_integral.h> -#include <__format/parser_std_format_spec.h> -#include <__utility/move.h> -#include -#include - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -# include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -# if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template -_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) { - to_chars_result __r = _VSTD::to_chars(__first, __last, __value); - _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); - return __r.ptr; -} - -template -_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt) { - to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt); - _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); - return __r.ptr; -} - -template -_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt, int __precision) { - to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt, __precision); - _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); - return __r.ptr; -} - -// https://en.cppreference.com/w/cpp/language/types#cite_note-1 -// float min subnormal: +/-0x1p-149 max: +/- 3.402,823,4 10^38 -// double min subnormal: +/-0x1p-1074 max +/- 1.797,693,134,862,315,7 10^308 -// long double (x86) min subnormal: +/-0x1p-16446 max: +/- 1.189,731,495,357,231,765,021 10^4932 -// -// The maximum number of digits required for the integral part is based on the -// maximum's value power of 10. Every power of 10 requires one additional -// decimal digit. -// The maximum number of digits required for the fractional part is based on -// the minimal subnormal hexadecimal output's power of 10. Every division of a -// fraction's binary 1 by 2, requires one additional decimal digit. -// -// The maximum size of a formatted value depends on the selected output format. -// Ignoring the fact the format string can request a precision larger than the -// values maximum required, these values are: -// -// sign 1 code unit -// __max_integral -// radix point 1 code unit -// __max_fractional -// exponent character 1 code unit -// sign 1 code unit -// __max_fractional_value -// ----------------------------------- -// total 4 code units extra required. -// -// TODO FMT Optimize the storage to avoid storing digits that are known to be zero. -// https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/ - -// TODO FMT Add long double specialization when to_chars has proper long double support. -template -struct __traits; - -template -static constexpr size_t __float_buffer_size(int __precision) { - using _Traits = __traits<_Fp>; - return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value; -} - -template <> -struct __traits { - static constexpr int __max_integral = 38; - static constexpr int __max_fractional = 149; - static constexpr int __max_fractional_value = 3; - static constexpr size_t __stack_buffer_size = 256; - - static constexpr int __hex_precision_digits = 3; -}; - -template <> -struct __traits { - static constexpr int __max_integral = 308; - static constexpr int __max_fractional = 1074; - static constexpr int __max_fractional_value = 4; - static constexpr size_t __stack_buffer_size = 1024; - - static constexpr int __hex_precision_digits = 4; -}; - -/// Helper class to store the conversion buffer. -/// -/// Depending on the maxium size required for a value, the buffer is allocated -/// on the stack or the heap. -template -class _LIBCPP_TEMPLATE_VIS __float_buffer { - using _Traits = __traits<_Fp>; - -public: - // TODO FMT Improve this constructor to do a better estimate. - // When using a scientific formatting with a precision of 6 a stack buffer - // will always suffice. At the moment that isn't important since floats and - // doubles use a stack buffer, unless the precision used in the format string - // is large. - // When supporting long doubles the __max_integral part becomes 4932 which - // may be too much for some platforms. For these cases a better estimate is - // required. - explicit _LIBCPP_HIDE_FROM_ABI __float_buffer(int __precision) - : __precision_(__precision != -1 ? __precision : _Traits::__max_fractional) { - - // When the precision is larger than _Traits::__max_fractional the digits in - // the range (_Traits::__max_fractional, precision] will contain the value - // zero. There's no need to request to_chars to write these zeros: - // - When the value is large a temporary heap buffer needs to be allocated. - // - When to_chars writes the values they need to be "copied" to the output: - // - char: std::fill on the output iterator is faster than std::copy. - // - wchar_t: same argument as char, but additional std::copy won't work. - // The input is always a char buffer, so every char in the buffer needs - // to be converted from a char to a wchar_t. - if (__precision_ > _Traits::__max_fractional) { - __num_trailing_zeros_ = __precision_ - _Traits::__max_fractional; - __precision_ = _Traits::__max_fractional; - } - - __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_); - if (__size_ > _Traits::__stack_buffer_size) - // The allocated buffer's contents don't need initialization. - __begin_ = allocator{}.allocate(__size_); - else - __begin_ = __buffer_; - } - - _LIBCPP_HIDE_FROM_ABI ~__float_buffer() { - if (__size_ > _Traits::__stack_buffer_size) - allocator{}.deallocate(__begin_, __size_); - } - _LIBCPP_HIDE_FROM_ABI __float_buffer(const __float_buffer&) = delete; - _LIBCPP_HIDE_FROM_ABI __float_buffer& operator=(const __float_buffer&) = delete; - - _LIBCPP_HIDE_FROM_ABI char* begin() const { return __begin_; } - _LIBCPP_HIDE_FROM_ABI char* end() const { return __begin_ + __size_; } - - _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; } - _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; } - _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; } - -private: - int __precision_; - int __num_trailing_zeros_{0}; - size_t __size_; - char* __begin_; - char __buffer_[_Traits::__stack_buffer_size]; -}; - -struct __float_result { - /// Points at the beginning of the integral part in the buffer. - /// - /// When there's no sign character this points at the start of the buffer. - char* __integral; - - /// Points at the radix point, when not present it's the same as \ref __last. - char* __radix_point; - - /// Points at the exponent character, when not present it's the same as \ref __last. - char* __exponent; - - /// Points beyond the last written element in the buffer. - char* __last; -}; - -/// Finds the position of the exponent character 'e' at the end of the buffer. -/// -/// Assuming there is an exponent the input will terminate with -/// eSdd and eSdddd (S = sign, d = digit) -/// -/// \returns a pointer to the exponent or __last when not found. -constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) { - ptrdiff_t __size = __last - __first; - if (__size > 4) { - __first = __last - _VSTD::min(__size, ptrdiff_t(6)); - for (; __first != __last - 3; ++__first) { - if (*__first == 'e') - return __first; - } - } - return __last; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffer<_Fp>& __buffer, _Tp __value, - char* __integral) { - __float_result __result; - __result.__integral = __integral; - __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value); - - __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last); - - // Constrains: - // - There's at least one decimal digit before the radix point. - // - The radix point, when present, is placed before the exponent. - __result.__radix_point = _VSTD::find(__result.__integral + 1, __result.__exponent, '.'); - - // When the radix point isn't found its position is the exponent instead of - // __result.__last. - if (__result.__radix_point == __result.__exponent) - __result.__radix_point = __result.__last; - - // clang-format off - _LIBCPP_ASSERT((__result.__integral != __result.__last) && - (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && - (__result.__exponent == __result.__last || *__result.__exponent == 'e'), - "Post-condition failure."); - // clang-format on - - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(const __float_buffer<_Fp>& __buffer, - _Tp __value, int __precision, - char* __integral) { - __float_result __result; - __result.__integral = __integral; - if (__precision == -1) - __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex); - else - __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision); - - // H = one or more hex-digits - // S = sign - // D = one or more decimal-digits - // When the fractional part is zero and no precision the output is 0p+0 - // else the output is 0.HpSD - // So testing the second position can differentiate between these two cases. - char* __first = __integral + 1; - if (*__first == '.') { - __result.__radix_point = __first; - // One digit is the minimum - // 0.hpSd - // ^-- last - // ^---- integral = end of search - // ^-------- start of search - // 0123456 - // - // Four digits is the maximum - // 0.hpSdddd - // ^-- last - // ^---- integral = end of search - // ^-------- start of search - // 0123456789 - static_assert(__traits<_Fp>::__hex_precision_digits <= 4, "Guard against possible underflow."); - - char* __last = __result.__last - 2; - __first = __last - __traits<_Fp>::__hex_precision_digits; - __result.__exponent = _VSTD::find(__first, __last, 'p'); - } else { - __result.__radix_point = __result.__last; - __result.__exponent = __first; - } - - // clang-format off - _LIBCPP_ASSERT((__result.__integral != __result.__last) && - (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && - (__result.__exponent != __result.__last && *__result.__exponent == 'p'), - "Post-condition failure."); - // clang-format on - - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(const __float_buffer<_Fp>& __buffer, - _Tp __value, int __precision, - char* __integral) { - __float_result __result = - __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral); - _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper); - *__result.__exponent = 'P'; - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const __float_buffer<_Fp>& __buffer, - _Tp __value, int __precision, - char* __integral) { - __float_result __result; - __result.__integral = __integral; - __result.__last = - __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision); - - char* __first = __integral + 1; - _LIBCPP_ASSERT(__first != __result.__last, "No exponent present"); - if (*__first == '.') { - __result.__radix_point = __first; - __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last); - } else { - __result.__radix_point = __result.__last; - __result.__exponent = __first; - } - - // clang-format off - _LIBCPP_ASSERT((__result.__integral != __result.__last) && - (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && - (__result.__exponent != __result.__last && *__result.__exponent == 'e'), - "Post-condition failure."); - // clang-format on - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const __float_buffer<_Fp>& __buffer, - _Tp __value, int __precision, - char* __integral) { - __float_result __result = - __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral); - *__result.__exponent = 'E'; - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<_Fp>& __buffer, _Tp __value, - int __precision, char* __integral) { - __float_result __result; - __result.__integral = __integral; - __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision); - - // When there's no precision there's no radix point. - // Else the radix point is placed at __precision + 1 from the end. - // By converting __precision to a bool the subtraction can be done - // unconditionally. - __result.__radix_point = __result.__last - (__precision + bool(__precision)); - __result.__exponent = __result.__last; - - // clang-format off - _LIBCPP_ASSERT((__result.__integral != __result.__last) && - (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && - (__result.__exponent == __result.__last), - "Post-condition failure."); - // clang-format on - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_buffer<_Fp>& __buffer, _Tp __value, - int __precision, char* __integral) { - - __buffer.__remove_trailing_zeros(); - - __float_result __result; - __result.__integral = __integral; - __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision); - - char* __first = __integral + 1; - if (__first == __result.__last) { - __result.__radix_point = __result.__last; - __result.__exponent = __result.__last; - } else { - __result.__exponent = __format_spec::__find_exponent(__first, __result.__last); - if (__result.__exponent != __result.__last) - // In scientific mode if there's a radix point it will always be after - // the first digit. (This is the position __first points at). - __result.__radix_point = *__first == '.' ? __first : __result.__last; - else { - // In fixed mode the algorithm truncates trailing spaces and possibly the - // radix point. There's no good guess for the position of the radix point - // therefore scan the output after the first digit. - __result.__radix_point = _VSTD::find(__first, __result.__last, '.'); - } - } - - // clang-format off - _LIBCPP_ASSERT((__result.__integral != __result.__last) && - (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && - (__result.__exponent == __result.__last || *__result.__exponent == 'e'), - "Post-condition failure."); - // clang-format on - - return __result; -} - -template -_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value, - int __precision, char* __integral) { - __float_result __result = - __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral); - if (__result.__exponent != __result.__last) - *__result.__exponent = 'E'; - return __result; -} - -# ifndef _LIBCPP_HAS_NO_LOCALIZATION -template -_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, const __float_buffer<_Fp>& __buffer, - const __float_result& __result, _VSTD::locale __loc, - size_t __width, _Flags::_Alignment __alignment, - _CharT __fill) { - const auto& __np = use_facet>(__loc); - string __grouping = __np.grouping(); - char* __first = __result.__integral; - // When no radix point or exponent are present __last will be __result.__last. - char* __last = _VSTD::min(__result.__radix_point, __result.__exponent); - - ptrdiff_t __digits = __last - __first; - if (!__grouping.empty()) { - if (__digits <= __grouping[0]) - __grouping.clear(); - else - __grouping = __determine_grouping(__digits, __grouping); - } - - size_t __size = __result.__last - __buffer.begin() + // Formatted string - __buffer.__num_trailing_zeros() + // Not yet rendered zeros - __grouping.size() - // Grouping contains one - !__grouping.empty(); // additional character - - __formatter::__padding_size_result __padding = {0, 0}; - bool __zero_padding = __alignment == _Flags::_Alignment::__default; - if (__size < __width) { - if (__zero_padding) { - __alignment = _Flags::_Alignment::__right; - __fill = _CharT('0'); - } - - __padding = __formatter::__padding_size(__size, __width, __alignment); - } - - // sign and (zero padding or alignment) - if (__zero_padding && __first != __buffer.begin()) - *__out_it++ = *__buffer.begin(); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); - if (!__zero_padding && __first != __buffer.begin()) - *__out_it++ = *__buffer.begin(); - - // integral part - if (__grouping.empty()) { - __out_it = _VSTD::copy_n(__first, __digits, _VSTD::move(__out_it)); - } else { - auto __r = __grouping.rbegin(); - auto __e = __grouping.rend() - 1; - _CharT __sep = __np.thousands_sep(); - // The output is divided in small groups of numbers to write: - // - A group before the first separator. - // - A separator and a group, repeated for the number of separators. - // - A group after the last separator. - // This loop achieves that process by testing the termination condition - // midway in the loop. - while (true) { - __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); - __first += *__r; - - if (__r == __e) - break; - - ++__r; - *__out_it++ = __sep; - } - } - - // fractional part - if (__result.__radix_point != __result.__last) { - *__out_it++ = __np.decimal_point(); - __out_it = _VSTD::copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it)); - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0')); - } - - // exponent - if (__result.__exponent != __result.__last) - __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it)); - - // alignment - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); -} - -# endif // _LIBCPP_HAS_NO_LOCALIZATION - -template <__formatter::__char_type _CharT> -class _LIBCPP_TEMPLATE_VIS __formatter_floating_point : public __parser_floating_point<_CharT> { -public: - template - _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) -> decltype(__ctx.out()) { - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - bool __negative = _VSTD::signbit(__value); - - if (!_VSTD::isfinite(__value)) [[unlikely]] - return __format_non_finite(__ctx.out(), __negative, _VSTD::isnan(__value)); - - bool __has_precision = this->__has_precision_field(); - if (this->__precision_needs_substitution()) - this->__substitute_precision_arg_id(__ctx.arg(this->__precision)); - - // Depending on the std-format-spec string the sign and the value - // might not be outputted together: - // - zero-padding may insert additional '0' characters. - // Therefore the value is processed as a non negative value. - // The function @ref __insert_sign will insert a '-' when the value was - // negative. - - if (__negative) - __value = _VSTD::copysign(__value, +1.0); - - // TODO FMT _Fp should just be _Tp when to_chars has proper long double support. - using _Fp = conditional_t, double, _Tp>; - // Force the type of the precision to avoid -1 to become an unsigned value. - __float_buffer<_Fp> __buffer(__has_precision ? int(this->__precision) : -1); - __float_result __result = __format_buffer(__buffer, __value, __negative, __has_precision); - - if (this->__alternate_form && __result.__radix_point == __result.__last) { - *__result.__last++ = '.'; - - // When there is an exponent the point needs to be moved before the - // exponent. When there's no exponent the rotate does nothing. Since - // rotate tests whether the operation is a nop, call it unconditionally. - _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last); - __result.__radix_point = __result.__exponent; - - // The radix point is always placed before the exponent. - // - No exponent needs to point to the new last. - // - An exponent needs to move one position to the right. - // So it's safe to increment the value unconditionally. - ++__result.__exponent; - } - -# ifndef _LIBCPP_HAS_NO_LOCALIZATION - if (this->__locale_specific_form) - return __format_spec::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), - this->__width, this->__alignment, this->__fill); -# endif - - ptrdiff_t __size = __result.__last - __buffer.begin(); - int __num_trailing_zeros = __buffer.__num_trailing_zeros(); - if (__size + __num_trailing_zeros >= this->__width) { - if (__num_trailing_zeros && __result.__exponent != __result.__last) - // Insert trailing zeros before exponent character. - return _VSTD::copy(__result.__exponent, __result.__last, - _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), - __num_trailing_zeros, _CharT('0'))); - - return _VSTD::fill_n(_VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, - _CharT('0')); - } - - auto __out_it = __ctx.out(); - char* __first = __buffer.begin(); - if (this->__alignment == _Flags::_Alignment::__default) { - // When there is a sign output it before the padding. Note the __size - // doesn't need any adjustment, regardless whether the sign is written - // here or in __formatter::__write. - if (__first != __result.__integral) - *__out_it++ = *__first++; - // After the sign is written, zero padding is the same a right alignment - // with '0'. - this->__alignment = _Flags::_Alignment::__right; - this->__fill = _CharT('0'); - } - - if (__num_trailing_zeros) - return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill, - this->__alignment, __result.__exponent, __num_trailing_zeros); - - return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill, - this->__alignment); - } - -private: - template - _LIBCPP_HIDE_FROM_ABI _OutIt __format_non_finite(_OutIt __out_it, bool __negative, bool __isnan) { - char __buffer[4]; - char* __last = __insert_sign(__buffer, __negative, this->__sign); - - // to_char can return inf, infinity, nan, and nan(n-char-sequence). - // The format library requires inf and nan. - // All in one expression to avoid dangling references. - __last = _VSTD::copy_n(&("infnanINFNAN"[6 * (this->__type == _Flags::_Type::__float_hexadecimal_upper_case || - this->__type == _Flags::_Type::__scientific_upper_case || - this->__type == _Flags::_Type::__fixed_upper_case || - this->__type == _Flags::_Type::__general_upper_case) + - 3 * __isnan]), - 3, __last); - - // [format.string.std]/13 - // A zero (0) character preceding the width field pads the field with - // leading zeros (following any indication of sign or base) to the field - // width, except when applied to an infinity or NaN. - if (this->__alignment == _Flags::_Alignment::__default) - this->__alignment = _Flags::_Alignment::__right; - - ptrdiff_t __size = __last - __buffer; - if (__size >= this->__width) - return _VSTD::copy_n(__buffer, __size, _VSTD::move(__out_it)); - - return __formatter::__write(_VSTD::move(__out_it), __buffer, __last, __size, this->__width, this->__fill, - this->__alignment); - } - - /// Fills the buffer with the data based on the requested formatting. - /// - /// This function, when needed, turns the characters to upper case and - /// determines the "interesting" locations which are returned to the caller. - /// - /// This means the caller never has to convert the contents of the buffer to - /// upper case or search for radix points and the location of the exponent. - /// This gives a bit of overhead. The original code didn't do that, but due - /// to the number of possible additional work needed to turn this number to - /// the proper output the code was littered with tests for upper cases and - /// searches for radix points and exponents. - /// - When a precision larger than the type's precision is selected - /// additional zero characters need to be written before the exponent. - /// - alternate form needs to add a radix point when not present. - /// - localization needs to do grouping in the integral part. - template - // TODO FMT _Fp should just be _Tp when to_chars has proper long double support. - _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(__float_buffer<_Fp>& __buffer, _Tp __value, bool __negative, - bool __has_precision) { - char* __first = __insert_sign(__buffer.begin(), __negative, this->__sign); - switch (this->__type) { - case _Flags::_Type::__default: - return __format_spec::__format_buffer_default(__buffer, __value, __first); - - case _Flags::_Type::__float_hexadecimal_lower_case: - return __format_spec::__format_buffer_hexadecimal_lower_case( - __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first); - - case _Flags::_Type::__float_hexadecimal_upper_case: - return __format_spec::__format_buffer_hexadecimal_upper_case( - __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first); - - case _Flags::_Type::__scientific_lower_case: - return __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first); - - case _Flags::_Type::__scientific_upper_case: - return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first); - - case _Flags::_Type::__fixed_lower_case: - case _Flags::_Type::__fixed_upper_case: - return __format_spec::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first); - - case _Flags::_Type::__general_lower_case: - return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first); - - case _Flags::_Type::__general_upper_case: - return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first); - - default: - _LIBCPP_ASSERT(false, "The parser should have validated the type"); - _LIBCPP_UNREACHABLE(); - } - } -}; - -} //namespace __format_spec - -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_floating_point<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_floating_point<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_floating_point<_CharT> {}; - -# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H diff --git a/include/__format/formatter_integer.h b/include/__format/formatter_integer.h deleted file mode 100644 index e1f3d4e34..000000000 --- a/include/__format/formatter_integer.h +++ /dev/null @@ -1,170 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGER_H -#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H - -#include <__availability> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> -#include <__format/formatter_integral.h> -#include <__format/parser_std_format_spec.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template -class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> { -public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__decimal; - [[fallthrough]]; - - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; - - case _Flags::_Type::__char: - this->__handle_char(); - break; - - default: - __throw_format_error("The format-spec type has a type not supported for " - "an integer argument"); - } - return __it; - } -}; - -template -using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>; - -} // namespace __format_spec - -// [format.formatter.spec]/2.3 -// For each charT, for each cv-unqualified arithmetic type ArithmeticT other -// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization - -// Signed integral types. -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<__int128_t, _CharT> - : public __format_spec::__formatter_integer<_CharT> { - using _Base = __format_spec::__formatter_integer<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx) - -> decltype(__ctx.out()) { - // TODO FMT Implement full 128 bit support. - using _To = long long; - if (__value < numeric_limits<_To>::min() || - __value > numeric_limits<_To>::max()) - __throw_format_error("128-bit value is outside of implemented range"); - - return _Base::format(static_cast<_To>(__value), __ctx); - } -}; -#endif - -// Unsigned integral types. -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_integer<_CharT> {}; -#ifndef _LIBCPP_HAS_NO_INT128 -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<__uint128_t, _CharT> - : public __format_spec::__formatter_integer<_CharT> { - using _Base = __format_spec::__formatter_integer<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx) - -> decltype(__ctx.out()) { - // TODO FMT Implement full 128 bit support. - using _To = unsigned long long; - if (__value < numeric_limits<_To>::min() || - __value > numeric_limits<_To>::max()) - __throw_format_error("128-bit value is outside of implemented range"); - - return _Base::format(static_cast<_To>(__value), __ctx); - } -}; -#endif - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H diff --git a/include/__format/formatter_integral.h b/include/__format/formatter_integral.h deleted file mode 100644 index f164ee610..000000000 --- a/include/__format/formatter_integral.h +++ /dev/null @@ -1,463 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H -#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H - -#include <__algorithm/copy.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/transform.h> -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> -#include <__format/parser_std_format_spec.h> -#include -#include -#include -#include -#include - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION -#include -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -/** - * Integral formatting classes. - * - * There are two types used here: - * * C++-type, the type as used in C++. - * * format-type, the output type specified in the std-format-spec. - * - * Design of the integral formatters consists of several layers. - * * @ref __parser_integral The basic std-format-spec parser for all integral - * classes. This parser does the basic sanity checks. It also contains some - * helper functions that are nice to have available for all parsers. - * * A C++-type specific parser. These parsers must derive from - * @ref __parser_integral. Their task is to validate whether the parsed - * std-format-spec is valid for the C++-type and selected format-type. After - * validation they need to make sure all members are properly set. For - * example, when the alignment hasn't changed it needs to set the proper - * default alignment for the format-type. The following parsers are available: - * - @ref __parser_integer - * - @ref __parser_char - * - @ref __parser_bool - * * A general formatter for all integral types @ref __formatter_integral. This - * formatter can handle all formatting of integers and characters. The class - * derives from the proper formatter. - * Note the boolean string format-type isn't supported in this class. - * * A typedef C++-type group combining the @ref __formatter_integral with a - * parser: - * * @ref __formatter_integer - * * @ref __formatter_char - * * @ref __formatter_bool - * * Then every C++-type has its own formatter specializations. They inherit - * from the C++-type group typedef. Most specializations need nothing else. - * Others need some additional specializations in this class. - */ -namespace __format_spec { - -/** Wrapper around @ref to_chars, returning the output pointer. */ -template -_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, - _Tp __value, int __base) { - // TODO FMT Evaluate code overhead due to not calling the internal function - // directly. (Should be zero overhead.) - to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base); - _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); - return __r.ptr; -} - -/** - * Helper to determine the buffer size to output a integer in Base @em x. - * - * There are several overloads for the supported bases. The function uses the - * base as template argument so it can be used in a constant expression. - */ -template -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 2) { - return numeric_limits<_Tp>::digits // The number of binary digits. - + 2 // Reserve space for the '0[Bb]' prefix. - + 1; // Reserve space for the sign. -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 8) { - return numeric_limits<_Tp>::digits // The number of binary digits. - / 3 // Adjust to octal. - + 1 // Turn floor to ceil. - + 1 // Reserve space for the '0' prefix. - + 1; // Reserve space for the sign. -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 10) { - return numeric_limits<_Tp>::digits10 // The floored value. - + 1 // Turn floor to ceil. - + 1; // Reserve space for the sign. -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 16) { - return numeric_limits<_Tp>::digits // The number of binary digits. - / 4 // Adjust to hexadecimal. - + 2 // Reserve space for the '0[Xx]' prefix. - + 1; // Reserve space for the sign. -} - -/** - * Determines the required grouping based on the size of the input. - * - * The grouping's last element will be repeated. For simplicity this repeating - * is unwrapped based on the length of the input. (When the input is short some - * groups are not processed.) - * - * @returns The size of the groups to write. This means the number of - * separator characters written is size() - 1. - * - * @note Since zero-sized groups cause issues they are silently ignored. - * - * @note The grouping field of the locale is always a @c std::string, - * regardless whether the @c std::numpunct's type is @c char or @c wchar_t. - */ -_LIBCPP_HIDE_FROM_ABI inline string -__determine_grouping(ptrdiff_t __size, const string& __grouping) { - _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0], - "The slow grouping formatting is used while there will be no " - "separators written"); - string __r; - auto __end = __grouping.end() - 1; - auto __ptr = __grouping.begin(); - - while (true) { - __size -= *__ptr; - if (__size > 0) - __r.push_back(*__ptr); - else { - // __size <= 0 so the value pushed will be <= *__ptr. - __r.push_back(*__ptr + __size); - return __r; - } - - // Proceed to the next group. - if (__ptr != __end) { - do { - ++__ptr; - // Skip grouping with a width of 0. - } while (*__ptr == 0 && __ptr != __end); - } - } - - _LIBCPP_UNREACHABLE(); -} - -template -requires __formatter::__char_type -class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser { -public: - using _CharT = typename _Parser::char_type; - - template - _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - if (this->__type == _Flags::_Type::__char) - return __format_as_char(__value, __ctx); - - if constexpr (unsigned_integral<_Tp>) - return __format_unsigned_integral(__value, false, __ctx); - else { - // Depending on the std-format-spec string the sign and the value - // might not be outputted together: - // - alternate form may insert a prefix string. - // - zero-padding may insert additional '0' characters. - // Therefore the value is processed as a positive unsigned value. - // The function @ref __insert_sign will a '-' when the value was negative. - auto __r = __to_unsigned_like(__value); - bool __negative = __value < 0; - if (__negative) - __r = __complement(__r); - - return __format_unsigned_integral(__r, __negative, __ctx); - } - } - -private: - /** Generic formatting for format-type c. */ - _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value, - auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__alignment == _Flags::_Alignment::__default) - this->__alignment = _Flags::_Alignment::__right; - - using _Tp = decltype(__value); - if constexpr (!same_as<_CharT, _Tp>) { - // cmp_less and cmp_greater can't be used for character types. - if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) { - if (__value < numeric_limits<_CharT>::min() || - __value > numeric_limits<_CharT>::max()) - __throw_format_error( - "Integral value outside the range of the char type"); - } else if constexpr (signed_integral<_CharT>) { - // _CharT is signed _Tp is unsigned - if (__value > - static_cast>(numeric_limits<_CharT>::max())) - __throw_format_error( - "Integral value outside the range of the char type"); - } else { - // _CharT is unsigned _Tp is signed - if (__value < 0 || static_cast>(__value) > - numeric_limits<_CharT>::max()) - __throw_format_error( - "Integral value outside the range of the char type"); - } - } - - const auto __c = static_cast<_CharT>(__value); - return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, - __ctx.out()); - } - - /** - * Generic formatting for format-type bBdoxX. - * - * This small wrapper allocates a buffer with the required size. Then calls - * the real formatter with the buffer and the prefix for the base. - */ - _LIBCPP_HIDE_FROM_ABI auto - __format_unsigned_integral(unsigned_integral auto __value, bool __negative, - auto& __ctx) -> decltype(__ctx.out()) { - switch (this->__type) { - case _Flags::_Type::__binary_lower_case: { - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 2, __ctx, "0b"); - } - case _Flags::_Type::__binary_upper_case: { - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 2, __ctx, "0B"); - } - case _Flags::_Type::__octal: { - // Octal is special; if __value == 0 there's no prefix. - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 8, __ctx, - __value != 0 ? "0" : nullptr); - } - case _Flags::_Type::__decimal: { - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 10, __ctx, nullptr); - } - case _Flags::_Type::__hexadecimal_lower_case: { - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 16, __ctx, "0x"); - } - case _Flags::_Type::__hexadecimal_upper_case: { - array()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 16, __ctx, "0X"); - } - default: - _LIBCPP_ASSERT(false, "The parser should have validated the type"); - _LIBCPP_UNREACHABLE(); - } - } - - template - requires(same_as || same_as) _LIBCPP_HIDE_FROM_ABI - auto __write(const _Tp* __first, const _Tp* __last, auto __out_it) - -> decltype(__out_it) { - - unsigned __size = __last - __first; - if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] { - if (__size >= this->__width) - return _VSTD::copy(__first, __last, _VSTD::move(__out_it)); - - return __formatter::__write(_VSTD::move(__out_it), __first, __last, - __size, this->__width, this->__fill, - this->__alignment); - } - - // this->__type == _Flags::_Type::__hexadecimal_upper_case - // This means all characters in the range [a-f] need to be changed to their - // uppercase representation. The transformation is done as transformation - // in the output routine instead of before. This avoids another pass over - // the data. - // TODO FMT See whether it's possible to do this transformation during the - // conversion. (This probably requires changing std::to_chars' alphabet.) - if (__size >= this->__width) - return _VSTD::transform(__first, __last, _VSTD::move(__out_it), - __hex_to_upper); - - return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size, - __hex_to_upper, this->__width, this->__fill, - this->__alignment); - } - - _LIBCPP_HIDE_FROM_ABI auto - __format_unsigned_integral(char* __begin, char* __end, - unsigned_integral auto __value, bool __negative, - int __base, auto& __ctx, const char* __prefix) - -> decltype(__ctx.out()) { - char* __first = __insert_sign(__begin, __negative, this->__sign); - if (this->__alternate_form && __prefix) - while (*__prefix) - *__first++ = *__prefix++; - - char* __last = __to_buffer(__first, __end, __value, __base); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - if (this->__locale_specific_form) { - const auto& __np = use_facet>(__ctx.locale()); - string __grouping = __np.grouping(); - ptrdiff_t __size = __last - __first; - // Writing the grouped form has more overhead than the normal output - // routines. If there will be no separators written the locale-specific - // form is identical to the normal routine. Test whether to grouped form - // is required. - if (!__grouping.empty() && __size > __grouping[0]) - return __format_grouping(__ctx.out(), __begin, __first, __last, - __determine_grouping(__size, __grouping), - __np.thousands_sep()); - } -#endif - auto __out_it = __ctx.out(); - if (this->__alignment != _Flags::_Alignment::__default) - __first = __begin; - else { - // __buf contains [sign][prefix]data - // ^ location of __first - // The zero padding is done like: - // - Write [sign][prefix] - // - Write data right aligned with '0' as fill character. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - this->__alignment = _Flags::_Alignment::__right; - this->__fill = _CharT('0'); - uint32_t __size = __first - __begin; - this->__width -= _VSTD::min(__size, this->__width); - } - - return __write(__first, __last, _VSTD::move(__out_it)); - } - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - /** Format's the locale-specific form's groupings. */ - template - _LIBCPP_HIDE_FROM_ABI _OutIt - __format_grouping(_OutIt __out_it, const char* __begin, const char* __first, - const char* __last, string&& __grouping, _CharT __sep) { - - // TODO FMT This function duplicates some functionality of the normal - // output routines. Evaluate whether these parts can be efficiently - // combined with the existing routines. - - unsigned __size = (__first - __begin) + // [sign][prefix] - (__last - __first) + // data - (__grouping.size() - 1); // number of separator characters - - __formatter::__padding_size_result __padding = {0, 0}; - if (this->__alignment == _Flags::_Alignment::__default) { - // Write [sign][prefix]. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - - if (this->__width > __size) { - // Write zero padding. - __padding.__before = this->__width - __size; - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), this->__width - __size, - _CharT('0')); - } - } else { - if (this->__width > __size) { - // Determine padding and write padding. - __padding = __formatter::__padding_size(__size, this->__width, - this->__alignment); - - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, - this->__fill); - } - // Write [sign][prefix]. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - } - - auto __r = __grouping.rbegin(); - auto __e = __grouping.rend() - 1; - _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while " - "there will be no separators written."); - // The output is divided in small groups of numbers to write: - // - A group before the first separator. - // - A separator and a group, repeated for the number of separators. - // - A group after the last separator. - // This loop achieves that process by testing the termination condition - // midway in the loop. - // - // TODO FMT This loop evaluates the loop invariant `this->__type != - // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test - // happens in the __write call.) Benchmark whether making two loops and - // hoisting the invariant is worth the effort. - while (true) { - if (this->__type == _Flags::_Type::__hexadecimal_upper_case) { - __last = __first + *__r; - __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), - __hex_to_upper); - __first = __last; - } else { - __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); - __first += *__r; - } - - if (__r == __e) - break; - - ++__r; - *__out_it++ = __sep; - } - - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, - this->__fill); - } -#endif // _LIBCPP_HAS_NO_LOCALIZATION -}; - -} // namespace __format_spec - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H diff --git a/include/__format/formatter_pointer.h b/include/__format/formatter_pointer.h deleted file mode 100644 index aa2eb641c..000000000 --- a/include/__format/formatter_pointer.h +++ /dev/null @@ -1,91 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H -#define _LIBCPP___FORMAT_FORMATTER_POINTER_H - -#include <__algorithm/copy.h> -#include <__availability> -#include <__config> -#include <__debug> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> -#include <__format/formatter_integral.h> -#include <__format/parser_std_format_spec.h> -#include <__iterator/access.h> -#include <__nullptr> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -# if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template <__formatter::__char_type _CharT> -class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> { -public: - _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) { - _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default, - "The call to parse should have updated the alignment"); - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - // This code looks a lot like the code to format a hexadecimal integral, - // but that code isn't public. Making that code public requires some - // refactoring. - // TODO FMT Remove code duplication. - char __buffer[2 + 2 * sizeof(uintptr_t)]; - __buffer[0] = '0'; - __buffer[1] = 'x'; - char* __last = __to_buffer(__buffer + 2, _VSTD::end(__buffer), reinterpret_cast(__ptr), 16); - - unsigned __size = __last - __buffer; - if (__size >= this->__width) - return _VSTD::copy(__buffer, __last, __ctx.out()); - - return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment); - } -}; - -} // namespace __format_spec - -// [format.formatter.spec]/2.4 -// For each charT, the pointer type specializations template<> -// - struct formatter; -// - template<> struct formatter; -// - template<> struct formatter; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_pointer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_pointer<_CharT> {}; -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter - : public __format_spec::__formatter_pointer<_CharT> {}; - -# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMATTER_POINTER_H diff --git a/include/__format/formatter_string.h b/include/__format/formatter_string.h deleted file mode 100644 index 04950faa4..000000000 --- a/include/__format/formatter_string.h +++ /dev/null @@ -1,162 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H -#define _LIBCPP___FORMAT_FORMATTER_STRING_H - -#include <__config> -#include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/format_string.h> -#include <__format/formatter.h> -#include <__format/parser_std_format_spec.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -template <__formatter::__char_type _CharT> -class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> { -public: - _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, - auto& __ctx) -> decltype(__ctx.out()) { - - _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default, - "The parser should not use these defaults"); - - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - if (this->__precision_needs_substitution()) - this->__substitute_precision_arg_id(__ctx.arg(this->__precision)); - - return __formatter::__write_unicode( - __ctx.out(), __str, this->__width, - this->__has_precision_field() ? this->__precision : -1, this->__fill, - this->__alignment); - } -}; - -} //namespace __format_spec - -// [format.formatter.spec]/2.2 For each charT, the string type specializations - -// Formatter const char*. -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) - -> decltype(__ctx.out()) { - _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have " - "prevented an invalid pointer."); - - // When using a center or right alignment and the width option the length - // of __str must be known to add the padding upfront. This case is handled - // by the base class by converting the argument to a basic_string_view. - // - // When using left alignment and the width option the padding is added - // after outputting __str so the length can be determined while outputting - // __str. The same holds true for the precision, during outputting __str it - // can be validated whether the precision threshold has been reached. For - // now these optimizations aren't implemented. Instead the base class - // handles these options. - // TODO FMT Implement these improvements. - if (this->__has_width_field() || this->__has_precision_field()) - return _Base::format(__str, __ctx); - - // No formatting required, copy the string to the output. - auto __out_it = __ctx.out(); - while (*__str) - *__out_it++ = *__str++; - return __out_it; - } -}; - -// Formatter char*. -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<_CharT*, _CharT> : public formatter { - using _Base = formatter; - - _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) - -> decltype(__ctx.out()) { - return _Base::format(__str, __ctx); - } -}; - -// Formatter const char[]. -template <__formatter::__char_type _CharT, size_t _Size> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) - -> decltype(__ctx.out()) { - return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); - } -}; - -// Formatter std::string. -template <__formatter::__char_type _CharT, class _Traits, class _Allocator> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter, _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto - format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) - -> decltype(__ctx.out()) { - // drop _Traits and _Allocator - return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); - } -}; - -// Formatter std::string_view. -template <__formatter::__char_type _CharT, class _Traits> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter, _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto - format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) - -> decltype(__ctx.out()) { - // drop _Traits - return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); - } -}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H diff --git a/include/__format/parser_std_format_spec.h b/include/__format/parser_std_format_spec.h deleted file mode 100644 index 9d893e9ce..000000000 --- a/include/__format/parser_std_format_spec.h +++ /dev/null @@ -1,1398 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H -#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H - -#include <__algorithm/find_if.h> -#include <__algorithm/min.h> -#include <__config> -#include <__debug> -#include <__format/format_arg.h> -#include <__format/format_error.h> -#include <__format/format_string.h> -#include <__variant/monostate.h> -#include -#include -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// TODO FMT Remove this once we require compilers with proper C++20 support. -// If the compiler has no concepts support, the format header will be disabled. -// Without concepts support enable_if needs to be used and that too much effort -// to support compilers with partial C++20 support. -# if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -namespace __format_spec { - -/** - * Contains the flags for the std-format-spec. - * - * Some format-options can only be used for specific C++types and may depend on - * the selected format-type. - * * The C++type filtering can be done using the proper policies for - * @ref __parser_std. - * * The format-type filtering needs to be done post parsing in the parser - * derived from @ref __parser_std. - */ -class _LIBCPP_TYPE_VIS _Flags { -public: - enum class _LIBCPP_ENUM_VIS _Alignment : uint8_t { - /** - * No alignment is set in the format string. - * - * Zero-padding is ignored when an alignment is selected. - * The default alignment depends on the selected format-type. - */ - __default, - __left, - __center, - __right - }; - enum class _LIBCPP_ENUM_VIS _Sign : uint8_t { - /** - * No sign is set in the format string. - * - * The sign isn't allowed for certain format-types. By using this value - * it's possible to detect whether or not the user explicitly set the sign - * flag. For formatting purposes it behaves the same as @ref __minus. - */ - __default, - __minus, - __plus, - __space - }; - - _Alignment __alignment : 2 {_Alignment::__default}; - _Sign __sign : 2 {_Sign::__default}; - uint8_t __alternate_form : 1 {false}; - uint8_t __zero_padding : 1 {false}; - uint8_t __locale_specific_form : 1 {false}; - - enum class _LIBCPP_ENUM_VIS _Type : uint8_t { - __default, - __string, - __binary_lower_case, - __binary_upper_case, - __octal, - __decimal, - __hexadecimal_lower_case, - __hexadecimal_upper_case, - __pointer, - __char, - __float_hexadecimal_lower_case, - __float_hexadecimal_upper_case, - __scientific_lower_case, - __scientific_upper_case, - __fixed_lower_case, - __fixed_upper_case, - __general_lower_case, - __general_upper_case - }; - - _Type __type{_Type::__default}; -}; - -namespace __detail { -template -_LIBCPP_HIDE_FROM_ABI constexpr bool -__parse_alignment(_CharT __c, _Flags& __flags) noexcept { - switch (__c) { - case _CharT('<'): - __flags.__alignment = _Flags::_Alignment::__left; - return true; - - case _CharT('^'): - __flags.__alignment = _Flags::_Alignment::__center; - return true; - - case _CharT('>'): - __flags.__alignment = _Flags::_Alignment::__right; - return true; - } - return false; -} -} // namespace __detail - -template -class _LIBCPP_TEMPLATE_VIS __parser_fill_align { -public: - // TODO FMT The standard doesn't specify this character is a Unicode - // character. Validate what fmt and MSVC have implemented. - _CharT __fill{_CharT(' ')}; - -protected: - _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* - __parse(const _CharT* __begin, const _CharT* __end, _Flags& __flags) { - _LIBCPP_ASSERT(__begin != __end, - "When called with an empty input the function will cause " - "undefined behavior by evaluating data not in the input"); - if (__begin + 1 != __end) { - if (__detail::__parse_alignment(*(__begin + 1), __flags)) { - if (*__begin == _CharT('{') || *__begin == _CharT('}')) - __throw_format_error( - "The format-spec fill field contains an invalid character"); - __fill = *__begin; - return __begin + 2; - } - } - - if (__detail::__parse_alignment(*__begin, __flags)) - return __begin + 1; - - return __begin; - } -}; - -template -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__parse_sign(const _CharT* __begin, _Flags& __flags) noexcept { - switch (*__begin) { - case _CharT('-'): - __flags.__sign = _Flags::_Sign::__minus; - break; - case _CharT('+'): - __flags.__sign = _Flags::_Sign::__plus; - break; - case _CharT(' '): - __flags.__sign = _Flags::_Sign::__space; - break; - default: - return __begin; - } - return __begin + 1; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__parse_alternate_form(const _CharT* __begin, _Flags& __flags) noexcept { - if (*__begin == _CharT('#')) { - __flags.__alternate_form = true; - ++__begin; - } - - return __begin; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__parse_zero_padding(const _CharT* __begin, _Flags& __flags) noexcept { - if (*__begin == _CharT('0')) { - __flags.__zero_padding = true; - ++__begin; - } - - return __begin; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT> -__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { - // This function is a wrapper to call the real parser. But it does the - // validation for the pre-conditions and post-conditions. - if (__begin == __end) - __throw_format_error("End of input while parsing format-spec arg-id"); - - __format::__parse_number_result __r = - __format::__parse_arg_id(__begin, __end, __parse_ctx); - - if (__r.__ptr == __end || *__r.__ptr != _CharT('}')) - __throw_format_error("Invalid arg-id"); - - ++__r.__ptr; - return __r; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr uint32_t -__substitute_arg_id(basic_format_arg<_Context> __arg) { - return visit_format_arg( - [](auto __arg) -> uint32_t { - using _Type = decltype(__arg); - if constexpr (integral<_Type>) { - if constexpr (signed_integral<_Type>) { - if (__arg < 0) - __throw_format_error("A format-spec arg-id replacement shouldn't " - "have a negative value"); - } - - using _CT = common_type_t<_Type, decltype(__format::__number_max)>; - if (static_cast<_CT>(__arg) > - static_cast<_CT>(__format::__number_max)) - __throw_format_error("A format-spec arg-id replacement exceeds " - "the maximum supported value"); - - return __arg; - } else if constexpr (same_as<_Type, monostate>) - __throw_format_error("Argument index out of bounds"); - else - __throw_format_error("A format-spec arg-id replacement argument " - "isn't an integral type"); - }, - __arg); -} - -class _LIBCPP_TYPE_VIS __parser_width { -public: - /** Contains a width or an arg-id. */ - uint32_t __width : 31 {0}; - /** Determines whether the value stored is a width or an arg-id. */ - uint32_t __width_as_arg : 1 {0}; - -protected: - /** - * Does the supplied std-format-spec contain a width field? - * - * When the field isn't present there's no padding required. This can be used - * to optimize the formatting. - */ - constexpr bool __has_width_field() const noexcept { - return __width_as_arg || __width; - } - - /** - * Does the supplied width field contain an arg-id? - * - * If @c true the formatter needs to call @ref __substitute_width_arg_id. - */ - constexpr bool __width_needs_substitution() const noexcept { - return __width_as_arg; - } - - template - _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* - __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { - if (*__begin == _CharT('0')) - __throw_format_error( - "A format-spec width field shouldn't have a leading zero"); - - if (*__begin == _CharT('{')) { - __format::__parse_number_result __r = - __parse_arg_id(++__begin, __end, __parse_ctx); - __width = __r.__value; - __width_as_arg = 1; - return __r.__ptr; - } - - if (*__begin < _CharT('0') || *__begin > _CharT('9')) - return __begin; - - __format::__parse_number_result __r = - __format::__parse_number(__begin, __end); - __width = __r.__value; - _LIBCPP_ASSERT(__width != 0, - "A zero value isn't allowed and should be impossible, " - "due to validations in this function"); - return __r.__ptr; - } - - _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) { - _LIBCPP_ASSERT(__width_as_arg == 1, - "Substitute width called when no substitution is required"); - - // The clearing of the flag isn't required but looks better when debugging - // the code. - __width_as_arg = 0; - __width = __substitute_arg_id(__arg); - if (__width == 0) - __throw_format_error( - "A format-spec width field replacement should have a positive value"); - } -}; - -class _LIBCPP_TYPE_VIS __parser_precision { -public: - /** Contains a precision or an arg-id. */ - uint32_t __precision : 31 {__format::__number_max}; - /** - * Determines whether the value stored is a precision or an arg-id. - * - * @note Since @ref __precision == @ref __format::__number_max is a valid - * value, the default value contains an arg-id of INT32_MAX. (This number of - * arguments isn't supported by compilers.) This is used to detect whether - * the std-format-spec contains a precision field. - */ - uint32_t __precision_as_arg : 1 {1}; - -protected: - /** - * Does the supplied std-format-spec contain a precision field? - * - * When the field isn't present there's no truncating required. This can be - * used to optimize the formatting. - */ - constexpr bool __has_precision_field() const noexcept { - - return __precision_as_arg == 0 || // Contains a value? - __precision != __format::__number_max; // The arg-id is valid? - } - - /** - * Does the supplied precision field contain an arg-id? - * - * If @c true the formatter needs to call @ref __substitute_precision_arg_id. - */ - constexpr bool __precision_needs_substitution() const noexcept { - return __precision_as_arg && __precision != __format::__number_max; - } - - template - _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* - __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { - if (*__begin != _CharT('.')) - return __begin; - - ++__begin; - if (__begin == __end) - __throw_format_error("End of input while parsing format-spec precision"); - - if (*__begin == _CharT('{')) { - __format::__parse_number_result __arg_id = - __parse_arg_id(++__begin, __end, __parse_ctx); - _LIBCPP_ASSERT(__arg_id.__value != __format::__number_max, - "Unsupported number of arguments, since this number of " - "arguments is used a special value"); - __precision = __arg_id.__value; - return __arg_id.__ptr; - } - - if (*__begin < _CharT('0') || *__begin > _CharT('9')) - __throw_format_error( - "The format-spec precision field doesn't contain a value or arg-id"); - - __format::__parse_number_result __r = - __format::__parse_number(__begin, __end); - __precision = __r.__value; - __precision_as_arg = 0; - return __r.__ptr; - } - - _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id( - auto __arg) { - _LIBCPP_ASSERT( - __precision_as_arg == 1 && __precision != __format::__number_max, - "Substitute precision called when no substitution is required"); - - // The clearing of the flag isn't required but looks better when debugging - // the code. - __precision_as_arg = 0; - __precision = __substitute_arg_id(__arg); - } -}; - -template -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__parse_locale_specific_form(const _CharT* __begin, _Flags& __flags) noexcept { - if (*__begin == _CharT('L')) { - __flags.__locale_specific_form = true; - ++__begin; - } - - return __begin; -} - -template -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__parse_type(const _CharT* __begin, _Flags& __flags) { - - // Determines the type. It does not validate whether the selected type is - // valid. Most formatters have optional fields that are only allowed for - // certain types. These parsers need to do validation after the type has - // been parsed. So its easier to implement the validation for all types in - // the specific parse function. - switch (*__begin) { - case 'A': - __flags.__type = _Flags::_Type::__float_hexadecimal_upper_case; - break; - case 'B': - __flags.__type = _Flags::_Type::__binary_upper_case; - break; - case 'E': - __flags.__type = _Flags::_Type::__scientific_upper_case; - break; - case 'F': - __flags.__type = _Flags::_Type::__fixed_upper_case; - break; - case 'G': - __flags.__type = _Flags::_Type::__general_upper_case; - break; - case 'X': - __flags.__type = _Flags::_Type::__hexadecimal_upper_case; - break; - case 'a': - __flags.__type = _Flags::_Type::__float_hexadecimal_lower_case; - break; - case 'b': - __flags.__type = _Flags::_Type::__binary_lower_case; - break; - case 'c': - __flags.__type = _Flags::_Type::__char; - break; - case 'd': - __flags.__type = _Flags::_Type::__decimal; - break; - case 'e': - __flags.__type = _Flags::_Type::__scientific_lower_case; - break; - case 'f': - __flags.__type = _Flags::_Type::__fixed_lower_case; - break; - case 'g': - __flags.__type = _Flags::_Type::__general_lower_case; - break; - case 'o': - __flags.__type = _Flags::_Type::__octal; - break; - case 'p': - __flags.__type = _Flags::_Type::__pointer; - break; - case 's': - __flags.__type = _Flags::_Type::__string; - break; - case 'x': - __flags.__type = _Flags::_Type::__hexadecimal_lower_case; - break; - default: - return __begin; - } - return ++__begin; -} - -/** - * Process the parsed alignment and zero-padding state of arithmetic types. - * - * [format.string.std]/13 - * If the 0 character and an align option both appear, the 0 character is - * ignored. - * - * For the formatter a @ref __default alignment means zero-padding. - */ -_LIBCPP_HIDE_FROM_ABI constexpr void __process_arithmetic_alignment(_Flags& __flags) { - __flags.__zero_padding &= __flags.__alignment == _Flags::_Alignment::__default; - if (!__flags.__zero_padding && __flags.__alignment == _Flags::_Alignment::__default) - __flags.__alignment = _Flags::_Alignment::__right; -} - -/** - * The parser for the std-format-spec. - * - * [format.string.std]/1 specifies the std-format-spec: - * fill-and-align sign # 0 width precision L type - * - * All these fields are optional. Whether these fields can be used depend on: - * - The type supplied to the format string. - * E.g. A string never uses the sign field so the field may not be set. - * This constrain is validated by the parsers in this file. - * - The supplied value for the optional type field. - * E.g. A int formatted as decimal uses the sign field. - * When formatted as a char the sign field may no longer be set. - * This constrain isn't validated by the parsers in this file. - * - * The base classes are ordered to minimize the amount of padding. - * - * This implements the parser for the string types. - */ -template -class _LIBCPP_TEMPLATE_VIS __parser_string - : public __parser_width, // provides __width(|as_arg) - public __parser_precision, // provides __precision(|as_arg) - public __parser_fill_align<_CharT>, // provides __fill and uses __flags - public _Flags // provides __flags -{ -public: - using char_type = _CharT; - - _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() { - this->__alignment = _Flags::_Alignment::__left; - } - - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parse(__parse_ctx); - __process_display_type(); - return __it; - } - -private: - /** - * Parses the std-format-spec. - * - * @throws __throw_format_error When @a __parse_ctx contains an ill-formed - * std-format-spec. - * - * @returns An iterator to the end of input or point at the closing '}'. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - - auto __begin = __parse_ctx.begin(); - auto __end = __parse_ctx.end(); - if (__begin == __end) - return __begin; - - __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, - static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parser_width::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); - - if (__begin != __end && *__begin != _CharT('}')) - __throw_format_error( - "The format-spec should consume the input or end with a '}'"); - - return __begin; - } - - /** Processes the parsed std-format-spec based on the parsed display type. */ - _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { - switch (this->__type) { - case _Flags::_Type::__default: - case _Flags::_Type::__string: - break; - - default: - __throw_format_error("The format-spec type has a type not supported for " - "a string argument"); - } - } -}; - -/** - * The parser for the std-format-spec. - * - * This implements the parser for the integral types. This includes the - * character type and boolean type. - * - * See @ref __parser_string. - */ -template -class _LIBCPP_TEMPLATE_VIS __parser_integral - : public __parser_width, // provides __width(|as_arg) - public __parser_fill_align<_CharT>, // provides __fill and uses __flags - public _Flags // provides __flags -{ -public: - using char_type = _CharT; - -protected: - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __begin = __parse_ctx.begin(); - auto __end = __parse_ctx.end(); - if (__begin == __end) - return __begin; - - __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, - static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_sign(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parser_width::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = - __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); - - if (__begin != __end && *__begin != _CharT('}')) - __throw_format_error( - "The format-spec should consume the input or end with a '}'"); - - return __begin; - } - - /** Handles the post-parsing updates for the integer types. */ - _LIBCPP_HIDE_FROM_ABI constexpr void __handle_integer() noexcept { - __process_arithmetic_alignment(static_cast<_Flags&>(*this)); - } - - /** - * Handles the post-parsing updates for the character types. - * - * Sets the alignment and validates the format flags set for a character type. - * - * At the moment the validation for a character and a Boolean behave the - * same, but this may change in the future. - * Specifically at the moment the locale-specific form is allowed for the - * char output type, but it has no effect on the output. - */ - _LIBCPP_HIDE_FROM_ABI constexpr void __handle_char() { __handle_bool(); } - - /** - * Handles the post-parsing updates for the Boolean types. - * - * Sets the alignment and validates the format flags set for a Boolean type. - */ - _LIBCPP_HIDE_FROM_ABI constexpr void __handle_bool() { - if (this->__sign != _Flags::_Sign::__default) - __throw_format_error("A sign field isn't allowed in this format-spec"); - - if (this->__alternate_form) - __throw_format_error( - "An alternate form field isn't allowed in this format-spec"); - - if (this->__zero_padding) - __throw_format_error( - "A zero-padding field isn't allowed in this format-spec"); - - if (this->__alignment == _Flags::_Alignment::__default) - this->__alignment = _Flags::_Alignment::__left; - } -}; - -/** - * The parser for the std-format-spec. - * - * This implements the parser for the floating-point types. - * - * See @ref __parser_string. - */ -template -class _LIBCPP_TEMPLATE_VIS __parser_floating_point - : public __parser_width, // provides __width(|as_arg) - public __parser_precision, // provides __precision(|as_arg) - public __parser_fill_align<_CharT>, // provides __fill and uses __flags - public _Flags // provides __flags -{ -public: - using char_type = _CharT; - - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parse(__parse_ctx); - __process_arithmetic_alignment(static_cast<_Flags&>(*this)); - __process_display_type(); - return __it; - } -protected: - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __begin = __parse_ctx.begin(); - auto __end = __parse_ctx.end(); - if (__begin == __end) - return __begin; - - __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, - static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_sign(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parser_width::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = - __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); - - if (__begin != __end && *__begin != _CharT('}')) - __throw_format_error( - "The format-spec should consume the input or end with a '}'"); - - return __begin; - } - - /** Processes the parsed std-format-spec based on the parsed display type. */ - _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { - switch (this->__type) { - case _Flags::_Type::__default: - // When no precision specified then it keeps default since that - // formatting differs from the other types. - if (this->__has_precision_field()) - this->__type = _Flags::_Type::__general_lower_case; - break; - case _Flags::_Type::__float_hexadecimal_lower_case: - case _Flags::_Type::__float_hexadecimal_upper_case: - // Precision specific behavior will be handled later. - break; - case _Flags::_Type::__scientific_lower_case: - case _Flags::_Type::__scientific_upper_case: - case _Flags::_Type::__fixed_lower_case: - case _Flags::_Type::__fixed_upper_case: - case _Flags::_Type::__general_lower_case: - case _Flags::_Type::__general_upper_case: - if (!this->__has_precision_field()) { - // Set the default precision for the call to to_chars. - this->__precision = 6; - this->__precision_as_arg = false; - } - break; - - default: - __throw_format_error("The format-spec type has a type not supported for " - "a floating-point argument"); - } - } -}; - -/** - * The parser for the std-format-spec. - * - * This implements the parser for the pointer types. - * - * See @ref __parser_string. - */ -template -class _LIBCPP_TEMPLATE_VIS __parser_pointer : public __parser_width, // provides __width(|as_arg) - public __parser_fill_align<_CharT>, // provides __fill and uses __flags - public _Flags // provides __flags -{ -public: - using char_type = _CharT; - - _LIBCPP_HIDE_FROM_ABI constexpr __parser_pointer() { - // Implements LWG3612 Inconsistent pointer alignment in std::format. - // The issue's current status is "Tentatively Ready" and libc++ status is - // still experimental. - // - // TODO FMT Validate this with the final resolution of LWG3612. - this->__alignment = _Flags::_Alignment::__right; - } - - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __it = __parse(__parse_ctx); - __process_display_type(); - return __it; - } - -protected: - /** - * The low-level std-format-spec parse function. - * - * @pre __begin points at the beginning of the std-format-spec. This means - * directly after the ':'. - * @pre The std-format-spec parses the entire input, or the first unmatched - * character is a '}'. - * - * @returns The iterator pointing at the last parsed character. - */ - _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(auto& __parse_ctx) -> decltype(__parse_ctx.begin()) { - auto __begin = __parse_ctx.begin(); - auto __end = __parse_ctx.end(); - if (__begin == __end) - return __begin; - - __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this)); - if (__begin == __end) - return __begin; - - // An integer presentation type isn't defined in the Standard. - // Since a pointer is formatted as an integer it can be argued it's an - // integer presentation type. However there are two LWG-issues asserting it - // isn't an integer presentation type: - // - LWG3612 Inconsistent pointer alignment in std::format - // - LWG3644 std::format does not define "integer presentation type" - // - // There's a paper to make additional clarifications on the status of - // formatting pointers and proposes additional fields to be valid. That - // paper hasn't been reviewed by the Committee yet. - // - P2510 Formatting pointers - // - // The current implementation assumes formatting pointers isn't covered by - // "integer presentation type". - // TODO FMT Apply the LWG-issues/papers after approval/rejection by the Committee. - - __begin = __parser_width::__parse(__begin, __end, __parse_ctx); - if (__begin == __end) - return __begin; - - __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); - - if (__begin != __end && *__begin != _CharT('}')) - __throw_format_error("The format-spec should consume the input or end with a '}'"); - - return __begin; - } - - /** Processes the parsed std-format-spec based on the parsed display type. */ - _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__pointer; - break; - case _Flags::_Type::__pointer: - break; - default: - __throw_format_error("The format-spec type has a type not supported for a pointer argument"); - } - } -}; - -/** Helper struct returned from @ref __get_string_alignment. */ -template -struct _LIBCPP_TEMPLATE_VIS __string_alignment { - /** Points beyond the last character to write to the output. */ - const _CharT* __last; - /** - * The estimated number of columns in the output or 0. - * - * Only when the output needs to be aligned it's required to know the exact - * number of columns in the output. So if the formatted output has only a - * minimum width the exact size isn't important. It's only important to know - * the minimum has been reached. The minimum width is the width specified in - * the format-spec. - * - * For example in this code @code std::format("{:10}", MyString); @endcode - * the width estimation can stop once the algorithm has determined the output - * width is 10 columns. - * - * So if: - * * @ref __align == @c true the @ref __size is the estimated number of - * columns required. - * * @ref __align == @c false the @ref __size is the estimated number of - * columns required or 0 when the estimation algorithm stopped prematurely. - */ - ptrdiff_t __size; - /** - * Does the output need to be aligned. - * - * When alignment is needed the output algorithm needs to add the proper - * padding. Else the output algorithm just needs to copy the input up to - * @ref __last. - */ - bool __align; -}; - -#ifndef _LIBCPP_HAS_NO_UNICODE -namespace __detail { - -/** - * Unicode column width estimates. - * - * Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32. - * Depending on format the relation between the number of code units stored and - * the number of output columns differs. The first relation is the number of - * code units forming a code point. (The text assumes the code units are - * unsigned.) - * - UTF-8 The number of code units is between one and four. The first 127 - * Unicode code points match the ASCII character set. When the highest bit is - * set it means the code point has more than one code unit. - * - UTF-16: The number of code units is between 1 and 2. When the first - * code unit is in the range [0xd800,0xdfff) it means the code point uses two - * code units. - * - UTF-32: The number of code units is always one. - * - * The code point to the number of columns isn't well defined. The code uses the - * estimations defined in [format.string.std]/11. This list might change in the - * future. - * - * The algorithm of @ref __get_string_alignment uses two different scanners: - * - The simple scanner @ref __estimate_column_width_fast. This scanner assumes - * 1 code unit is 1 column. This scanner stops when it can't be sure the - * assumption is valid: - * - UTF-8 when the code point is encoded in more than 1 code unit. - * - UTF-16 and UTF-32 when the first multi-column code point is encountered. - * (The code unit's value is lower than 0xd800 so the 2 code unit encoding - * is irrelevant for this scanner.) - * Due to these assumptions the scanner is faster than the full scanner. It - * can process all text only containing ASCII. For UTF-16/32 it can process - * most (all?) European languages. (Note the set it can process might be - * reduced in the future, due to updates in the scanning rules.) - * - The full scanner @ref __estimate_column_width. This scanner, if needed, - * converts multiple code units into one code point then converts the code - * point to a column width. - * - * See also: - * - [format.string.general]/11 - * - https://en.wikipedia.org/wiki/UTF-8#Encoding - * - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF - */ - -/** - * The first 2 column code point. - * - * This is the point where the fast UTF-16/32 scanner needs to stop processing. - */ -inline constexpr uint32_t __two_column_code_point = 0x1100; - -/** Helper concept for an UTF-8 character type. */ -template -concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>; - -/** Helper concept for an UTF-16 character type. */ -template -concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>; - -/** Helper concept for an UTF-32 character type. */ -template -concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>; - -/** Helper concept for an UTF-16 or UTF-32 character type. */ -template -concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>; - -/** - * Converts a code point to the column width. - * - * The estimations are conforming to [format.string.general]/11 - * - * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8 - * character. - */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept { - _LIBCPP_ASSERT(__c < 0x1'0000, - "Use __column_width_4 or __column_width for larger values"); - - // clang-format off - return 1 + (__c >= 0x1100 && (__c <= 0x115f || - (__c >= 0x2329 && (__c <= 0x232a || - (__c >= 0x2e80 && (__c <= 0x303e || - (__c >= 0x3040 && (__c <= 0xa4cf || - (__c >= 0xac00 && (__c <= 0xd7a3 || - (__c >= 0xf900 && (__c <= 0xfaff || - (__c >= 0xfe10 && (__c <= 0xfe19 || - (__c >= 0xfe30 && (__c <= 0xfe6f || - (__c >= 0xff00 && (__c <= 0xff60 || - (__c >= 0xffe0 && (__c <= 0xffe6 - )))))))))))))))))))); - // clang-format on -} - -/** - * @overload - * - * This version expects a value greater than or equal to 0x1'0000, which is a - * 4-byte UTF-8 character. - */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexcept { - _LIBCPP_ASSERT(__c >= 0x1'0000, - "Use __column_width_3 or __column_width for smaller values"); - - // clang-format off - return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f || - (__c >= 0x1'f900 && (__c <= 0x1'f9ff || - (__c >= 0x2'0000 && (__c <= 0x2'fffd || - (__c >= 0x3'0000 && (__c <= 0x3'fffd - )))))))); - // clang-format on -} - -/** - * @overload - * - * The general case, accepting all values. - */ -_LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept { - if (__c < 0x1'0000) - return __column_width_3(__c); - - return __column_width_4(__c); -} - -/** - * Estimate the column width for the UTF-8 sequence using the fast algorithm. - */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__estimate_column_width_fast(const _CharT* __first, - const _CharT* __last) noexcept { - return _VSTD::find_if(__first, __last, - [](unsigned char __c) { return __c & 0x80; }); -} - -/** - * @overload - * - * The implementation for UTF-16/32. - */ -template <__utf16_or_32_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr const _CharT* -__estimate_column_width_fast(const _CharT* __first, - const _CharT* __last) noexcept { - return _VSTD::find_if(__first, __last, - [](uint32_t __c) { return __c >= 0x1100; }); -} - -template -struct _LIBCPP_TEMPLATE_VIS __column_width_result { - /** The number of output columns. */ - size_t __width; - /** - * The last parsed element. - * - * This limits the original output to fit in the wanted number of columns. - */ - const _CharT* __ptr; -}; - -/** - * Small helper to determine the width of malformed Unicode. - * - * @note This function's only needed for UTF-8. During scanning UTF-8 there - * are multiple place where it can be detected that the Unicode is malformed. - * UTF-16 only requires 1 test and UTF-32 requires no testing. - */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width_malformed(const _CharT* __first, const _CharT* __last, - size_t __maximum, size_t __result) noexcept { - size_t __size = __last - __first; - size_t __n = _VSTD::min(__size, __maximum); - return {__result + __n, __first + __n}; -} - -/** - * Determines the number of output columns needed to render the input. - * - * @note When the scanner encounters malformed Unicode it acts as-if every code - * unit at the end of the input is one output column. It's expected the output - * terminal will replace these malformed code units with a one column - * replacement characters. - * - * @param __first Points to the first element of the input range. - * @param __last Points beyond the last element of the input range. - * @param __maximum The maximum number of output columns. The returned number - * of estimated output columns will not exceed this value. - */ -template <__utf8_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; - - while (__first != __last) { - // Based on the number of leading 1 bits the number of code units in the - // code point can be determined. See - // https://en.wikipedia.org/wiki/UTF-8#Encoding - switch (_VSTD::countl_one(static_cast(*__first))) { - case 0: // 1-code unit encoding: all 1 column - ++__result; - ++__first; - break; - - case 2: // 2-code unit encoding: all 1 column - // Malformed Unicode. - if (__last - __first < 2) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - __first += 2; - ++__result; - break; - - case 3: // 3-code unit encoding: either 1 or 2 columns - // Malformed Unicode. - if (__last - __first < 3) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - { - uint32_t __c = static_cast(*__first++) & 0x0f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __result += __column_width_3(__c); - if (__result > __maximum) - return {__result - 2, __first - 3}; - } - break; - case 4: // 4-code unit encoding: either 1 or 2 columns - // Malformed Unicode. - if (__last - __first < 4) [[unlikely]] - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - { - uint32_t __c = static_cast(*__first++) & 0x07; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __c <<= 6; - __c |= static_cast(*__first++) & 0x3f; - __result += __column_width_4(__c); - if (__result > __maximum) - return {__result - 2, __first - 4}; - } - break; - default: - // Malformed Unicode. - return __estimate_column_width_malformed(__first, __last, __maximum, - __result); - } - - if (__result >= __maximum) - return {__result, __first}; - } - return {__result, __first}; -} - -template <__utf16_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; - - while (__first != __last) { - uint32_t __c = *__first; - // Is the code unit part of a surrogate pair? See - // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF - if (__c >= 0xd800 && __c <= 0xDfff) { - // Malformed Unicode. - if (__last - __first < 2) [[unlikely]] - return {__result + 1, __first + 1}; - - __c -= 0xd800; - __c <<= 10; - __c += (*(__first + 1) - 0xdc00); - __c += 0x10'000; - - __result += __column_width_4(__c); - if (__result > __maximum) - return {__result - 2, __first}; - __first += 2; - } else { - __result += __column_width_3(__c); - if (__result > __maximum) - return {__result - 2, __first}; - ++__first; - } - - if (__result >= __maximum) - return {__result, __first}; - } - - return {__result, __first}; -} - -template <__utf32_character _CharT> -_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> -__estimate_column_width(const _CharT* __first, const _CharT* __last, - size_t __maximum) noexcept { - size_t __result = 0; - - while (__first != __last) { - wchar_t __c = *__first; - __result += __column_width(__c); - - if (__result > __maximum) - return {__result - 2, __first}; - - ++__first; - if (__result >= __maximum) - return {__result, __first}; - } - - return {__result, __first}; -} - -} // namespace __detail - -template -_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> -__get_string_alignment(const _CharT* __first, const _CharT* __last, - ptrdiff_t __width, ptrdiff_t __precision) noexcept { - _LIBCPP_ASSERT(__width != 0 || __precision != -1, - "The function has no effect and shouldn't be used"); - - // TODO FMT There might be more optimizations possible: - // If __precision == __format::__number_max and the encoding is: - // * UTF-8 : 4 * (__last - __first) >= __width - // * UTF-16 : 2 * (__last - __first) >= __width - // * UTF-32 : (__last - __first) >= __width - // In these cases it's certain the output is at least the requested width. - // It's unknown how often this happens in practice. For now the improvement - // isn't implemented. - - /* - * First assume there are no special Unicode code units in the input. - * - Apply the precision (this may reduce the size of the input). When - * __precison == -1 this step is omitted. - * - Scan for special code units in the input. - * If our assumption was correct the __pos will be at the end of the input. - */ - const ptrdiff_t __length = __last - __first; - const _CharT* __limit = - __first + - (__precision == -1 ? __length : _VSTD::min(__length, __precision)); - ptrdiff_t __size = __limit - __first; - const _CharT* __pos = - __detail::__estimate_column_width_fast(__first, __limit); - - if (__pos == __limit) - return {__limit, __size, __size < __width}; - - /* - * Our assumption was wrong, there are special Unicode code units. - * The range [__first, __pos) contains a set of code units with the - * following property: - * Every _CharT in the range will be rendered in 1 column. - * - * If there's no maximum width and the parsed size already exceeds the - * minimum required width. The real size isn't important. So bail out. - */ - if (__precision == -1 && (__pos - __first) >= __width) - return {__last, 0, false}; - - /* If there's a __precision, truncate the output to that width. */ - ptrdiff_t __prefix = __pos - __first; - if (__precision != -1) { - _LIBCPP_ASSERT(__precision > __prefix, "Logic error."); - auto __lengh_info = __detail::__estimate_column_width( - __pos, __last, __precision - __prefix); - __size = __lengh_info.__width + __prefix; - return {__lengh_info.__ptr, __size, __size < __width}; - } - - /* Else use __width to determine the number of required padding characters. */ - _LIBCPP_ASSERT(__width > __prefix, "Logic error."); - /* - * The column width is always one or two columns. For the precision the wanted - * column width is the maximum, for the width it's the minimum. Using the - * width estimation with its truncating behavior will result in the wrong - * result in the following case: - * - The last code unit processed requires two columns and exceeds the - * maximum column width. - * By increasing the __maximum by one avoids this issue. (It means it may - * pass one code point more than required to determine the proper result; - * that however isn't a problem for the algorithm.) - */ - size_t __maximum = 1 + __width - __prefix; - auto __lengh_info = - __detail::__estimate_column_width(__pos, __last, __maximum); - if (__lengh_info.__ptr != __last) { - // Consumed the width number of code units. The exact size of the string - // is unknown. We only know we don't need to align the output. - _LIBCPP_ASSERT(static_cast(__lengh_info.__width + __prefix) >= - __width, - "Logic error"); - return {__last, 0, false}; - } - - __size = __lengh_info.__width + __prefix; - return {__last, __size, __size < __width}; -} -#else // _LIBCPP_HAS_NO_UNICODE -template -_LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> -__get_string_alignment(const _CharT* __first, const _CharT* __last, - ptrdiff_t __width, ptrdiff_t __precision) noexcept { - const ptrdiff_t __length = __last - __first; - const _CharT* __limit = - __first + - (__precision == -1 ? __length : _VSTD::min(__length, __precision)); - ptrdiff_t __size = __limit - __first; - return {__limit, __size, __size < __width}; -} -#endif // _LIBCPP_HAS_NO_UNICODE - -} // namespace __format_spec - -# endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H diff --git a/include/__function_like.h b/include/__function_like.h new file mode 100644 index 000000000..8a3597bac --- /dev/null +++ b/include/__function_like.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___ITERATOR_FUNCTION_LIKE_H +#define _LIBCPP___ITERATOR_FUNCTION_LIKE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +// Per [range.iter.ops.general] and [algorithms.requirements], functions in namespace std::ranges +// can't be found by ADL and inhibit ADL when found by unqualified lookup. The easiest way to +// facilitate this is to use function objects. +// +// Since these are still standard library functions, we use `__function_like` to eliminate most of +// the properties that function objects get by default (e.g. semiregularity, addressability), to +// limit the surface area of the unintended public interface, so as to curb the effect of Hyrum's +// law. +struct __function_like { + __function_like() = delete; + __function_like(__function_like const&) = delete; + __function_like& operator=(__function_like const&) = delete; + + void operator&() const = delete; + + struct __tag { }; + +protected: + constexpr explicit __function_like(__tag) noexcept {} + ~__function_like() = default; +}; +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_FUNCTION_LIKE_H diff --git a/include/__functional/bind.h b/include/__functional/bind.h index 11a51e595..79dfad723 100644 --- a/include/__functional/bind.h +++ b/include/__functional/bind.h @@ -11,8 +11,8 @@ #define _LIBCPP___FUNCTIONAL_BIND_H #include <__config> -#include <__functional/invoke.h> #include <__functional/weak_result_type.h> +#include <__functional/invoke.h> #include #include #include @@ -23,28 +23,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template -struct is_bind_expression : _If< - _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, - false_type, - is_bind_expression::type> -> {}; +template struct __is_bind_expression : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_bind_expression + : public __is_bind_expression::type> {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; +_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; #endif -template -struct is_placeholder : _If< - _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, - integral_constant, - is_placeholder::type> -> {}; +template struct __is_placeholder : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS is_placeholder + : public __is_placeholder::type> {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; +_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; #endif namespace placeholders @@ -64,22 +58,22 @@ _LIBCPP_FUNC_VIS extern const __ph<8> _8; _LIBCPP_FUNC_VIS extern const __ph<9> _9; _LIBCPP_FUNC_VIS extern const __ph<10> _10; #else -/* inline */ constexpr __ph<1> _1{}; -/* inline */ constexpr __ph<2> _2{}; -/* inline */ constexpr __ph<3> _3{}; -/* inline */ constexpr __ph<4> _4{}; -/* inline */ constexpr __ph<5> _5{}; -/* inline */ constexpr __ph<6> _6{}; -/* inline */ constexpr __ph<7> _7{}; -/* inline */ constexpr __ph<8> _8{}; -/* inline */ constexpr __ph<9> _9{}; -/* inline */ constexpr __ph<10> _10{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -} // namespace placeholders +} // placeholders template -struct is_placeholder > +struct __is_placeholder > : public integral_constant {}; @@ -103,7 +97,7 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) template inline _LIBCPP_INLINE_VISIBILITY -typename __enable_if_t +typename _EnableIf < is_bind_expression<_Ti>::value, __invoke_of<_Ti&, _Uj...> @@ -310,7 +304,7 @@ public: }; template -struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; +struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; template class __bind_r @@ -365,7 +359,7 @@ public: }; template -struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; +struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 diff --git a/include/__functional/bind_back.h b/include/__functional/bind_back.h deleted file mode 100644 index a0089e1fb..000000000 --- a/include/__functional/bind_back.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FUNCTIONAL_BIND_BACK_H -#define _LIBCPP___FUNCTIONAL_BIND_BACK_H - -#include <__config> -#include <__functional/invoke.h> -#include <__functional/perfect_forward.h> -#include <__utility/forward.h> -#include <__utility/integer_sequence.h> -#include -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -template > -struct __bind_back_op; - -template -struct __bind_back_op<_NBound, index_sequence<_Ip...>> { - template - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const - noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))) - -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)) - { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); } -}; - -template -struct __bind_back_t : __perfect_forward<__bind_back_op>, _Fn, _BoundArgs> { - using __perfect_forward<__bind_back_op>, _Fn, _BoundArgs>::__perfect_forward; -}; - -template , _Fn>, - is_move_constructible>, - is_constructible, _Args>..., - is_move_constructible>... - >::value ->> -_LIBCPP_HIDE_FROM_ABI -constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) - noexcept(noexcept(__bind_back_t, tuple...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))) - -> decltype( __bind_back_t, tuple...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))) - { return __bind_back_t, tuple...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); } - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FUNCTIONAL_BIND_BACK_H diff --git a/include/__functional/bind_front.h b/include/__functional/bind_front.h index 31397ec54..8690499f2 100644 --- a/include/__functional/bind_front.h +++ b/include/__functional/bind_front.h @@ -11,8 +11,8 @@ #define _LIBCPP___FUNCTIONAL_BIND_FRONT_H #include <__config> -#include <__functional/invoke.h> #include <__functional/perfect_forward.h> +#include <__functional/invoke.h> #include #include @@ -24,31 +24,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -struct __bind_front_op { - template - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Args&& ...__args) const - noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) - -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) - { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } +struct __bind_front_op +{ + template + constexpr static auto __call(_Args&&... __args) + noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) + -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) + { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } }; -template -struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { - using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward; -}; - -template , _Fn>, - is_move_constructible>, - is_constructible, _Args>..., - is_move_constructible>... - >::value ->> -_LIBCPP_HIDE_FROM_ABI -constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { - return __bind_front_t, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); +template, _Fn>, + is_move_constructible>, + is_constructible, _Args>..., + is_move_constructible>... + >::value>> +constexpr auto bind_front(_Fn&& __f, _Args&&... __args) +{ + return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f), + _VSTD::forward<_Args>(__args)...); } #endif // _LIBCPP_STD_VER > 17 diff --git a/include/__functional/compose.h b/include/__functional/compose.h deleted file mode 100644 index d9d75875c..000000000 --- a/include/__functional/compose.h +++ /dev/null @@ -1,52 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___FUNCTIONAL_COMPOSE_H -#define _LIBCPP___FUNCTIONAL_COMPOSE_H - -#include <__config> -#include <__functional/invoke.h> -#include <__functional/perfect_forward.h> -#include <__utility/forward.h> -#include - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -struct __compose_op { - template - _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const - noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)))) - -> decltype( _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...))) - { return _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)); } -}; - -template -struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> { - using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward; -}; - -template -_LIBCPP_HIDE_FROM_ABI -constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) - noexcept(noexcept(__compose_t, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)))) - -> decltype( __compose_t, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2))) - { return __compose_t, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)); } - -#endif // _LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H diff --git a/include/__functional/function.h b/include/__functional/function.h index 6bb7eb7e8..ba629e1d1 100644 --- a/include/__functional/function.h +++ b/include/__functional/function.h @@ -11,12 +11,10 @@ #define _LIBCPP___FUNCTIONAL_FUNCTION_H #include <__config> -#include <__debug> #include <__functional/binary_function.h> #include <__functional/invoke.h> #include <__functional/unary_function.h> #include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/shared_ptr.h> @@ -36,17 +34,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_EXCEPTION_ABI bad_function_call : public exception { -public: -// Note that when a key function is not used, every translation unit that uses -// bad_function_call will end up containing a weak definition of the vtable and -// typeinfo. #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION +public: virtual ~bad_function_call() _NOEXCEPT; -#else - virtual ~bad_function_call() _NOEXCEPT {} -#endif -#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE virtual const char* what() const _NOEXCEPT; #endif }; @@ -135,8 +126,8 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> __compressed_pair<_Fp, _Ap> __f_; public: - typedef _LIBCPP_NODEBUG _Fp _Target; - typedef _LIBCPP_NODEBUG _Ap _Alloc; + typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; + typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc; _LIBCPP_INLINE_VISIBILITY const _Target& __target() const { return __f_.first(); } @@ -213,7 +204,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { _Fp __f_; public: - typedef _LIBCPP_NODEBUG _Fp _Target; + typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; _LIBCPP_INLINE_VISIBILITY const _Target& __target() const { return __f_; } @@ -361,7 +352,7 @@ const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { if (__ti == typeid(_Fp)) - return _VSTD::addressof(__f_.__target()); + return &__f_.__target(); return nullptr; } @@ -947,7 +938,7 @@ public: #endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC -} // namespace __function +} // __function template class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> @@ -1053,7 +1044,7 @@ public: #endif // _LIBCPP_NO_RTTI }; -#if _LIBCPP_STD_VER >= 17 +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>; @@ -1098,7 +1089,7 @@ struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { usin template::type> function(_Fp) -> function<_Stripped>; -#endif // _LIBCPP_STD_VER >= 17 +#endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES template function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {} @@ -1393,7 +1384,7 @@ const void* __func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const { if (__ti == typeid(_Fp)) - return _VSTD::addressof(__f_.first()); + return &__f_.first(); return (const void*)0; } @@ -1664,7 +1655,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const #endif // _LIBCPP_NO_RTTI -} // namespace __function +} // __function template class _LIBCPP_TEMPLATE_VIS function<_Rp()> @@ -1718,11 +1709,13 @@ public: // 20.7.16.2.3, function capacity: _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} +private: + // deleted overloads close possible hole in the type system template - bool operator==(const function<_R2()>&) const = delete; + bool operator==(const function<_R2()>&) const;// = delete; template - bool operator!=(const function<_R2()>&) const = delete; - + bool operator!=(const function<_R2()>&) const;// = delete; +public: // 20.7.16.2.4, function invocation: _Rp operator()() const; @@ -1996,11 +1989,13 @@ public: // 20.7.16.2.3, function capacity: _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} +private: + // deleted overloads close possible hole in the type system template - bool operator==(const function<_R2(_B0)>&) const = delete; + bool operator==(const function<_R2(_B0)>&) const;// = delete; template - bool operator!=(const function<_R2(_B0)>&) const = delete; - + bool operator!=(const function<_R2(_B0)>&) const;// = delete; +public: // 20.7.16.2.4, function invocation: _Rp operator()(_A0) const; @@ -2274,11 +2269,13 @@ public: // 20.7.16.2.3, function capacity: _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} +private: + // deleted overloads close possible hole in the type system template - bool operator==(const function<_R2(_B0, _B1)>&) const = delete; + bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete; template - bool operator!=(const function<_R2(_B0, _B1)>&) const = delete; - + bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete; +public: // 20.7.16.2.4, function invocation: _Rp operator()(_A0, _A1) const; @@ -2551,11 +2548,13 @@ public: // 20.7.16.2.3, function capacity: _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} +private: + // deleted overloads close possible hole in the type system template - bool operator==(const function<_R2(_B0, _B1, _B2)>&) const = delete; + bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; template - bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const = delete; - + bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; +public: // 20.7.16.2.4, function invocation: _Rp operator()(_A0, _A1, _A2) const; diff --git a/include/__functional/hash.h b/include/__functional/hash.h index de0c161f4..ebcbbad13 100644 --- a/include/__functional/hash.h +++ b/include/__functional/hash.h @@ -16,9 +16,9 @@ #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/swap.h> -#include #include #include +#include #include #include @@ -26,6 +26,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -561,7 +564,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP #endif // _LIBCPP_HAS_NO_UNICODE_CHARS -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash @@ -577,7 +579,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast(__v);} }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> @@ -838,33 +839,35 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP #ifndef _LIBCPP_CXX03_LANG template -using __check_hash_requirements _LIBCPP_NODEBUG = integral_constant::value && is_move_constructible<_Hash>::value && __invokable_r::value >; template > -using __has_enabled_hash _LIBCPP_NODEBUG = integral_constant::value && is_default_constructible<_Hash>::value >; #if _LIBCPP_STD_VER > 14 template -using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; +using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type; template -using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, +using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type, typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type >; #else template -using __enable_hash_helper _LIBCPP_NODEBUG = _Type; +using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type; #endif #endif // !_LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___FUNCTIONAL_HASH_H diff --git a/include/__functional/mem_fn.h b/include/__functional/mem_fn.h index 0ec842334..1fa070a42 100644 --- a/include/__functional/mem_fn.h +++ b/include/__functional/mem_fn.h @@ -11,9 +11,9 @@ #define _LIBCPP___FUNCTIONAL_MEM_FN_H #include <__config> +#include <__functional/weak_result_type.h> #include <__functional/binary_function.h> #include <__functional/invoke.h> -#include <__functional/weak_result_type.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/include/__functional/mem_fun_ref.h b/include/__functional/mem_fun_ref.h index 830936c1b..4616da0b0 100644 --- a/include/__functional/mem_fun_ref.h +++ b/include/__functional/mem_fun_ref.h @@ -11,8 +11,8 @@ #define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H #include <__config> -#include <__functional/binary_function.h> #include <__functional/unary_function.h> +#include <__functional/binary_function.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/include/__functional/not_fn.h b/include/__functional/not_fn.h index 36aab2eb7..632be5ff0 100644 --- a/include/__functional/not_fn.h +++ b/include/__functional/not_fn.h @@ -11,8 +11,8 @@ #define _LIBCPP___FUNCTIONAL_NOT_FN_H #include <__config> -#include <__functional/invoke.h> #include <__functional/perfect_forward.h> +#include <__functional/invoke.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -23,27 +23,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 -struct __not_fn_op { - template - _LIBCPP_HIDE_FROM_ABI - _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const - noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) - -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) - { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } +struct __not_fn_op +{ + template + static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args) + noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) + -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) + { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } }; -template -struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> { - using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward; -}; - -template , _Fn> && - is_move_constructible_v> ->> -_LIBCPP_HIDE_FROM_ABI -_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) { - return __not_fn_t>(_VSTD::forward<_Fn>(__f)); +template, _Fn> && + is_move_constructible_v<_Fn>>> +_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) +{ + return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f)); } #endif // _LIBCPP_STD_VER > 14 diff --git a/include/__functional/operations.h b/include/__functional/operations.h index 0c7c6d4fc..667d17988 100644 --- a/include/__functional/operations.h +++ b/include/__functional/operations.h @@ -53,9 +53,9 @@ struct _LIBCPP_TEMPLATE_VIS plus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -90,9 +90,9 @@ struct _LIBCPP_TEMPLATE_VIS minus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -127,9 +127,9 @@ struct _LIBCPP_TEMPLATE_VIS multiplies template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -164,9 +164,9 @@ struct _LIBCPP_TEMPLATE_VIS divides template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -201,9 +201,9 @@ struct _LIBCPP_TEMPLATE_VIS modulus template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -237,9 +237,9 @@ struct _LIBCPP_TEMPLATE_VIS negate template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - noexcept(noexcept(- _VSTD::forward<_Tp>(__x))) - -> decltype( - _VSTD::forward<_Tp>(__x)) - { return - _VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) + -> decltype (- _VSTD::forward<_Tp>(__x)) + { return - _VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -276,9 +276,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_and template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -307,9 +307,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_not template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - noexcept(noexcept(~_VSTD::forward<_Tp>(__x))) - -> decltype( ~_VSTD::forward<_Tp>(__x)) - { return ~_VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) + -> decltype (~_VSTD::forward<_Tp>(__x)) + { return ~_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -344,9 +344,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_or template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -381,9 +381,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -420,9 +420,9 @@ struct _LIBCPP_TEMPLATE_VIS equal_to template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -457,9 +457,9 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -494,9 +494,9 @@ struct _LIBCPP_TEMPLATE_VIS less template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -531,9 +531,9 @@ struct _LIBCPP_TEMPLATE_VIS less_equal template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -568,9 +568,9 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -605,9 +605,9 @@ struct _LIBCPP_TEMPLATE_VIS greater template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -644,9 +644,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_and template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif @@ -680,9 +680,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_not template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const - noexcept(noexcept(!_VSTD::forward<_Tp>(__x))) - -> decltype( !_VSTD::forward<_Tp>(__x)) - { return !_VSTD::forward<_Tp>(__x); } + _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) + -> decltype (!_VSTD::forward<_Tp>(__x)) + { return !_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif @@ -717,9 +717,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_or template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const - noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) - -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif diff --git a/include/__functional/perfect_forward.h b/include/__functional/perfect_forward.h index 308b304a7..a5678e159 100644 --- a/include/__functional/perfect_forward.h +++ b/include/__functional/perfect_forward.h @@ -11,11 +11,9 @@ #define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H #include <__config> -#include <__utility/declval.h> -#include <__utility/forward.h> -#include <__utility/move.h> #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -25,68 +23,63 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 -template +template::value>::type> struct __perfect_forward_impl; -template -struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> { -private: +template +struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>> +{ tuple<_Bound...> __bound_; -public: - template , _BoundArgs&&...> - >> - explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound) - : __bound_(_VSTD::forward<_BoundArgs>(__bound)...) - { } + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) & + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} - __perfect_forward_impl(__perfect_forward_impl const&) = default; - __perfect_forward_impl(__perfect_forward_impl&&) = default; + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const& + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} - __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default; - __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default; + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) && + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...);} - template >> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & - noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))) - -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)) - { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); } + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&& + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...);} - template >> - auto operator()(_Args&&...) & = delete; + template>::type, + class = _EnableIf>> + constexpr __perfect_forward_impl(__perfect_forward_impl const& __other) + : __bound_(__other.__bound_) {} - template >> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& - noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))) - -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)) - { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); } + template>::type, + class = _EnableIf>> + constexpr __perfect_forward_impl(__perfect_forward_impl && __other) + : __bound_(_VSTD::move(__other.__bound_)) {} - template >> - auto operator()(_Args&&...) const& = delete; - - template >> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && - noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))) - -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)) - { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); } - - template >> - auto operator()(_Args&&...) && = delete; - - template >> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& - noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))) - -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)) - { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); } - - template >> - auto operator()(_Args&&...) const&& = delete; + template + explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) : + __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { } }; -// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require]. -template -using __perfect_forward = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>; +template +using __perfect_forward = + __perfect_forward_impl<_Op, __tuple_types...>>; #endif // _LIBCPP_STD_VER > 14 diff --git a/include/__functional/ranges_operations.h b/include/__functional/ranges_operations.h index a0ea7ccaf..777c53525 100644 --- a/include/__functional/ranges_operations.h +++ b/include/__functional/ranges_operations.h @@ -20,8 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - +#if !defined(_LIBCPP_HAS_NO_RANGES) namespace ranges { struct equal_to { @@ -91,7 +90,7 @@ struct greater_equal { }; } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD diff --git a/include/__functional/reference_wrapper.h b/include/__functional/reference_wrapper.h index d04d51568..09f4a6494 100644 --- a/include/__functional/reference_wrapper.h +++ b/include/__functional/reference_wrapper.h @@ -34,16 +34,25 @@ public: private: type* __f_; +#ifndef _LIBCPP_CXX03_LANG static void __fun(_Tp&) _NOEXCEPT; static void __fun(_Tp&&) = delete; +#endif public: - template ::value, decltype(__fun(declval<_Up>())) > > + // construct/copy/destroy +#ifdef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + reference_wrapper(type& __f) _NOEXCEPT + : __f_(_VSTD::addressof(__f)) {} +#else + template ::value, decltype(__fun(declval<_Up>())) >> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) { type& __f = static_cast<_Up&&>(__u); __f_ = _VSTD::addressof(__f); } +#endif // access _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -167,7 +176,7 @@ public: #endif // _LIBCPP_CXX03_LANG }; -#if _LIBCPP_STD_VER > 14 +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; #endif @@ -185,7 +194,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference_wrapper<_Tp> ref(reference_wrapper<_Tp> __t) _NOEXCEPT { - return __t; + return _VSTD::ref(__t.get()); } template @@ -201,11 +210,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference_wrapper cref(reference_wrapper<_Tp> __t) _NOEXCEPT { - return __t; + return _VSTD::cref(__t.get()); } +#ifndef _LIBCPP_CXX03_LANG template void ref(const _Tp&&) = delete; template void cref(const _Tp&&) = delete; +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/include/__functional/unary_function.h b/include/__functional/unary_function.h index 499f99646..8084ef4b0 100644 --- a/include/__functional/unary_function.h +++ b/include/__functional/unary_function.h @@ -15,6 +15,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -26,4 +29,6 @@ struct _LIBCPP_TEMPLATE_VIS unary_function _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H diff --git a/include/__functional/unwrap_ref.h b/include/__functional/unwrap_ref.h index dc309add9..4d091ec35 100644 --- a/include/__functional/unwrap_ref.h +++ b/include/__functional/unwrap_ref.h @@ -15,16 +15,19 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template -struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; }; +struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; template class reference_wrapper; template -struct __unwrap_reference > { typedef _LIBCPP_NODEBUG _Tp& type; }; +struct __unwrap_reference > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; template struct decay; @@ -54,4 +57,6 @@ struct __unwrap_ref_decay _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H diff --git a/include/__functional/weak_result_type.h b/include/__functional/weak_result_type.h index 32b1e0b1c..2ee85acf1 100644 --- a/include/__functional/weak_result_type.h +++ b/include/__functional/weak_result_type.h @@ -89,7 +89,7 @@ struct __weak_result_type_imp // bool is true : public __maybe_derive_from_unary_function<_Tp>, public __maybe_derive_from_binary_function<_Tp> { - typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type; + typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; }; template @@ -110,19 +110,19 @@ struct __weak_result_type template struct __weak_result_type<_Rp ()> { - typedef _LIBCPP_NODEBUG _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; template struct __weak_result_type<_Rp (&)()> { - typedef _LIBCPP_NODEBUG _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; template struct __weak_result_type<_Rp (*)()> { - typedef _LIBCPP_NODEBUG _Rp result_type; + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; }; // 1 argument case diff --git a/include/__hash_table b/include/__hash_table index adc732cff..df0f7c80d 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -288,7 +288,9 @@ public: typedef typename _NodeTypes::__node_value_type_pointer pointer; _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) { - _VSTD::__debug_db_insert_i(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } #if _LIBCPP_DEBUG_LEVEL == 2 @@ -296,7 +298,7 @@ public: __hash_iterator(const __hash_iterator& __i) : __node_(__i.__node_) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY @@ -308,9 +310,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator=(const __hash_iterator& __i) { - if (this != _VSTD::addressof(__i)) + if (this != &__i) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; } return *this; @@ -398,7 +400,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) { - _VSTD::__debug_db_insert_i(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } _LIBCPP_INLINE_VISIBILITY @@ -406,7 +410,7 @@ public: : __node_(__x.__node_) { #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); + __get_db()->__iterator_copy(this, &__x); #endif } @@ -415,7 +419,7 @@ public: __hash_const_iterator(const __hash_const_iterator& __i) : __node_(__i.__node_) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY @@ -427,9 +431,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator=(const __hash_const_iterator& __i) { - if (this != _VSTD::addressof(__i)) + if (this != &__i) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; } return *this; @@ -513,7 +517,9 @@ public: typedef typename _NodeTypes::__node_value_type_pointer pointer; _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) { - _VSTD::__debug_db_insert_i(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } #if _LIBCPP_DEBUG_LEVEL == 2 @@ -523,7 +529,7 @@ public: __bucket_(__i.__bucket_), __bucket_count_(__i.__bucket_count_) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY @@ -535,9 +541,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator=(const __hash_local_iterator& __i) { - if (this != _VSTD::addressof(__i)) + if (this != &__i) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; __bucket_ = __i.__bucket_; __bucket_count_ = __i.__bucket_count_; @@ -645,7 +651,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) { - _VSTD::__debug_db_insert_i(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } _LIBCPP_INLINE_VISIBILITY @@ -655,7 +663,7 @@ public: __bucket_count_(__x.__bucket_count_) { #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); + __get_db()->__iterator_copy(this, &__x); #endif } @@ -666,7 +674,7 @@ public: __bucket_(__i.__bucket_), __bucket_count_(__i.__bucket_count_) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); } _LIBCPP_INLINE_VISIBILITY @@ -678,9 +686,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) { - if (this != _VSTD::addressof(__i)) + if (this != &__i) { - __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); + __get_db()->__iterator_copy(this, &__i); __node_ = __i.__node_; __bucket_ = __i.__bucket_; __bucket_count_ = __i.__bucket_count_; @@ -1533,7 +1541,7 @@ template __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) { - if (this != _VSTD::addressof(__u)) + if (this != &__u) { __copy_assign_alloc(__u); hash_function() = __u.hash_function(); @@ -1615,7 +1623,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __u.size() = 0; } #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->swap(this, _VSTD::addressof(__u)); + __get_db()->swap(this, &__u); #endif } @@ -2021,9 +2029,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( const_iterator __p, __node_pointer __cp) { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered container"); +#endif if (__p != end() && key_eq()(*__p, __cp->__value_)) { __next_pointer __np = __p.__node_; @@ -2148,9 +2158,11 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( const_iterator __p, _Args&&... __args) { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, - "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" - " referring to this unordered container"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" + " referring to this unordered container"); +#endif __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); iterator __r = __node_insert_multi(__p, __h.get()); __h.release(); @@ -2336,7 +2348,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) size_type __chash = __constrain_hash(__cp->__hash(), __nbc); __bucket_list_[__chash] = __pp; size_type __phash = __chash; - for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr; + for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr; __cp = __pp->__next_) { __chash = __constrain_hash(__cp->__hash(), __nbc); @@ -2472,12 +2484,12 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { __next_pointer __np = __p.__node_; - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, - "unordered container erase(iterator) called with an iterator not" - " referring to this container"); - _LIBCPP_DEBUG_ASSERT(__p != end(), - "unordered container erase(iterator) called with a non-dereferenceable iterator"); #if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered container erase(iterator) called with an iterator not" + " referring to this container"); + _LIBCPP_ASSERT(__p != end(), + "unordered container erase(iterator) called with a non-dereferenceable iterator"); iterator __r(__np, this); #else iterator __r(__np); @@ -2492,12 +2504,14 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this, - "unordered container::erase(iterator, iterator) called with an iterator not" - " referring to this container"); - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this, - "unordered container::erase(iterator, iterator) called with an iterator not" - " referring to this container"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, + "unordered container::erase(iterator, iterator) called with an iterator not" + " referring to this container"); + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, + "unordered container::erase(iterator, iterator) called with an iterator not" + " referring to this container"); +#endif for (const_iterator __p = __first; __first != __last; __p = __first) { ++__first; @@ -2727,7 +2741,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = __u.__p1_.first().__ptr(); #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->swap(this, _VSTD::addressof(__u)); + __get_db()->swap(this, &__u); #endif } @@ -2744,7 +2758,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const { for (__np = __np->__next_; __np != nullptr && __constrain_hash(__np->__hash(), __bc) == __n; - __np = __np->__next_, (void) ++__r) + __np = __np->__next_, ++__r) ; } return __r; diff --git a/include/__iterator/access.h b/include/__iterator/access.h index 5e0d6b351..c0576b459 100644 --- a/include/__iterator/access.h +++ b/include/__iterator/access.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -126,4 +129,6 @@ end(const _Cp& __c) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ACCESS_H diff --git a/include/__iterator/advance.h b/include/__iterator/advance.h index d74d6b8b9..47bce1ddf 100644 --- a/include/__iterator/advance.h +++ b/include/__iterator/advance.h @@ -12,12 +12,13 @@ #include <__config> #include <__debug> +#include <__function_like.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__utility/move.h> -#include #include +#include #include #include @@ -25,6 +26,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -54,7 +58,7 @@ void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_t template < class _InputIter, class _Distance, class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), - class = __enable_if_t::value> > + class = _EnableIf::value> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 void advance(_InputIter& __i, _Distance __orig_n) { typedef typename iterator_traits<_InputIter>::difference_type _Difference; @@ -64,15 +68,18 @@ void advance(_InputIter& __i, _Distance __orig_n) { _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); } -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -// [range.iter.op.advance] +#if !defined(_LIBCPP_HAS_NO_RANGES) namespace ranges { -namespace __advance { - -struct __fn { +// [range.iter.op.advance] +struct __advance_fn final : private __function_like { private: + template + _LIBCPP_HIDE_FROM_ABI + static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { + return __a < 0 ? (__a <= __b) : (__a >= __b); + } + template _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { @@ -92,6 +99,8 @@ private: } public: + constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {} + // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. template _LIBCPP_HIDE_FROM_ABI @@ -149,12 +158,6 @@ public: // If `S` and `I` model `sized_sentinel_for`: if constexpr (sized_sentinel_for<_Sp, _Ip>) { // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. - // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign. - auto __magnitude_geq = [](auto __a, auto __b) { - return __a == 0 ? __b == 0 : - __a > 0 ? __a >= __b : - __a <= __b; - }; if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) { (*this)(__i, __bound); return __n - __M; @@ -185,15 +188,13 @@ public: } }; -} // namespace __advance - -inline namespace __cpo { - inline constexpr auto advance = __advance::__fn{}; -} // namespace __cpo +inline constexpr auto advance = __advance_fn(__function_like::__tag()); } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ADVANCE_H diff --git a/include/__iterator/back_insert_iterator.h b/include/__iterator/back_insert_iterator.h index 844babe5c..f34cb863b 100644 --- a/include/__iterator/back_insert_iterator.h +++ b/include/__iterator/back_insert_iterator.h @@ -21,6 +21,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -45,20 +48,20 @@ public: typedef void reference; typedef _Container container_type; - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) {container->push_back(__value_); return *this;} #ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) {container->push_back(_VSTD::move(__value_)); return *this;} #endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} }; template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator<_Container> back_inserter(_Container& __x) { @@ -67,4 +70,6 @@ back_inserter(_Container& __x) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H diff --git a/include/__iterator/common_iterator.h b/include/__iterator/common_iterator.h index 68309ee08..fb01d8bd4 100644 --- a/include/__iterator/common_iterator.h +++ b/include/__iterator/common_iterator.h @@ -25,14 +25,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -concept __can_use_postfix_proxy = - constructible_from, iter_reference_t<_Iter>> && - move_constructible>; +#if !defined(_LIBCPP_HAS_NO_RANGES) template _Sent> requires (!same_as<_Iter, _Sent> && copyable<_Iter>) @@ -46,7 +44,7 @@ class common_iterator { : __value(_VSTD::move(__x)) {} public: - constexpr const iter_value_t<_Iter>* operator->() const noexcept { + const iter_value_t<_Iter>* operator->() const { return _VSTD::addressof(__value); } }; @@ -59,7 +57,11 @@ class common_iterator { : __value(_VSTD::forward>(__x)) {} public: - constexpr const iter_value_t<_Iter>& operator*() const noexcept { + constexpr static bool __valid_for_iter = + constructible_from, iter_reference_t<_Iter>> && + move_constructible>; + + const iter_value_t<_Iter>& operator*() const { return __value; } }; @@ -76,7 +78,7 @@ public: requires convertible_to && convertible_to constexpr common_iterator(const common_iterator<_I2, _S2>& __other) : __hold_([&]() -> variant<_Iter, _Sent> { - _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Attempted to construct from a valueless common_iterator"); + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator."); if (__other.__hold_.index() == 0) return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)}; return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)}; @@ -86,7 +88,7 @@ public: requires convertible_to && convertible_to && assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&> common_iterator& operator=(const common_iterator<_I2, _S2>& __other) { - _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Attempted to assign from a valueless common_iterator"); + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator."); auto __idx = __hold_.index(); auto __other_idx = __other.__hold_.index(); @@ -106,16 +108,18 @@ public: return *this; } - constexpr decltype(auto) operator*() + decltype(auto) operator*() { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); return *_VSTD::__unchecked_get<_Iter>(__hold_); } - constexpr decltype(auto) operator*() const + decltype(auto) operator*() const requires __dereferenceable { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); return *_VSTD::__unchecked_get<_Iter>(__hold_); } @@ -126,7 +130,9 @@ public: is_reference_v> || constructible_from, iter_reference_t<_I2>>) { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) { return _VSTD::__unchecked_get<_Iter>(__hold_); } else if constexpr (is_reference_v>) { @@ -138,18 +144,21 @@ public: } common_iterator& operator++() { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this; } decltype(auto) operator++(int) { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); + if constexpr (forward_iterator<_Iter>) { auto __tmp = *this; ++*this; return __tmp; } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || - !__can_use_postfix_proxy<_Iter>) { + !__postfix_proxy::__valid_for_iter) { return _VSTD::__unchecked_get<_Iter>(__hold_)++; } else { __postfix_proxy __p(**this); @@ -160,9 +169,10 @@ public: template _S2> requires sentinel_for<_Sent, _I2> - friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); - _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); auto __x_index = __x.__hold_.index(); auto __y_index = __y.__hold_.index(); @@ -178,9 +188,10 @@ public: template _S2> requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2> - friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); - _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); auto __x_index = __x.__hold_.index(); auto __y_index = __y.__hold_.index(); @@ -199,9 +210,10 @@ public: template _I2, sized_sentinel_for<_Iter> _S2> requires sized_sentinel_for<_Sent, _I2> - friend constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { - _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator"); - _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator"); + friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)"); auto __x_index = __x.__hold_.index(); auto __y_index = __y.__hold_.index(); @@ -218,21 +230,24 @@ public: return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); } - friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) + friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(declval()))) requires input_iterator<_Iter> { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator"); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), + "Cannot iter_move a sentinel. Common iterator not holding an iterator."); return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_)); } template _I2, class _S2> - friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) + friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) noexcept(noexcept(ranges::iter_swap(declval(), declval()))) { - _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); - _LIBCPP_ASSERT(holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); - return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__y.__hold_)); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), + "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator."); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_), + "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator."); + return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_)); } }; @@ -259,10 +274,10 @@ struct __arrow_type_or_void { template requires __common_iter_has_ptr_op<_Iter, _Sent> struct __arrow_type_or_void<_Iter, _Sent> { - using type = decltype(declval&>().operator->()); + using type = decltype(declval>().operator->()); }; -template +template struct iterator_traits> { using iterator_concept = _If, forward_iterator_tag, @@ -276,8 +291,11 @@ struct iterator_traits> { using reference = iter_reference_t<_Iter>; }; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H diff --git a/include/__iterator/concepts.h b/include/__iterator/concepts.h index f6d092c75..6eb4aef10 100644 --- a/include/__iterator/concepts.h +++ b/include/__iterator/concepts.h @@ -24,9 +24,14 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// clang-format off // [iterator.concept.readable] template @@ -67,8 +72,6 @@ concept __signed_integer_like = signed_integral<_Tp>; template concept weakly_incrementable = - // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173). - !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. movable<_Ip> && requires(_Ip __i) { typename iter_difference_t<_Ip>; @@ -169,6 +172,7 @@ concept contiguous_iterator = derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && is_lvalue_reference_v> && same_as, remove_cvref_t>> && + (is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) && requires(const _Ip& __i) { { _VSTD::to_address(__i) } -> same_as>>; }; @@ -257,8 +261,12 @@ concept indirectly_movable_storable = // Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle // (both iter_swap and indirectly_swappable require indirectly_readable). -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +// clang-format on + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_CONCEPTS_H diff --git a/include/__iterator/counted_iterator.h b/include/__iterator/counted_iterator.h index aaab3ac77..7136aaf02 100644 --- a/include/__iterator/counted_iterator.h +++ b/include/__iterator/counted_iterator.h @@ -13,14 +13,12 @@ #include <__debug> #include <__iterator/concepts.h> #include <__iterator/default_sentinel.h> -#include <__iterator/incrementable_traits.h> #include <__iterator/iter_move.h> #include <__iterator/iter_swap.h> +#include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__iterator/readable_traits.h> #include <__memory/pointer_traits.h> -#include <__utility/move.h> -#include #include #include @@ -28,9 +26,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) template struct __counted_iterator_concept {}; @@ -96,7 +97,7 @@ public: } _LIBCPP_HIDE_FROM_ABI - constexpr const _Iter& base() const& noexcept { return __current_; } + constexpr const _Iter& base() const& { return __current_; } _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return _VSTD::move(__current_); } @@ -296,8 +297,10 @@ struct iterator_traits> : iterator_traits<_Iter> { add_pointer_t>, void>; }; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H diff --git a/include/__iterator/data.h b/include/__iterator/data.h index 5e4946cc1..cd8e37b96 100644 --- a/include/__iterator/data.h +++ b/include/__iterator/data.h @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 @@ -48,4 +51,6 @@ constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.beg _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_DATA_H diff --git a/include/__iterator/default_sentinel.h b/include/__iterator/default_sentinel.h index e12a5909c..934a56fd9 100644 --- a/include/__iterator/default_sentinel.h +++ b/include/__iterator/default_sentinel.h @@ -16,15 +16,20 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) struct default_sentinel_t { }; inline constexpr default_sentinel_t default_sentinel{}; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H diff --git a/include/__iterator/distance.h b/include/__iterator/distance.h index 50ed76a4e..33e4af84d 100644 --- a/include/__iterator/distance.h +++ b/include/__iterator/distance.h @@ -11,18 +11,15 @@ #define _LIBCPP___ITERATOR_DISTANCE_H #include <__config> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/size.h> -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -52,56 +49,8 @@ distance(_InputIter __first, _InputIter __last) return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -// [range.iter.op.distance] - -namespace ranges { -namespace __distance { - -struct __fn { - template _Sp> - requires (!sized_sentinel_for<_Sp, _Ip>) - _LIBCPP_HIDE_FROM_ABI - constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { - iter_difference_t<_Ip> __n = 0; - while (__first != __last) { - ++__first; - ++__n; - } - return __n; - } - - template> _Sp> - _LIBCPP_HIDE_FROM_ABI - constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const { - if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) { - return __last - __first; - } else { - return __last - decay_t<_Ip>(__first); - } - } - - template - _LIBCPP_HIDE_FROM_ABI - constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const { - if constexpr (sized_range<_Rp>) { - return static_cast>(ranges::size(__r)); - } else { - return operator()(ranges::begin(__r), ranges::end(__r)); - } - } -}; - -} // namespace __distance - -inline namespace __cpo { - inline constexpr auto distance = __distance::__fn{}; -} // namespace __cpo -} // namespace ranges - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_DISTANCE_H diff --git a/include/__iterator/empty.h b/include/__iterator/empty.h index 39cd560a2..4dd59f5cc 100644 --- a/include/__iterator/empty.h +++ b/include/__iterator/empty.h @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 @@ -41,4 +44,6 @@ constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() = _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_EMPTY_H diff --git a/include/__iterator/erase_if_container.h b/include/__iterator/erase_if_container.h index 08f6e2248..a5dfd0720 100644 --- a/include/__iterator/erase_if_container.h +++ b/include/__iterator/erase_if_container.h @@ -16,6 +16,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -37,4 +40,6 @@ __libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H diff --git a/include/__iterator/front_insert_iterator.h b/include/__iterator/front_insert_iterator.h index b229a99f1..0421dd5c4 100644 --- a/include/__iterator/front_insert_iterator.h +++ b/include/__iterator/front_insert_iterator.h @@ -21,6 +21,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -67,4 +70,6 @@ front_inserter(_Container& __x) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H diff --git a/include/__iterator/incrementable_traits.h b/include/__iterator/incrementable_traits.h index 3b68acc9b..5a433982b 100644 --- a/include/__iterator/incrementable_traits.h +++ b/include/__iterator/incrementable_traits.h @@ -18,9 +18,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) // [incrementable.traits] template struct incrementable_traits {}; @@ -65,8 +68,10 @@ using iter_difference_t = typename conditional_t<__is_primary_template >, iterator_traits > >::difference_type; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H diff --git a/include/__iterator/indirectly_comparable.h b/include/__iterator/indirectly_comparable.h deleted file mode 100644 index ad5ff1a86..000000000 --- a/include/__iterator/indirectly_comparable.h +++ /dev/null @@ -1,30 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H -#define _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H - -#include <__config> -#include <__functional/identity.h> -#include <__iterator/concepts.h> -#include <__iterator/projected.h> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -template -concept indirectly_comparable = - indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H diff --git a/include/__iterator/insert_iterator.h b/include/__iterator/insert_iterator.h index dc617c1c9..265814182 100644 --- a/include/__iterator/insert_iterator.h +++ b/include/__iterator/insert_iterator.h @@ -14,7 +14,6 @@ #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> -#include <__ranges/access.h> #include <__utility/move.h> #include @@ -22,15 +21,10 @@ #pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD +_LIBCPP_PUSH_MACROS +#include <__undef_macros> -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) -template -using __insert_iterator_iter_t = ranges::iterator_t<_Container>; -#else -template -using __insert_iterator_iter_t = typename _Container::iterator; -#endif +_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH template @@ -42,7 +36,7 @@ class _LIBCPP_TEMPLATE_VIS insert_iterator _LIBCPP_SUPPRESS_DEPRECATED_POP protected: _Container* container; - __insert_iterator_iter_t<_Container> iter; + typename _Container::iterator iter; // FIXME: `ranges::iterator_t` in C++20 mode public: typedef output_iterator_tag iterator_category; typedef void value_type; @@ -55,7 +49,7 @@ public: typedef void reference; typedef _Container container_type; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) : container(_VSTD::addressof(__x)), iter(__i) {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) {iter = container->insert(iter, __value_); ++iter; return *this;} @@ -71,11 +65,13 @@ public: template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator<_Container> -inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) +inserter(_Container& __x, typename _Container::iterator __i) { return insert_iterator<_Container>(__x, __i); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H diff --git a/include/__iterator/istream_iterator.h b/include/__iterator/istream_iterator.h index 979d714ed..f39faa6d5 100644 --- a/include/__iterator/istream_iterator.h +++ b/include/__iterator/istream_iterator.h @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -67,6 +70,12 @@ public: bool operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); + + template + friend _LIBCPP_INLINE_VISIBILITY + bool + operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, + const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); }; template @@ -89,4 +98,6 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H diff --git a/include/__iterator/istreambuf_iterator.h b/include/__iterator/istreambuf_iterator.h index 0c7676f16..119698d54 100644 --- a/include/__iterator/istreambuf_iterator.h +++ b/include/__iterator/istreambuf_iterator.h @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -102,4 +105,6 @@ bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H diff --git a/include/__iterator/iter_move.h b/include/__iterator/iter_move.h index 45d9ade68..5540799e1 100644 --- a/include/__iterator/iter_move.h +++ b/include/__iterator/iter_move.h @@ -21,23 +21,20 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [iterator.cust.move] - -namespace ranges { -namespace __iter_move { +#if !defined(_LIBCPP_HAS_NO_RANGES) +namespace ranges::__iter_move { void iter_move(); -template -concept __unqualified_iter_move = - __class_or_enum> && - requires (_Tp&& __t) { - iter_move(_VSTD::forward<_Tp>(__t)); - }; +template +concept __unqualified_iter_move = requires(_Ip&& __i) { + iter_move(_VSTD::forward<_Ip>(__i)); +}; // [iterator.cust.move]/1 // The name ranges::iter_move denotes a customization point object. @@ -75,19 +72,20 @@ struct __fn { // [iterator.cust.move]/1.3 // Otherwise, ranges::iter_move(E) is ill-formed. }; -} // namespace __iter_move +} // namespace ranges::__iter_move -inline namespace __cpo { +namespace ranges::inline __cpo { inline constexpr auto iter_move = __iter_move::__fn{}; -} // namespace __cpo -} // namespace ranges +} template<__dereferenceable _Tp> - requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } +requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !_LIBCPP_HAS_NO_RANGES _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ITER_MOVE_H diff --git a/include/__iterator/iter_swap.h b/include/__iterator/iter_swap.h index 0b290520b..d70da09b4 100644 --- a/include/__iterator/iter_swap.h +++ b/include/__iterator/iter_swap.h @@ -14,8 +14,7 @@ #include <__iterator/iter_move.h> #include <__iterator/iterator_traits.h> #include <__iterator/readable_traits.h> -#include <__utility/forward.h> -#include <__utility/move.h> +#include <__ranges/access.h> #include #include @@ -23,11 +22,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -// [iter.cust.swap] +#if !defined(_LIBCPP_HAS_NO_RANGES) namespace ranges { namespace __iter_swap { @@ -35,11 +35,9 @@ namespace __iter_swap { void iter_swap(_I1, _I2) = delete; template - concept __unqualified_iter_swap = - (__class_or_enum> || __class_or_enum>) && - requires (_T1&& __x, _T2&& __y) { - iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); - }; + concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { + iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + }; template concept __readable_swappable = @@ -82,11 +80,12 @@ namespace __iter_swap { *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); } }; -} // namespace __iter_swap +} // end namespace __iter_swap inline namespace __cpo { inline constexpr auto iter_swap = __iter_swap::__fn{}; } // namespace __cpo + } // namespace ranges template @@ -99,8 +98,10 @@ concept indirectly_swappable = ranges::iter_swap(__i2, __i1); }; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ITER_SWAP_H diff --git a/include/__iterator/iterator.h b/include/__iterator/iterator.h index be298ee52..dfd481e35 100644 --- a/include/__iterator/iterator.h +++ b/include/__iterator/iterator.h @@ -17,6 +17,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) template using __with_reference = _Tp&; @@ -41,7 +44,7 @@ concept __dereferenceable = requires(_Tp& __t) { template<__dereferenceable _Tp> using iter_reference_t = decltype(*declval<_Tp&>()); -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) template struct _LIBCPP_TEMPLATE_VIS iterator_traits; @@ -76,7 +79,7 @@ struct __iter_concept_category_test { }; struct __iter_concept_random_fallback { template - using _Apply = __enable_if_t< + using _Apply = _EnableIf< __is_primary_template >::value, random_access_iterator_tag >; @@ -139,7 +142,7 @@ public: static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; }; -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) // The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, // so they've been banished to a namespace that makes it obvious they have a niche use-case. @@ -362,7 +365,7 @@ struct iterator_traits : __iterator_traits<_Ip> { using __primary_template = iterator_traits; }; -#else // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#else // !defined(_LIBCPP_HAS_NO_RANGES) template struct __iterator_traits {}; @@ -399,10 +402,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits using __primary_template = iterator_traits; }; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) template -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) requires is_object_v<_Tp> #endif struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> @@ -474,7 +477,7 @@ struct __is_exactly_cpp17_input_iterator __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; -#if _LIBCPP_STD_VER >= 17 +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; @@ -488,8 +491,10 @@ template using __iter_to_alloc_type = pair< add_const_t::value_type::first_type>, typename iterator_traits<_InputIterator>::value_type::second_type>; -#endif // _LIBCPP_STD_VER >= 17 +#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H diff --git a/include/__iterator/move_iterator.h b/include/__iterator/move_iterator.h index 29bac864c..7819743bd 100644 --- a/include/__iterator/move_iterator.h +++ b/include/__iterator/move_iterator.h @@ -12,32 +12,33 @@ #include <__config> #include <__iterator/iterator_traits.h> -#include <__utility/move.h> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_TEMPLATE_VIS move_iterator { +private: + _Iter __i; public: -#if _LIBCPP_STD_VER > 17 - typedef input_iterator_tag iterator_concept; -#endif - - typedef _Iter iterator_type; - typedef _If< - __is_cpp17_random_access_iterator<_Iter>::value, - random_access_iterator_tag, - typename iterator_traits<_Iter>::iterator_category - > iterator_category; + typedef _Iter iterator_type; typedef typename iterator_traits::value_type value_type; typedef typename iterator_traits::difference_type difference_type; typedef iterator_type pointer; + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + typename iterator_traits<_Iter>::iterator_category> iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef input_iterator_tag iterator_concept; +#endif #ifndef _LIBCPP_CXX03_LANG typedef typename iterator_traits::reference __reference; @@ -50,113 +51,114 @@ public: typedef typename iterator_traits::reference reference; #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator() : __current_() {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator() : __i() {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit move_iterator(_Iter __x) : __i(__x) {} - template ::value && is_convertible::value + template ::value && is_convertible<_Up const&, _Iter>::value > > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} - template ::value && - is_convertible::value && - is_assignable<_Iter&, const _Up&>::value + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Iter&, _Up const&>::value > > - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator& operator=(const move_iterator<_Up>& __u) { - __current_ = __u.base(); + __i = __u.base(); return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - _Iter base() const { return __current_; } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator*() const { return static_cast(*__current_); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - pointer operator->() const { return __current_; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - reference operator[](difference_type __n) const { return static_cast(__current_[__n]); } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator++() { ++__current_; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator--() { --__current_; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 - move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; } - -private: - _Iter __current_; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator*() const { return static_cast(*__i); } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + pointer operator->() const { return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator++() {++__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator--() {--__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](difference_type __n) const { return static_cast(__i[__n]); } }; template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { return __x.base() == __y.base(); } template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() != __y.base(); -} - -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { return __x.base() < __y.base(); } template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() != __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { return __x.base() > __y.base(); } template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -{ - return __x.base() <= __y.base(); -} - -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { return __x.base() >= __y.base(); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() <= __y.base(); +} + #ifndef _LIBCPP_CXX03_LANG template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 -auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) - -> decltype(__x.base() - __y.base()) +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +-> decltype(__x.base() - __y.base()) { return __x.base() - __y.base(); } #else template -inline _LIBCPP_HIDE_FROM_ABI +inline _LIBCPP_INLINE_VISIBILITY typename move_iterator<_Iter1>::difference_type operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) { @@ -165,7 +167,7 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) #endif template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator<_Iter> operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) { @@ -173,13 +175,15 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato } template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 move_iterator<_Iter> make_move_iterator(_Iter __i) { - return move_iterator<_Iter>(_VSTD::move(__i)); + return move_iterator<_Iter>(__i); } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H diff --git a/include/__iterator/next.h b/include/__iterator/next.h index 5dda0674d..1eecaa975 100644 --- a/include/__iterator/next.h +++ b/include/__iterator/next.h @@ -12,6 +12,7 @@ #include <__config> #include <__debug> +#include <__function_like.h> #include <__iterator/advance.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -22,6 +23,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -35,14 +39,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 return __x; } -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -// [range.iter.op.next] +#if !defined(_LIBCPP_HAS_NO_RANGES) namespace ranges { -namespace __next { +struct __next_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {} -struct __fn { template _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { @@ -72,15 +75,13 @@ struct __fn { } }; -} // namespace __next - -inline namespace __cpo { - inline constexpr auto next = __next::__fn{}; -} // namespace __cpo +inline constexpr auto next = __next_fn(__function_like::__tag()); } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___ITERATOR_NEXT_H +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_PRIMITIVES_H diff --git a/include/__iterator/ostream_iterator.h b/include/__iterator/ostream_iterator.h index 20a36742c..5b4466c86 100644 --- a/include/__iterator/ostream_iterator.h +++ b/include/__iterator/ostream_iterator.h @@ -20,6 +20,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -67,4 +70,6 @@ public: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H diff --git a/include/__iterator/ostreambuf_iterator.h b/include/__iterator/ostreambuf_iterator.h index 3272f6c99..90309dacd 100644 --- a/include/__iterator/ostreambuf_iterator.h +++ b/include/__iterator/ostreambuf_iterator.h @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_SUPPRESS_DEPRECATED_PUSH @@ -73,4 +76,6 @@ public: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H diff --git a/include/__iterator/prev.h b/include/__iterator/prev.h index 2b8c15fe5..cb8a57135 100644 --- a/include/__iterator/prev.h +++ b/include/__iterator/prev.h @@ -12,6 +12,7 @@ #include <__config> #include <__debug> +#include <__function_like.h> #include <__iterator/advance.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -22,6 +23,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -34,14 +38,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 return __x; } -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -// [range.iter.op.prev] +#if !defined(_LIBCPP_HAS_NO_RANGES) namespace ranges { -namespace __prev { +struct __prev_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {} -struct __fn { template _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { @@ -64,15 +67,13 @@ struct __fn { } }; -} // namespace __prev - -inline namespace __cpo { - inline constexpr auto prev = __prev::__fn{}; -} // namespace __cpo +inline constexpr auto prev = __prev_fn(__function_like::__tag()); } // namespace ranges -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_PREV_H diff --git a/include/__iterator/projected.h b/include/__iterator/projected.h index 30ea3a124..7064a5eb9 100644 --- a/include/__iterator/projected.h +++ b/include/__iterator/projected.h @@ -18,9 +18,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) template _Proj> struct projected { @@ -33,8 +36,10 @@ struct incrementable_traits> { using difference_type = iter_difference_t<_It>; }; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_PROJECTED_H diff --git a/include/__iterator/readable_traits.h b/include/__iterator/readable_traits.h index c0b16bafd..fbad106e4 100644 --- a/include/__iterator/readable_traits.h +++ b/include/__iterator/readable_traits.h @@ -18,9 +18,12 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) +#if !defined(_LIBCPP_HAS_NO_RANGES) // [readable.traits] template struct __cond_value_type {}; @@ -57,14 +60,14 @@ template<__has_member_element_type _Tp> struct indirectly_readable_traits<_Tp> : __cond_value_type {}; +// Pre-emptively applies LWG3541 template<__has_member_value_type _Tp> - requires __has_member_element_type<_Tp> +requires __has_member_element_type<_Tp> struct indirectly_readable_traits<_Tp> {}; - template<__has_member_value_type _Tp> - requires __has_member_element_type<_Tp> && - same_as, - remove_cv_t> +requires __has_member_element_type<_Tp> && + same_as, + remove_cv_t> struct indirectly_readable_traits<_Tp> : __cond_value_type {}; @@ -79,8 +82,10 @@ using iter_value_t = typename conditional_t<__is_primary_template >, iterator_traits > >::value_type; -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) +#endif // !defined(_LIBCPP_HAS_NO_RANGES) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H diff --git a/include/__iterator/reverse_access.h b/include/__iterator/reverse_access.h index 643aede01..66cc3568c 100644 --- a/include/__iterator/reverse_access.h +++ b/include/__iterator/reverse_access.h @@ -19,6 +19,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if !defined(_LIBCPP_CXX03_LANG) @@ -101,4 +104,6 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H diff --git a/include/__iterator/reverse_iterator.h b/include/__iterator/reverse_iterator.h index af855a0a1..76424a89a 100644 --- a/include/__iterator/reverse_iterator.h +++ b/include/__iterator/reverse_iterator.h @@ -10,8 +10,6 @@ #ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H #define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H -#include <__compare/compare_three_way_result.h> -#include <__compare/three_way_comparable.h> #include <__config> #include <__iterator/iterator.h> #include <__iterator/iterator_traits.h> @@ -22,8 +20,18 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD +template +struct __is_stashing_iterator : false_type {}; + +template +struct __is_stashing_iterator<_Tp, typename __void_t::type> + : true_type {}; + _LIBCPP_SUPPRESS_DEPRECATED_PUSH template class _LIBCPP_TEMPLATE_VIS reverse_iterator @@ -41,6 +49,10 @@ private: _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break #endif + static_assert(!__is_stashing_iterator<_Iter>::value, + "The specified iterator type cannot be used with reverse_iterator; " + "Using stashing iterators with reverse_iterator causes undefined behavior"); + protected: _Iter current; public: @@ -66,7 +78,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} - template ::value && is_convertible<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 @@ -74,10 +86,10 @@ public: : __t(__u.base()), current(__u.base()) { } - template ::value && is_convertible<_Up const&, _Iter>::value && - is_assignable<_Iter&, _Up const&>::value + is_assignable<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { @@ -91,7 +103,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 explicit reverse_iterator(_Iter __x) : current(__x) {} - template ::value && is_convertible<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 @@ -99,10 +111,10 @@ public: : current(__u.base()) { } - template ::value && is_convertible<_Up const&, _Iter>::value && - is_assignable<_Iter&, _Up const&>::value + is_assignable<_Up const&, _Iter>::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { @@ -184,16 +196,6 @@ operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& return __x.base() >= __y.base(); } -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) -template _Iter2> -_LIBCPP_HIDE_FROM_ABI constexpr -compare_three_way_result_t<_Iter1, _Iter2> -operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) -{ - return __y.base() <=> __x.base(); -} -#endif - #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 @@ -232,4 +234,6 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H diff --git a/include/__iterator/size.h b/include/__iterator/size.h index 2e6a7d386..259424f1d 100644 --- a/include/__iterator/size.h +++ b/include/__iterator/size.h @@ -18,6 +18,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 @@ -50,4 +53,6 @@ constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_SIZE_H diff --git a/include/__iterator/unreachable_sentinel.h b/include/__iterator/unreachable_sentinel.h deleted file mode 100644 index b200236d8..000000000 --- a/include/__iterator/unreachable_sentinel.h +++ /dev/null @@ -1,38 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H -#define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H - -#include <__config> -#include <__iterator/concepts.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if !defined(_LIBCPP_HAS_NO_CONCEPTS) - -struct unreachable_sentinel_t { - template - _LIBCPP_HIDE_FROM_ABI - friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept { - return false; - } -}; - -inline constexpr unreachable_sentinel_t unreachable_sentinel{}; - -#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H diff --git a/include/__iterator/wrap_iter.h b/include/__iterator/wrap_iter.h index d9dbee588..e35a372b4 100644 --- a/include/__iterator/wrap_iter.h +++ b/include/__iterator/wrap_iter.h @@ -13,14 +13,16 @@ #include <__config> #include <__debug> #include <__iterator/iterator_traits.h> -#include <__memory/addressof.h> -#include <__memory/pointer_traits.h> +#include <__memory/pointer_traits.h> // __to_address #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template @@ -40,109 +42,120 @@ public: private: iterator_type __i; public: - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT - : __i() + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __i{} +#endif { - _VSTD::__debug_db_insert_i(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } - template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 + template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const __wrap_iter<_Up>& __u, typename enable_if::value>::type* = nullptr) _NOEXCEPT : __i(__u.base()) { #if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__iterator_copy(this, _VSTD::addressof(__u)); + __get_db()->__iterator_copy(this, &__u); #endif } #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const __wrap_iter& __x) : __i(__x.base()) { - if (!__libcpp_is_constant_evaluated()) - __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); + __get_db()->__iterator_copy(this, &__x); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator=(const __wrap_iter& __x) { - if (this != _VSTD::addressof(__x)) + if (this != &__x) { - if (!__libcpp_is_constant_evaluated()) - __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); + __get_db()->__iterator_copy(this, &__x); __i = __x.__i; } return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG ~__wrap_iter() { - if (!__libcpp_is_constant_evaluated()) __get_db()->__erase_i(this); } #endif - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable iterator"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif return *__i; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to dereference a non-dereferenceable iterator"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif return _VSTD::__to_address(__i); } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment a non-incrementable iterator"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment a non-incrementable iterator"); +#endif ++__i; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT {__wrap_iter __tmp(*this); ++(*this); return __tmp;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator--() _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this), - "Attempted to decrement a non-decrementable iterator"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), + "Attempted to decrement a non-decrementable iterator"); +#endif --__i; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT {__wrap_iter __tmp(*this); --(*this); return __tmp;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT {__wrap_iter __w(*this); __w += __n; return __w;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n), - "Attempted to add/subtract an iterator outside its valid range"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), + "Attempted to add/subtract an iterator outside its valid range"); +#endif __i += __n; return *this; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT {return *this + (-__n);} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT {*this += -__n; return *this;} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n), - "Attempted to subscript an iterator outside its valid range"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), + "Attempted to subscript an iterator outside its valid range"); +#endif return __i[__n]; } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} private: #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x) + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) { - if (!__libcpp_is_constant_evaluated()) __get_db()->__insert_ic(this, __p); } #else - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #endif template friend class __wrap_iter; @@ -152,95 +165,99 @@ private: }; template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { return __x.base() == __y.base(); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return __x.base() == __y.base(); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), - "Attempted to compare incomparable iterators"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to compare incomparable iterators"); +#endif return __x.base() < __y.base(); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), - "Attempted to compare incomparable iterators"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to compare incomparable iterators"); +#endif return __x.base() < __y.base(); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { return !(__x == __y); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return !(__x == __y); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { return __y < __x; } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return __y < __x; } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { return !(__x < __y); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return !(__x < __y); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { return !(__y < __x); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { return !(__y < __x); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG #ifndef _LIBCPP_CXX03_LANG auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT -> decltype(__x.base() - __y.base()) @@ -249,13 +266,15 @@ typename __wrap_iter<_Iter1>::difference_type operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT #endif // C++03 { - _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), - "Attempted to subtract incompatible iterators"); +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to subtract incompatible iterators"); +#endif return __x.base() - __y.base(); } template -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT { __x += __n; @@ -267,19 +286,15 @@ template struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; #endif -template -struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > -{ - typedef __wrap_iter<_It> pointer; - typedef typename pointer_traits<_It>::element_type element_type; - typedef typename pointer_traits<_It>::difference_type difference_type; - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR - static element_type *to_address(pointer __w) _NOEXCEPT { - return _VSTD::__to_address(__w.base()); - } -}; +template +_LIBCPP_CONSTEXPR +decltype(_VSTD::__to_address(declval<_Iter>())) +__to_address(__wrap_iter<_Iter> __w) _NOEXCEPT { + return _VSTD::__to_address(__w.base()); +} _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ITERATOR_WRAP_ITER_H diff --git a/include/__libcpp_version b/include/__libcpp_version index bfed81939..09514aa4d 100644 --- a/include/__libcpp_version +++ b/include/__libcpp_version @@ -1 +1 @@ -14000 +13000 diff --git a/include/__locale b/include/__locale index 51f35eece..ad742997d 100644 --- a/include/__locale +++ b/include/__locale @@ -12,17 +12,18 @@ #include <__availability> #include <__config> -#include -#include -#include -#include -#include #include +#include #include - +#include +#include +#include +#include #if defined(_LIBCPP_MSVCRT_LIKE) # include # include <__support/win32/locale_win32.h> +#elif defined(__NuttX__) +# include <__support/nuttx/xlocale.h> #elif defined(_AIX) || defined(__MVS__) # include <__support/ibm/xlocale.h> #elif defined(__ANDROID__) @@ -209,11 +210,10 @@ class _LIBCPP_TYPE_VIS locale::id static int32_t __next_id; public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} - void operator=(const id&) = delete; - id(const id&) = delete; - private: void __init(); + void operator=(const id&); // = delete; + id(const id&); // = delete; public: // only needed for tests long __get(); @@ -340,9 +340,7 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const } _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) -#endif // template class collate_byname; @@ -367,7 +365,6 @@ protected: virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; }; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS collate_byname : public collate @@ -387,7 +384,6 @@ protected: const char_type* __lo2, const char_type* __hi2) const; virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; }; -#endif template bool @@ -452,7 +448,7 @@ public: static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; - static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used + static const mask __regex_word = 0x80; # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) # ifdef __APPLE__ @@ -511,33 +507,6 @@ public: # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT -#elif defined(__MVS__) -# if defined(__NATIVE_ASCII_F) - typedef unsigned int mask; - static const mask space = _ISSPACE_A; - static const mask print = _ISPRINT_A; - static const mask cntrl = _ISCNTRL_A; - static const mask upper = _ISUPPER_A; - static const mask lower = _ISLOWER_A; - static const mask alpha = _ISALPHA_A; - static const mask digit = _ISDIGIT_A; - static const mask punct = _ISPUNCT_A; - static const mask xdigit = _ISXDIGIT_A; - static const mask blank = _ISBLANK_A; -# else - typedef unsigned short mask; - static const mask space = __ISSPACE; - static const mask print = __ISPRINT; - static const mask cntrl = __ISCNTRL; - static const mask upper = __ISUPPER; - static const mask lower = __ISLOWER; - static const mask alpha = __ISALPHA; - static const mask digit = __ISDIGIT; - static const mask punct = __ISPUNCT; - static const mask xdigit = __ISXDIGIT; - static const mask blank = __ISBLANK; -# endif - static const mask __regex_word = 0x8000; #else # error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? #endif @@ -545,17 +514,10 @@ public: static const mask graph = alnum | punct; _LIBCPP_INLINE_VISIBILITY ctype_base() {} - -// TODO: Remove the ifndef when the assert no longer fails on AIX. -#ifndef _AIX - static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word, - "__regex_word can't overlap other bits"); -#endif }; template class _LIBCPP_TEMPLATE_VIS ctype; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS ctype : public locale::facet, @@ -657,7 +619,6 @@ protected: virtual char do_narrow(char_type, char __dfault) const; virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS ctype @@ -767,10 +728,6 @@ public: static const short* __classic_upper_table() _NOEXCEPT; static const short* __classic_lower_table() _NOEXCEPT; #endif -#if defined(__MVS__) - static const unsigned short* __classic_upper_table() _NOEXCEPT; - static const unsigned short* __classic_lower_table() _NOEXCEPT; -#endif protected: ~ctype(); @@ -806,7 +763,6 @@ protected: virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; }; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS ctype_byname : public ctype @@ -832,7 +788,6 @@ protected: virtual char do_narrow(char_type, char __dfault) const; virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS template inline _LIBCPP_INLINE_VISIBILITY @@ -1039,7 +994,6 @@ protected: // template <> class codecvt -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS codecvt : public locale::facet, @@ -1120,7 +1074,6 @@ protected: virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; virtual int do_max_length() const _NOEXCEPT; }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS // template <> class codecvt // deprecated in C++20 @@ -1499,9 +1452,7 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) -#endif _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) // deprecated in C++20 _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) // deprecated in C++20 #ifndef _LIBCPP_HAS_NO_CHAR8_T @@ -1732,7 +1683,6 @@ protected: string __grouping_; }; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS numpunct : public locale::facet @@ -1763,7 +1713,6 @@ protected: char_type __thousands_sep_; string __grouping_; }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS // template class numpunct_byname @@ -1787,7 +1736,6 @@ private: void __init(const char*); }; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> class _LIBCPP_TYPE_VIS numpunct_byname : public numpunct @@ -1805,7 +1753,6 @@ protected: private: void __init(const char*); }; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_END_NAMESPACE_STD diff --git a/include/__mbstate_t.h b/include/__mbstate_t.h deleted file mode 100644 index 3489f9cc0..000000000 --- a/include/__mbstate_t.h +++ /dev/null @@ -1,44 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP___MBSTATE_T_H -#define _LIBCPP___MBSTATE_T_H - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - -// TODO(ldionne): -// The goal of this header is to provide mbstate_t without having to pull in -// or . This is necessary because we need that type even -// when we don't have (or try to provide) support for wchar_t, because several -// types like std::fpos are defined in terms of mbstate_t. -// -// This is a gruesome hack, but I don't know how to make it cleaner for -// the time being. - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -# include // for mbstate_t -#elif __has_include() -# include // works on most Unixes -#elif __has_include() -# include // works on Darwin -#else -# error "The library was configured without support for wide-characters, but we don't know how to get the definition of mbstate_t without on your platform." -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::mbstate_t _LIBCPP_USING_IF_EXISTS; - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___MBSTATE_T_H diff --git a/include/__memory/addressof.h b/include/__memory/addressof.h index c45dedfae..5efdb5878 100644 --- a/include/__memory/addressof.h +++ b/include/__memory/addressof.h @@ -16,8 +16,13 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF + template inline _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY @@ -27,6 +32,19 @@ addressof(_Tp& __x) _NOEXCEPT return __builtin_addressof(__x); } +#else + +template +inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return reinterpret_cast<_Tp *>( + const_cast(&reinterpret_cast(__x))); +} + +#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF + #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) // Objective-C++ Automatic Reference Counting uses qualified pointers // that require special addressof() signatures. When @@ -73,4 +91,6 @@ template _Tp* addressof(const _Tp&&) noexcept = delete; _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_ADDRESSOF_H diff --git a/include/__memory/allocation_guard.h b/include/__memory/allocation_guard.h index 6412677aa..4987af293 100644 --- a/include/__memory/allocation_guard.h +++ b/include/__memory/allocation_guard.h @@ -19,6 +19,10 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + _LIBCPP_BEGIN_NAMESPACE_STD // Helper class to allocate memory using an Allocator in an exception safe @@ -80,4 +84,6 @@ private: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H diff --git a/include/__memory/allocator.h b/include/__memory/allocator.h index 708bd82b0..2c21a16e7 100644 --- a/include/__memory/allocator.h +++ b/include/__memory/allocator.h @@ -22,6 +22,9 @@ #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template class allocator; @@ -80,7 +83,6 @@ template class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if::value, allocator<_Tp> > { - static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -89,7 +91,7 @@ public: typedef true_type is_always_equal; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - allocator() _NOEXCEPT = default; + allocator() _NOEXCEPT _LIBCPP_DEFAULT template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -98,7 +100,8 @@ public: _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp* allocate(size_t __n) { if (__n > allocator_traits::max_size(*this)) - __throw_bad_array_new_length(); + __throw_length_error("allocator::allocate(size_t n)" + " 'n' exceeds maximum supported size"); if (__libcpp_is_constant_evaluated()) { return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); } else { @@ -162,7 +165,6 @@ template class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if::value, allocator > { - static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); public: typedef size_t size_type; typedef ptrdiff_t difference_type; @@ -171,7 +173,7 @@ public: typedef true_type is_always_equal; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 - allocator() _NOEXCEPT = default; + allocator() _NOEXCEPT _LIBCPP_DEFAULT template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 @@ -180,7 +182,8 @@ public: _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const _Tp* allocate(size_t __n) { if (__n > allocator_traits::max_size(*this)) - __throw_bad_array_new_length(); + __throw_length_error("allocator::allocate(size_t n)" + " 'n' exceeds maximum supported size"); if (__libcpp_is_constant_evaluated()) { return static_cast(::operator new(__n * sizeof(_Tp))); } else { @@ -246,4 +249,6 @@ bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_ALLOCATOR_H diff --git a/include/__memory/allocator_arg_t.h b/include/__memory/allocator_arg_t.h index f5a116dbb..830c6b814 100644 --- a/include/__memory/allocator_arg_t.h +++ b/include/__memory/allocator_arg_t.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H -#define _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H +#ifndef _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H +#define _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H #include <__config> #include <__memory/uses_allocator.h> @@ -26,7 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = defau #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; #else -/* inline */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); #endif #ifndef _LIBCPP_CXX03_LANG @@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; template struct __uses_alloc_ctor_imp { - typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc; + typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc; static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; @@ -75,4 +75,4 @@ void __user_alloc_construct_impl (integral_constant, _Tp *__storage, con _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H +#endif // _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H diff --git a/include/__memory/allocator_traits.h b/include/__memory/allocator_traits.h index f4c8fa02d..a02af0dea 100644 --- a/include/__memory/allocator_traits.h +++ b/include/__memory/allocator_traits.h @@ -36,11 +36,11 @@ template ::type, bool = __has_pointer<_RawAlloc>::value> struct __pointer { - using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer; + using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer; }; template struct __pointer<_Tp, _Alloc, _RawAlloc, false> { - using type _LIBCPP_NODEBUG = _Tp*; + using type _LIBCPP_NODEBUG_TYPE = _Tp*; }; // __const_pointer @@ -48,14 +48,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); template ::value> struct __const_pointer { - using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer; }; template struct __const_pointer<_Tp, _Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG using type = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -64,14 +64,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer); template ::value> struct __void_pointer { - using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer; }; template struct __void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -80,14 +80,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer); template ::value> struct __const_void_pointer { - using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer; }; template struct __const_void_pointer<_Ptr, _Alloc, false> { #ifdef _LIBCPP_CXX03_LANG - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind::other; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; #else - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; #endif }; @@ -97,18 +97,18 @@ template ::value> struct __size_type : make_unsigned<_DiffType> { }; template struct __size_type<_Alloc, _DiffType, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::size_type; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type; }; // __alloc_traits_difference_type _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); template ::value> struct __alloc_traits_difference_type { - using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type; + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type; }; template struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::difference_type; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type; }; // __propagate_on_container_copy_assignment @@ -117,7 +117,7 @@ template struct __propagate_on_container_copy_assignment<_Alloc, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment; }; // __propagate_on_container_move_assignment @@ -126,7 +126,7 @@ template struct __propagate_on_container_move_assignment<_Alloc, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment; }; // __propagate_on_container_swap @@ -135,7 +135,7 @@ template ::value> struct __propagate_on_container_swap : false_type { }; template struct __propagate_on_container_swap<_Alloc, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap; }; // __is_always_equal @@ -144,7 +144,7 @@ template ::value> struct __is_always_equal : is_empty<_Alloc> { }; template struct __is_always_equal<_Alloc, true> { - using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal; + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal; }; // __allocator_traits_rebind @@ -158,15 +158,15 @@ struct __has_rebind_other<_Tp, _Up, typename __void_t< template ::value> struct __allocator_traits_rebind { - using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; + using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other; }; template