Index: vendor/libc++/dist/CMakeLists.txt =================================================================== --- vendor/libc++/dist/CMakeLists.txt (revision 320379) +++ vendor/libc++/dist/CMakeLists.txt (revision 320380) @@ -1,651 +1,652 @@ # See www/CMake.html for instructions on how to build libcxx with CMake. #=============================================================================== # Setup Project #=============================================================================== cmake_minimum_required(VERSION 3.4.3) if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default endif() if(POLICY CMP0022) cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang endif() # Add path for custom modules set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH} ) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(libcxx CXX C) set(PACKAGE_NAME libcxx) set(PACKAGE_VERSION 5.0.0svn) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") # Find the LLVM sources and simulate LLVM CMake options. include(HandleOutOfTreeLLVM) endif() if (LIBCXX_STANDALONE_BUILD) include(FindPythonInterp) if( NOT PYTHONINTERP_FOUND ) message(WARNING "Failed to find python interpreter. " "The libc++ test suite will be disabled.") set(LLVM_INCLUDE_TESTS OFF) endif() endif() # Require out of source build. include(MacroEnsureOutOfSourceBuild) MACRO_ENSURE_OUT_OF_SOURCE_BUILD( "${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." ) if (MSVC) set(LIBCXX_TARGETING_MSVC ON) else() set(LIBCXX_TARGETING_MSVC OFF) endif() #=============================================================================== # Setup CMake Options #=============================================================================== include(CMakeDependentOption) include(HandleCompilerRT) # Basic options --------------------------------------------------------------- option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) set(ENABLE_FILESYSTEM_DEFAULT ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY}) if (WIN32) set(ENABLE_FILESYSTEM_DEFAULT OFF) endif() option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of libc++experimental.a" ${ENABLE_FILESYSTEM_DEFAULT}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) # Benchmark options ----------------------------------------------------------- option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependancies" ON) set(LIBCXX_BENCHMARK_NATIVE_STDLIB "" CACHE STRING "Build the benchmarks against the specified native STL. The value must be one of libc++/libstdc++") set(LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain when building the native benchmarks") if (LIBCXX_BENCHMARK_NATIVE_STDLIB) if (NOT (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++" OR LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")) message(FATAL_ERROR "Invalid value for LIBCXX_BENCHMARK_NATIVE_STDLIB: " "'${LIBCXX_BENCHMARK_NATIVE_STDLIB}'") endif() endif() option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING "Define suffix of library directory name (32/64)") option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" ON "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.") option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC) message(FATAL_ERROR "libc++ must be built as either a shared or static library.") endif() # ABI Library options --------------------------------------------------------- set(LIBCXX_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.") set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) # Setup the default options if LIBCXX_CXX_ABI is not specified. if (LIBCXX_CXX_ABI STREQUAL "default") find_path( LIBCXX_LIBCXXABI_INCLUDES_INTERNAL cxxabi.h PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include + ${LLVM_MAIN_SRC_DIR}/../libcxxabi/include NO_DEFAULT_PATH ) if (LIBCXX_TARGETING_MSVC) # FIXME: Figure out how to configure the ABI library on Windows. set(LIBCXX_CXX_ABI_LIBNAME "vcruntime") elseif ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}") set(LIBCXX_CXX_ABI_INTREE 1) elseif (APPLE) set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") set(LIBCXX_CXX_ABI_SYSTEM 1) else() set(LIBCXX_CXX_ABI_LIBNAME "default") endif() else() set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") endif() # Use a static copy of the ABI library when linking libc++. This option # cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) # Generate and install a linker script inplace of libc++.so. The linker script # will link libc++ to the correct ABI library. This option is on by default # on UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' # is on. This option is also disabled when the ABI library is not specified # or is specified to be "none". set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default" AND PYTHONINTERP_FOUND AND LIBCXX_ENABLE_SHARED) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) endif() option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT "Use and install a linker script for the given ABI library" ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) set(ENABLE_NEW_DELETE_DEFAULT ON) if (LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS) # FIXME: This option should default to off. Unfortunatly GCC 4.9 fails to link # programs due to undefined references to new/delete in libc++abi so to work # around this libc++abi currently defaults LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS # to ON. Once the GCC bug has been worked around this option should be changed # back to OFF. set(ENABLE_NEW_DELETE_DEFAULT ON) endif() option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS "Build libc++ with definitions for operator new/delete. This option can be used to disable the definitions when libc++abi is expected to provide them" ${ENABLE_NEW_DELETE_DEFAULT}) # Build libc++abi with libunwind. We need this option to determine whether to # link with libunwind or libgcc_s while running the test cases. option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF) # Target options -------------------------------------------------------------- option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") # 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) option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF) option(LIBCXX_HAS_EXTERNAL_THREAD_API "Build libc++ with an externalized threading API. This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF) option(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY "Build libc++ with an externalized threading library. This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON" OFF) # Misc options ---------------------------------------------------------------- # FIXME: Turn -pedantic back ON. It is currently off because it warns # about #include_next which is used everywhere. option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS "Disable #warnings about conflicting macros." OFF) option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING "The Profile-rt library used to build with code coverage") # Don't allow a user to accidentally overwrite the system libc++ installation on Darwin. # If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++ # will not be generated and a warning will be issued. option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF) mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default. if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL) if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") message(WARNING "Disabling libc++ install rules because installation would " "overwrite the systems installation. Configure with " "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.") mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option. set(LIBCXX_INSTALL_HEADERS OFF) set(LIBCXX_INSTALL_LIBRARY OFF) endif() endif() set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) if (XCODE OR MSVC_IDE) set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) endif() option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" ${LIBCXX_CONFIGURE_IDE_DEFAULT}) #=============================================================================== # Check option configurations #=============================================================================== if (LIBCXX_ENABLE_FILESYSTEM AND NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) message(FATAL_ERROR "LIBCXX_ENABLE_FILESYSTEM cannot be turned on when LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF") endif() # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when # LIBCXX_ENABLE_THREADS is on. if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" " when LIBCXX_ENABLE_THREADS is also set to OFF.") endif() if(NOT LIBCXX_ENABLE_THREADS) if(LIBCXX_HAS_PTHREAD_API) message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON" " when LIBCXX_ENABLE_THREADS is also set to ON.") endif() if(LIBCXX_HAS_EXTERNAL_THREAD_API) message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON" " when LIBCXX_ENABLE_THREADS is also set to ON.") endif() if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set " "to ON when LIBCXX_ENABLE_THREADS is also set to ON.") endif() endif() if (LIBCXX_HAS_EXTERNAL_THREAD_API) if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY) message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and " "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at " "the same time") endif() if (LIBCXX_HAS_PTHREAD_API) message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API" "and LIBCXX_HAS_PTHREAD_API cannot be both" "set to ON at the same time.") endif() endif() # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE # is ON. 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() # Check that this option is not enabled on Apple and emit a usage warning. if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) if (APPLE) message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") else() message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") endif() if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.") endif() endif() if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) if (APPLE) message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") endif() if (NOT PYTHONINTERP_FOUND) message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.") endif() if (NOT LIBCXX_ENABLE_SHARED) message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT is only available for shared library builds.") endif() endif() if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) message(FATAL_ERROR "Conflicting options given. LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with LIBCXX_ENABLE_ABI_LINKER_SCRIPT") endif() if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off" "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") endif() #=============================================================================== # Configure System #=============================================================================== set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") if (LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) endif() file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) # Declare libc++ configuration variables. # They are intended for use as follows: # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. # LIBCXX_COMPILE_FLAGS: Compile only flags. # LIBCXX_LINK_FLAGS: Linker only flags. # LIBCXX_LIBRARIES: libraries libc++ is linked to. # LIBCXX_INTERFACE_LIBRARIES: Libraries that must be linked when using libc++ # These libraries are exposed in the linker script. set(LIBCXX_COMPILE_FLAGS "") set(LIBCXX_LINK_FLAGS "") set(LIBCXX_LIBRARIES "") set(LIBCXX_INTERFACE_LIBRARIES "") # Include macros for adding and removing libc++ flags. include(HandleLibcxxFlags) # Target flags ================================================================ # 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' add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") add_target_flags_if(LIBCXX_TARGET_TRIPLE "--target=${LIBCXX_TARGET_TRIPLE}") add_target_flags_if(LIBCXX_SYSROOT "--sysroot=${LIBCXX_SYSROOT}") add_target_flags_if(LIBCXX_GCC_TOOLCHAIN "--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") if (LIBCXX_TARGET_TRIPLE) set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") endif() # Configure compiler. include(config-ix) if (LIBCXX_USE_COMPILER_RT) list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt") endif() # Configure coverage options. if (LIBCXX_GENERATE_COVERAGE) include(CodeCoverage) set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") set(LIBCXX_DEBUG_BUILD ON) else() set(LIBCXX_DEBUG_BUILD OFF) endif() #=============================================================================== # Setup Compiler Flags #=============================================================================== include(HandleLibCXXABI) # Setup the ABI library flags if (NOT LIBCXX_STANDALONE_BUILD) # Remove flags that may have snuck in. remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG -lc++abi) endif() remove_flags(-stdlib=libc++ -stdlib=libstdc++) # FIXME: Remove all debug flags and flags that change which Windows # default libraries are linked. Currently we only support linking the # non-debug DLLs remove_flags("/D_DEBUG" "/MTd" "/MDd" "/MT" "/Md") # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors # so they don't get transformed into -Wno and -errors respectively. remove_flags(-Wno-pedantic -pedantic-errors -pedantic) # Required flags ============================================================== set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect") if (LIBCXX_HAS_MUSL_LIBC) # musl's pthread implementations uses volatile types in their structs which is # not a constexpr in C++11 but is in C++14, so we use C++14 with musl. set(LIBCXX_STANDARD_VER c++14 CACHE INTERNAL "internal option to change build dialect") endif() add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER}) mangle_name("LIBCXX_SUPPORTS_STD_EQ_${LIBCXX_STANDARD_VER}_FLAG" SUPPORTS_DIALECT_NAME) if(NOT ${SUPPORTS_DIALECT_NAME}) if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") message(FATAL_ERROR "C++11 or greater is required but the compiler does not support ${LIBCXX_STANDARD_VER}") endif() endif() # On all systems the system c++ standard library headers need to be excluded. # MSVC only has -X, which disables all default includes; including the crt. # Thus, we do nothing and hope we don't accidentally include any of the C++ # headers add_compile_flags_if_supported(-nostdinc++) # Hide all inline function definitions which have not explicitly been marked # visible. This prevents new definitions for inline functions from appearing in # the dylib when get ODR used by another function. add_compile_flags_if_supported(-fvisibility-inlines-hidden) if (LIBCXX_CONFIGURE_IDE) # This simply allows IDE to process add_compile_flags_if_supported(-fcoroutines-ts) endif() # Let the library headers know they are currently being used to build the # library. add_definitions(-D_LIBCPP_BUILDING_LIBRARY) if (NOT LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS) endif() # Warning flags =============================================================== add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_compile_flags_if_supported( -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") add_compile_flags_if_supported( -Wno-user-defined-literals -Wno-covered-switch-default) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") add_compile_flags_if_supported( -Wno-literal-suffix -Wno-c++14-compat -Wno-noexcept-type) endif() if (LIBCXX_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) else() # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is # added elsewhere. add_compile_flags_if_supported(-Wno-error) endif() if (LIBCXX_ENABLE_PEDANTIC) add_compile_flags_if_supported(-pedantic) endif() if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS) add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) endif() # Exception flags ============================================================= if (LIBCXX_ENABLE_EXCEPTIONS) # Catches C++ exceptions only and tells the compiler to assume that extern C # functions never throw a C++ exception. add_compile_flags_if_supported(-EHsc) else() add_definitions(-D_LIBCPP_NO_EXCEPTIONS) add_compile_flags_if_supported(-EHs- -EHa-) add_compile_flags_if_supported(-fno-exceptions) endif() # RTTI flags ================================================================== if (NOT LIBCXX_ENABLE_RTTI) add_definitions(-D_LIBCPP_NO_RTTI) add_compile_flags_if_supported(-GR-) add_compile_flags_if_supported(-fno-rtti) endif() # Threading flags ============================================================= if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED) # Need to allow unresolved symbols if this is to work with shared library builds if (APPLE) add_link_flags("-undefined dynamic_lookup") else() # Relax this restriction from HandleLLVMOptions string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") endif() endif() # Assertion flags ============================================================= define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) define_if(LIBCXX_ENABLE_ASSERTIONS -D_LIBCPP_DEBUG=0) define_if(LIBCXX_DEBUG_BUILD -D_DEBUG) if (LIBCXX_ENABLE_ASSERTIONS AND NOT LIBCXX_DEBUG_BUILD) # MSVC doesn't like _DEBUG on release builds. See PR 4379. define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG) endif() # Modules flags =============================================================== # FIXME The libc++ sources are fundamentally non-modular. They need special # versions of the headers in order to provide C++03 and legacy ABI definitions. # NOTE: The public headers can be used with modules in all other contexts. if (LLVM_ENABLE_MODULES) # Ignore that the rest of the modules flags are now unused. add_compile_flags_if_supported(-Wno-unused-command-line-argument) add_compile_flags(-fno-modules) endif() # Sanitizer flags ============================================================= # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. if (LIBCXX_STANDALONE_BUILD) set(LLVM_USE_SANITIZER "" CACHE STRING "Define the sanitizer used to build the library and tests") # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. if (LLVM_USE_SANITIZER AND NOT MSVC) add_flags_if_supported("-fno-omit-frame-pointer") add_flags_if_supported("-gline-tables-only") if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") add_flags_if_supported("-gline-tables-only") endif() if (LLVM_USE_SANITIZER STREQUAL "Address") add_flags("-fsanitize=address") elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") add_flags(-fsanitize=memory) if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") add_flags("-fsanitize-memory-track-origins") endif() elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") elseif (LLVM_USE_SANITIZER STREQUAL "Thread") add_flags(-fsanitize=thread) else() message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") endif() elseif(LLVM_USE_SANITIZER AND MSVC) message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") endif() endif() # Configuration file flags ===================================================== if (NOT LIBCXX_ABI_VERSION EQUAL "1") config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) endif() config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) 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) config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) # 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. if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) message(STATUS "Generating custom __config for non-DLL Windows build") config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) endif() if (LIBCXX_NEEDS_SITE_CONFIG) configure_file("include/__config_site.in" "${LIBCXX_BINARY_DIR}/__config_site" @ONLY) # Provide the config definitions by included the generated __config_site # file at compile time. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") add_compile_flags("/FI\"${LIBCXX_BINARY_DIR}/__config_site\"") else() add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") endif() endif() #=============================================================================== # Setup Source Code And Tests #=============================================================================== include_directories(include) add_subdirectory(include) add_subdirectory(lib) if (LIBCXX_INCLUDE_BENCHMARKS) add_subdirectory(benchmarks) endif() # Create the lit.site.cfg file even when LIBCXX_INCLUDE_TESTS is OFF or # LLVM_FOUND is OFF. This allows users to run the tests manually using # LIT without requiring a full LLVM checkout. # # However, since some submission systems strip test/ subdirectories, check for # it before adding it. if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test") add_subdirectory(test) endif() if (LIBCXX_INCLUDE_TESTS) add_subdirectory(lib/abi) endif() if (LIBCXX_INCLUDE_DOCS) add_subdirectory(docs) endif() Index: vendor/libc++/dist/include/__config =================================================================== --- vendor/libc++/dist/include/__config (revision 320379) +++ vendor/libc++/dist/include/__config (revision 320380) @@ -1,1244 +1,1255 @@ // -*- C++ -*- //===--------------------------- __config ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_CONFIG #define _LIBCPP_CONFIG #if defined(_MSC_VER) && !defined(__clang__) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #endif #endif #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif #ifdef __cplusplus #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) // The _GNUC_VER_NEW macro better represents the new GCC versioning scheme // introduced in GCC 5.0. #define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) #else #define _GNUC_VER 0 #define _GNUC_VER_NEW 0 #endif #define _LIBCPP_VERSION 5000 #ifndef _LIBCPP_ABI_VERSION #define _LIBCPP_ABI_VERSION 1 #endif #if defined(__ELF__) #define _LIBCPP_OBJECT_FORMAT_ELF 1 #elif defined(__MACH__) #define _LIBCPP_OBJECT_FORMAT_MACHO 1 #elif defined(_WIN32) #define _LIBCPP_OBJECT_FORMAT_COFF 1 #else #error Unknown object file format #endif #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 // Change short string representation so that string data starts at offset 0, // improving its alignment in some cases. #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT // Fix deque iterator type in order to support incomplete types. #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE // Fix undefined behavior in how std::list stores it's linked nodes. #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB // Fix undefined behavior in how __tree stores its end and parent nodes. #define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB // Fix undefined behavior in how __hash_table stores it's pointer types #define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB #define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr // provided under the alternate keyword __nullptr, which changes the mangling // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. #define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR // Define the `pointer_safety` enum as a C++11 strongly typed enumeration // instead of as a class simulating an enum. If this option is enabled // `pointer_safety` and `get_pointer_safety()` will no longer be available // in C++03. #define _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE // Define a key function for `bad_function_call` in the library, to centralize // its vtable and typeinfo to libc++ rather than having all other libraries // using that class define their own copies. #define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION // Enable optimized version of __do_get_(un)signed which avoids redundant copies. #define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET #elif _LIBCPP_ABI_VERSION == 1 #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support // applications compiled against older libraries. This is unnecessary with // COFF dllexport semantics, since dllexport forces a non-inline definition // of inline functions to be emitted anyway. Our own non-inline copy would // conflict with the dllexport-emitted copy, so we disable it. #define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS #endif // Feature macros for disabling pre ABI v1 features. All of these options // are deprecated. #if defined(__FreeBSD__) #define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR #endif #endif #ifdef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR #error "_LIBCPP_TRIVIAL_PAIR_COPY_CTOR" is no longer supported. \ use _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR instead #endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #if __cplusplus < 201103L #define _LIBCPP_CXX03_LANG #endif #ifndef __has_attribute #define __has_attribute(__x) 0 #endif #ifndef __has_builtin #define __has_builtin(__x) 0 #endif #ifndef __has_extension #define __has_extension(__x) 0 #endif #ifndef __has_feature #define __has_feature(__x) 0 #endif // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by // the compiler and '1' otherwise. #ifndef __is_identifier #define __is_identifier(__x) 1 #endif #ifndef __has_declspec_attribute #define __has_declspec_attribute(__x) 0 #endif #define __has_keyword(__x) !(__is_identifier(__x)) #ifdef __has_include #define __libcpp_has_include(__x) __has_include(__x) #else #define __libcpp_has_include(__x) 0 #endif #if defined(__clang__) #define _LIBCPP_COMPILER_CLANG # ifndef __apple_build_version__ # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) # endif #elif defined(__GNUC__) #define _LIBCPP_COMPILER_GCC #elif defined(_MSC_VER) #define _LIBCPP_COMPILER_MSVC #elif defined(__IBMCPP__) #define _LIBCPP_COMPILER_IBM #endif #ifndef _LIBCPP_CLANG_VER #define _LIBCPP_CLANG_VER 0 #endif // FIXME: ABI detection should be done via compiler builtin macros. This // is just a placeholder until Clang implements such macros. For now assume // that Windows compilers pretending to be MSVC++ target the microsoft ABI. #if defined(_WIN32) && defined(_MSC_VER) # define _LIBCPP_ABI_MICROSOFT #else # define _LIBCPP_ABI_ITANIUM #endif // Need to detect which libc we're using if we're on Linux. #if defined(__linux__) #include #if !defined(__GLIBC_PREREQ) #define __GLIBC_PREREQ(a, b) 0 #endif // !defined(__GLIBC_PREREQ) #endif // defined(__linux__) #ifdef __LITTLE_ENDIAN__ #if __LITTLE_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 1 #define _LIBCPP_BIG_ENDIAN 0 #endif // __LITTLE_ENDIAN__ #endif // __LITTLE_ENDIAN__ #ifdef __BIG_ENDIAN__ #if __BIG_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 0 #define _LIBCPP_BIG_ENDIAN 1 #endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ #ifdef __BYTE_ORDER__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 1 #define _LIBCPP_BIG_ENDIAN 0 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define _LIBCPP_LITTLE_ENDIAN 0 #define _LIBCPP_BIG_ENDIAN 1 #endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #endif // __BYTE_ORDER__ #ifdef __FreeBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif // _BYTE_ORDER == _LITTLE_ENDIAN # ifndef __LONG_LONG_SUPPORTED # define _LIBCPP_HAS_NO_LONG_LONG # endif // __LONG_LONG_SUPPORTED #endif // __FreeBSD__ #ifdef __NetBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_HAS_QUICK_EXIT #endif // __NetBSD__ #if defined(_WIN32) # define _LIBCPP_WIN32API # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # define _LIBCPP_SHORT_WCHAR 1 // Both MinGW and native MSVC provide a "MSVC"-like enviroment # define _LIBCPP_MSVCRT_LIKE // If mingw not explicitly detected, assume using MS C runtime only. # ifndef __MINGW32__ # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) # define _LIBCPP_HAS_BITSCAN64 # endif # if defined(_LIBCPP_MSVCRT) # define _LIBCPP_HAS_QUICK_EXIT # endif // Some CRT APIs are unavailable to store apps #if defined(WINAPI_FAMILY) #include #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ (!defined(WINAPI_PARTITION_SYSTEM) || \ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) #define _LIBCPP_WINDOWS_STORE_APP #endif #endif #endif // defined(_WIN32) #ifdef __sun__ # include # ifdef _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # else # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # endif #endif // __sun__ #if defined(__CloudABI__) // Certain architectures provide arc4random(). Prefer using // arc4random() over /dev/{u,}random to make it possible to obtain // random data even when using sandboxing mechanisms such as chroots, // Capsicum, etc. # define _LIBCPP_USING_ARC4_RANDOM #elif defined(__native_client__) // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, // including accesses to the special files under /dev. C++11's // std::random_device is instead exposed through a NaCl syscall. # define _LIBCPP_USING_NACL_RANDOM #elif defined(_LIBCPP_WIN32API) # define _LIBCPP_USING_WIN32_RANDOM #else # define _LIBCPP_USING_DEV_RANDOM #endif #if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) # include # if __BYTE_ORDER == __LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # elif __BYTE_ORDER == __BIG_ENDIAN # define _LIBCPP_LITTLE_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 1 # else // __BYTE_ORDER == __BIG_ENDIAN # error unable to determine endian # endif #endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN) #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) #define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) #else #define _LIBCPP_NO_CFI #endif #if defined(_LIBCPP_COMPILER_CLANG) // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \ defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #endif #if __has_feature(cxx_alignas) # define _ALIGNAS_TYPE(x) alignas(x) # define _ALIGNAS(x) alignas(x) #else # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) # define _ALIGNAS(x) __attribute__((__aligned__(x))) #endif #if __cplusplus < 201103L typedef __char16_t char16_t; typedef __char32_t char32_t; #endif #if !(__has_feature(cxx_exceptions)) && !defined(_LIBCPP_NO_EXCEPTIONS) #define _LIBCPP_NO_EXCEPTIONS #endif #if !(__has_feature(cxx_rtti)) && !defined(_LIBCPP_NO_RTTI) #define _LIBCPP_NO_RTTI #endif #if !(__has_feature(cxx_strong_enums)) #define _LIBCPP_HAS_NO_STRONG_ENUMS #endif #if !(__has_feature(cxx_decltype)) #define _LIBCPP_HAS_NO_DECLTYPE #endif #if __has_feature(cxx_attributes) # define _LIBCPP_NORETURN [[noreturn]] #else # define _LIBCPP_NORETURN __attribute__ ((noreturn)) #endif #if !(__has_feature(cxx_lambdas)) #define _LIBCPP_HAS_NO_LAMBDAS #endif #if !(__has_feature(cxx_nullptr)) # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) # define nullptr __nullptr # else # define _LIBCPP_HAS_NO_NULLPTR # endif #endif #if !(__has_feature(cxx_rvalue_references)) #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if !(__has_feature(cxx_auto_type)) #define _LIBCPP_HAS_NO_AUTO_TYPE #endif #if !(__has_feature(cxx_variadic_templates)) #define _LIBCPP_HAS_NO_VARIADICS #endif #if !(__has_feature(cxx_generalized_initializers)) #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif #if __has_feature(is_base_of) # define _LIBCPP_HAS_IS_BASE_OF #endif #if __has_feature(is_final) # define _LIBCPP_HAS_IS_FINAL #endif // Objective-C++ features (opt-in) #if __has_feature(objc_arc) #define _LIBCPP_HAS_OBJC_ARC #endif #if __has_feature(objc_arc_weak) #define _LIBCPP_HAS_OBJC_ARC_WEAK #endif #if !(__has_feature(cxx_constexpr)) #define _LIBCPP_HAS_NO_CONSTEXPR #endif #if !(__has_feature(cxx_relaxed_constexpr)) #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #endif #if !(__has_feature(cxx_variable_templates)) #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #endif #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L #if defined(__FreeBSD__) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #elif defined(__Fuchsia__) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #elif defined(__linux__) #if !defined(_LIBCPP_HAS_MUSL_LIBC) #if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__) #define _LIBCPP_HAS_QUICK_EXIT #endif #if __GLIBC_PREREQ(2, 17) #define _LIBCPP_HAS_C11_FEATURES #endif #else // defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_C11_FEATURES #endif #endif // __linux__ #endif #if !(__has_feature(cxx_noexcept)) #define _LIBCPP_HAS_NO_NOEXCEPT #endif #if __has_feature(underlying_type) # define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) #endif #if __has_feature(is_literal) # define _LIBCPP_IS_LITERAL(T) __is_literal(T) #endif // Inline namespaces are available in Clang regardless of C++ dialect. #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer) #define _LIBCPP_HAS_NO_ASAN #endif // Allow for build-time disabling of unsigned integer sanitization #if !defined(_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && __has_attribute(no_sanitize) #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #endif #elif defined(_LIBCPP_COMPILER_GCC) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _LIBCPP_NORETURN __attribute__((noreturn)) #if _GNUC_VER >= 407 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T) #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T) #define _LIBCPP_HAS_IS_FINAL #endif #if defined(__GNUC__) && _GNUC_VER >= 403 # define _LIBCPP_HAS_IS_BASE_OF #endif #if !__EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS #endif // constexpr was added to GCC in 4.6. #if _GNUC_VER < 406 #define _LIBCPP_HAS_NO_CONSTEXPR // Can only use constexpr in c++11 mode. #elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L #define _LIBCPP_HAS_NO_CONSTEXPR #endif // Determine if GCC supports relaxed constexpr #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #endif // GCC 5 will support variable templates #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #endif #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_HAS_NO_NOEXCEPT #else // __GXX_EXPERIMENTAL_CXX0X__ #if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _GNUC_VER < 404 #if _GNUC_VER < 406 #define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NULLPTR #endif #endif // __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__) #define _LIBCPP_HAS_NO_ASAN #endif #elif defined(_LIBCPP_COMPILER_MSVC) #define _LIBCPP_TOSTRING2(x) #x #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) #if _MSC_VER < 1900 #error "MSVC versions prior to Visual Studio 2015 are not supported" #endif #define _LIBCPP_HAS_IS_BASE_OF #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #if _MSC_VER <= 1800 #define _LIBCPP_HAS_NO_UNICODE_CHARS #endif #define _LIBCPP_HAS_NO_NOEXCEPT #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std # define _LIBCPP_WEAK namespace std { } #define _LIBCPP_HAS_NO_ASAN #elif defined(_LIBCPP_COMPILER_IBM) #define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ATTRIBUTE(x) __attribute__((x)) #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_IS_BASE_OF #define _LIBCPP_HAS_IS_FINAL #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #if defined(_AIX) #define __MULTILOCALE_API #endif #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { #define _LIBCPP_END_NAMESPACE_STD } } #define _VSTD std::_LIBCPP_NAMESPACE namespace std { inline namespace _LIBCPP_NAMESPACE { } } #define _LIBCPP_HAS_NO_ASAN #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] #if defined(_LIBCPP_OBJECT_FORMAT_COFF) #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_DLL_VIS # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS #elif defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_DLL_VIS __declspec(dllexport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS #else # define _LIBCPP_DLL_VIS __declspec(dllimport) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS #endif #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS #define _LIBCPP_EXTERN_VIS _LIBCPP_DLL_VIS #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS #define _LIBCPP_HIDDEN #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS #define _LIBCPP_TEMPLATE_VIS #define _LIBCPP_FUNC_VIS_ONLY #define _LIBCPP_ENUM_VIS #if defined(_LIBCPP_COMPILER_MSVC) # define _LIBCPP_INLINE_VISIBILITY __forceinline # define _LIBCPP_ALWAYS_INLINE __forceinline # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline #else # define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) # define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__)) #endif #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) #ifndef _LIBCPP_HIDDEN #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) #else #define _LIBCPP_HIDDEN #endif #endif #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) // The inline should be removed once PR32114 is resolved #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN #else #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS #endif #endif #ifndef _LIBCPP_FUNC_VIS #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) #else #define _LIBCPP_FUNC_VIS #endif #endif #ifndef _LIBCPP_TYPE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_TYPE_VIS # endif #endif #ifndef _LIBCPP_TEMPLATE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # if __has_attribute(__type_visibility__) # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) # endif # else # define _LIBCPP_TEMPLATE_VIS # endif #endif #ifndef _LIBCPP_FUNC_VIS_ONLY # define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS #endif #ifndef _LIBCPP_EXTERN_VIS # define _LIBCPP_EXTERN_VIS #endif #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS #endif #ifndef _LIBCPP_EXCEPTION_ABI #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) #else #define _LIBCPP_EXCEPTION_ABI #endif #endif #ifndef _LIBCPP_ENUM_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) # else # define _LIBCPP_ENUM_VIS # endif #endif #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) # else # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS # endif #endif #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS #endif #ifndef _LIBCPP_INLINE_VISIBILITY #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) #else #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__)) #endif #endif #ifndef _LIBCPP_ALWAYS_INLINE #if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #else #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) #endif #endif #ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__)) # else # define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__always_inline__)) # endif #endif #ifndef _LIBCPP_PREFERRED_OVERLOAD # if __has_attribute(__enable_if__) # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) # endif #endif #ifndef _LIBCPP_HAS_NO_NOEXCEPT # define _NOEXCEPT noexcept # define _NOEXCEPT_(x) noexcept(x) #else # define _NOEXCEPT throw() # define _NOEXCEPT_(x) #endif #if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) # if !defined(_LIBCPP_DEBUG) # error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined # endif # define _NOEXCEPT_DEBUG noexcept(false) # define _NOEXCEPT_DEBUG_(x) noexcept(false) #else # define _NOEXCEPT_DEBUG _NOEXCEPT # define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x) #endif #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS #ifndef __SIZEOF_INT128__ #define _LIBCPP_HAS_NO_INT128 #endif #ifdef _LIBCPP_CXX03_LANG # if __has_extension(c_static_assert) # define static_assert(__b, __m) _Static_assert(__b, __m) # else extern "C++" { template struct __static_assert_test; template <> struct __static_assert_test {}; template struct __static_assert_check {}; } #define static_assert(__b, __m) \ typedef __static_assert_check)> \ _LIBCPP_CONCAT(__t, __LINE__) # endif // __has_extension(c_static_assert) #endif // _LIBCPP_CXX03_LANG #ifdef _LIBCPP_HAS_NO_DECLTYPE // GCC 4.6 provides __decltype in all standard modes. #if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406 # define decltype(__x) __decltype(__x) #else # define decltype(__x) __typeof__(__x) #endif #endif #ifdef _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_CONSTEXPR #else #define _LIBCPP_CONSTEXPR constexpr #endif #ifdef _LIBCPP_CXX03_LANG #define _LIBCPP_DEFAULT {} #else #define _LIBCPP_DEFAULT = default; #endif #ifdef _LIBCPP_CXX03_LANG #define _LIBCPP_EQUAL_DELETE #else #define _LIBCPP_EQUAL_DELETE = delete #endif #ifdef __GNUC__ #define _NOALIAS __attribute__((__malloc__)) #else #define _NOALIAS #endif #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions # define _LIBCPP_EXPLICIT explicit #else # define _LIBCPP_EXPLICIT #endif #if !__has_builtin(__builtin_operator_new) || !__has_builtin(__builtin_operator_delete) # define _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE #endif #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ __lx __v_; \ _LIBCPP_ALWAYS_INLINE x(__lx __v) : __v_(__v) {} \ _LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ }; #else // _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS #ifdef _LIBCPP_DEBUG # if _LIBCPP_DEBUG == 0 # define _LIBCPP_DEBUG_LEVEL 1 # elif _LIBCPP_DEBUG == 1 # define _LIBCPP_DEBUG_LEVEL 2 # else # error Supported values for _LIBCPP_DEBUG are 0 and 1 # endif # if !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_EXTERN_TEMPLATE(...) # endif #endif #ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) #define _LIBCPP_EXTERN_TEMPLATE2(...) #endif #ifndef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #endif #ifndef _LIBCPP_EXTERN_TEMPLATE2 #define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \ defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) #define _LIBCPP_LOCALE__L_EXTENSIONS 1 #endif #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. #if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_CATOPEN 1 #endif #endif #ifdef __FreeBSD__ #define _DECLARE_C99_LDBL_MATH 1 #endif #if defined(__APPLE__) # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) # define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ # endif # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) # if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION # endif # endif #endif // defined(__APPLE__) #if defined(__APPLE__) || defined(__FreeBSD__) #define _LIBCPP_HAS_DEFAULTRUNELOCALE #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) #define _LIBCPP_WCTYPE_IS_MASK #endif #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 # elif __cplusplus <= 201402L # define _LIBCPP_STD_VER 14 # else # define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification # endif #endif // _LIBCPP_STD_VER #if _LIBCPP_STD_VER > 11 #define _LIBCPP_DEPRECATED [[deprecated]] #else #define _LIBCPP_DEPRECATED #endif #if _LIBCPP_STD_VER <= 11 #define _LIBCPP_EXPLICIT_AFTER_CXX11 #define _LIBCPP_DEPRECATED_AFTER_CXX11 #else #define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit #define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] #endif #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr #else #define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) #define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr #else #define _LIBCPP_CONSTEXPR_AFTER_CXX14 #endif // FIXME: Remove all usages of this macro once compilers catch up. #if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L) # define _LIBCPP_HAS_NO_INLINE_VARIABLES #endif #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) #else # define _LIBCPP_EXPLICIT_MOVE(x) (x) #endif #ifndef _LIBCPP_HAS_NO_ASAN _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); #endif // Try to find out if RTTI is disabled. // g++ and cl.exe have RTTI on by default and define a macro when it is. // g++ only defines the macro in 4.3.2 and onwards. #if !defined(_LIBCPP_NO_RTTI) # if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI # elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) # define _LIBCPP_NO_RTTI # endif #endif #ifndef _LIBCPP_WEAK # define _LIBCPP_WEAK __attribute__((__weak__)) #endif // Thread API #if !defined(_LIBCPP_HAS_NO_THREADS) && \ !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) # if defined(__FreeBSD__) || \ defined(__Fuchsia__) || \ defined(__NetBSD__) || \ defined(__linux__) || \ defined(__APPLE__) || \ defined(__CloudABI__) || \ defined(__sun__) || \ (defined(__MINGW32__) && __libcpp_has_include()) # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(_LIBCPP_WIN32API) # define _LIBCPP_HAS_THREAD_API_WIN32 # else # error "No thread API" # endif // _LIBCPP_HAS_THREAD_API #endif // _LIBCPP_HAS_NO_THREADS #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ _LIBCPP_HAS_NO_THREADS is not defined. #endif #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ _LIBCPP_HAS_NO_THREADS is defined. #endif #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ _LIBCPP_HAS_NO_THREADS is defined. #endif // Systems that use capability-based security (FreeBSD with Capsicum, // Nuxi CloudABI) may only provide local filesystem access (using *at()). // Functions like open(), rename(), unlink() and stat() should not be // used, as they attempt to access the global filesystem namespace. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE #endif // CloudABI is intended for running networked services. Processes do not // have standard input and output channels. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_STDIN #define _LIBCPP_HAS_NO_STDOUT #endif #if defined(__BIONIC__) || defined(__CloudABI__) || \ defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif // Thread-unsafe functions such as strtok() and localtime() // are not available. #ifdef __CloudABI__ #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #endif #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) #define _LIBCPP_HAS_C_ATOMIC_IMP #elif _GNUC_VER > 407 #define _LIBCPP_HAS_GCC_ATOMIC_IMP #endif #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ || defined(_LIBCPP_HAS_NO_THREADS) #define _LIBCPP_HAS_NO_ATOMIC_HEADER #endif #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #endif #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) #if defined(__clang__) && __has_attribute(acquire_capability) // Work around the attribute handling in clang. When both __declspec and // __attribute__ are present, the processing goes awry preventing the definition // of the types. #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS #endif #endif #endif #if __has_attribute(require_constant_initialization) #define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) #else #define _LIBCPP_SAFE_STATIC #endif #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 # define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF #endif #if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) #if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) #define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS #endif #endif #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) # define _LIBCPP_DIAGNOSE_WARNING(...) \ __attribute__((diagnose_if(__VA_ARGS__, "warning"))) # define _LIBCPP_DIAGNOSE_ERROR(...) \ __attribute__((diagnose_if(__VA_ARGS__, "error"))) #else # define _LIBCPP_DIAGNOSE_WARNING(...) # define _LIBCPP_DIAGNOSE_ERROR(...) #endif #if __has_attribute(fallthough) || _GNUC_VER >= 700 // Use a function like macro to imply that it must be followed by a semicolon #define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) #else #define _LIBCPP_FALLTHROUGH() ((void)0) #endif #if defined(_LIBCPP_ABI_MICROSOFT) && \ (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) #else # define _LIBCPP_DECLSPEC_EMPTY_BASES #endif #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 # define _LIBCPP_HAS_NO_DEDUCTION_GUIDES #endif #if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) # define _LIBCPP_HAS_NO_IS_AGGREGATE #endif #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L # define _LIBCPP_HAS_NO_COROUTINES #endif // Decide whether to use availability macros. #if !defined(_LIBCPP_BUILDING_LIBRARY) && \ !defined(_LIBCPP_DISABLE_AVAILABILITY) && \ __has_feature(attribute_availability_with_strict) && \ __has_feature(attribute_availability_in_templates) #ifdef __APPLE__ #define _LIBCPP_USE_AVAILABILITY_APPLE #endif #endif // Define availability macros. #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) #define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ __attribute__((availability(macosx,strict,introduced=10.12))) \ __attribute__((availability(ios,strict,introduced=10.0))) \ __attribute__((availability(tvos,strict,introduced=10.0))) \ __attribute__((availability(watchos,strict,introduced=3.0))) #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable)) +#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable)) #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ __attribute__((availability(macosx,strict,introduced=10.12))) \ __attribute__((availability(ios,strict,introduced=10.0))) \ __attribute__((availability(tvos,strict,introduced=10.0))) \ __attribute__((availability(watchos,strict,introduced=3.0))) #define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ __attribute__((availability(macosx,strict,introduced=10.12))) \ __attribute__((availability(ios,strict,introduced=10.0))) \ __attribute__((availability(tvos,strict,introduced=10.0))) \ __attribute__((availability(watchos,strict,introduced=3.0))) #define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ __attribute__((availability(ios,strict,introduced=6.0))) #define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ __attribute__((availability(macosx,strict,introduced=10.9))) \ __attribute__((availability(ios,strict,introduced=7.0))) #define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ __attribute__((availability(macosx,strict,introduced=10.9))) \ __attribute__((availability(ios,strict,introduced=7.0))) #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ __attribute__((availability(macosx,strict,introduced=10.9))) \ __attribute__((availability(ios,strict,introduced=7.0))) +#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION \ + __attribute__((availability(macosx,strict,introduced=10.13))) \ + __attribute__((availability(ios,strict,introduced=11.0))) \ + __attribute__((availability(tvos,strict,introduced=11.0))) \ + __attribute__((availability(watchos,strict,introduced=4.0))) #else #define _LIBCPP_AVAILABILITY_SHARED_MUTEX #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS #define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH +#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST #define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS #define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE #define _LIBCPP_AVAILABILITY_FUTURE_ERROR #define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE #define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY #define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR +#define _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION #endif // Define availability that depends on _LIBCPP_NO_EXCEPTIONS. #ifdef _LIBCPP_NO_EXCEPTIONS #define _LIBCPP_AVAILABILITY_DYNARRAY #define _LIBCPP_AVAILABILITY_FUTURE +#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST #else #define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH #define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR +#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \ + _LIBCPP_AVAILABILITY_BAD_ANY_CAST #endif // Availability of stream API in the dylib got dropped and re-added. The // extern template should effectively be available at: // availability(macosx,introduced=10.9) // availability(ios,introduced=7.0) #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \ ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1090) || \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \ (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ <= 70000)) + __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000)) #define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE #endif #if defined(_LIBCPP_COMPILER_IBM) #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO #endif #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) # define _LIBCPP_PUSH_MACROS # define _LIBCPP_POP_MACROS #else // Don't warn about macro conflicts when we can restore them at the // end of the header. # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS # endif # if defined(_LIBCPP_COMPILER_MSVC) # define _LIBCPP_PUSH_MACROS \ __pragma(push_macro("min")) \ __pragma(push_macro("max")) # define _LIBCPP_POP_MACROS \ __pragma(pop_macro("min")) \ __pragma(pop_macro("max")) # else # define _LIBCPP_PUSH_MACROS \ _Pragma("push_macro(\"min\")") \ _Pragma("push_macro(\"max\")") # define _LIBCPP_POP_MACROS \ _Pragma("pop_macro(\"min\")") \ _Pragma("pop_macro(\"max\")") # endif #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) #endif // __cplusplus #endif // _LIBCPP_CONFIG Index: vendor/libc++/dist/include/experimental/any =================================================================== --- vendor/libc++/dist/include/experimental/any (revision 320379) +++ vendor/libc++/dist/include/experimental/any (revision 320380) @@ -1,591 +1,592 @@ // -*- C++ -*- //===------------------------------ any -----------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_EXPERIMENTAL_ANY #define _LIBCPP_EXPERIMENTAL_ANY /* experimental/any synopsis namespace std { namespace experimental { inline namespace fundamentals_v1 { class bad_any_cast : public bad_cast { public: virtual const char* what() const noexcept; }; class any { public: // 6.3.1 any construct/destruct any() noexcept; any(const any& other); any(any&& other) noexcept; template any(ValueType&& value); ~any(); // 6.3.2 any assignments any& operator=(const any& rhs); any& operator=(any&& rhs) noexcept; template any& operator=(ValueType&& rhs); // 6.3.3 any modifiers void clear() noexcept; void swap(any& rhs) noexcept; // 6.3.4 any observers bool empty() const noexcept; const type_info& type() const noexcept; }; // 6.4 Non-member functions void swap(any& x, any& y) noexcept; template ValueType any_cast(const any& operand); template ValueType any_cast(any& operand); template ValueType any_cast(any&& operand); template const ValueType* any_cast(const any* operand) noexcept; template ValueType* any_cast(any* operand) noexcept; } // namespace fundamentals_v1 } // namespace experimental } // namespace std */ #include #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_LFTS -class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { public: virtual const char* what() const _NOEXCEPT; }; #if _LIBCPP_STD_VER > 11 // C++ > 11 _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_any_cast(); #else _VSTD::abort(); #endif } // Forward declarations class any; template typename add_pointer::type>::type _LIBCPP_INLINE_VISIBILITY any_cast(any const *) _NOEXCEPT; template typename add_pointer<_ValueType>::type _LIBCPP_INLINE_VISIBILITY any_cast(any *) _NOEXCEPT; namespace __any_imp { typedef typename aligned_storage<3*sizeof(void*), alignment_of::value>::type _Buffer; template struct _IsSmallObject : public integral_constant::value % alignment_of<_Tp>::value == 0 && is_nothrow_move_constructible<_Tp>::value > {}; enum class _Action { _Destroy, _Copy, _Move, _Get, _TypeInfo }; template struct _SmallHandler; template struct _LargeHandler; template using _Handler = typename conditional<_IsSmallObject<_Tp>::value , _SmallHandler<_Tp> , _LargeHandler<_Tp> >::type; template using _EnableIfNotAny = typename enable_if< !is_same::type, any>::value >::type; } // namespace __any_imp class any { public: // 6.3.1 any construct/destruct _LIBCPP_INLINE_VISIBILITY any() _NOEXCEPT : __h(nullptr) {} _LIBCPP_INLINE_VISIBILITY any(any const & __other) : __h(nullptr) { if (__other.__h) __other.__call(_Action::_Copy, this); } _LIBCPP_INLINE_VISIBILITY any(any && __other) _NOEXCEPT : __h(nullptr) { if (__other.__h) __other.__call(_Action::_Move, this); } template < class _ValueType , class = __any_imp::_EnableIfNotAny<_ValueType> > _LIBCPP_INLINE_VISIBILITY any(_ValueType && __value); _LIBCPP_INLINE_VISIBILITY ~any() { this->clear(); } // 6.3.2 any assignments _LIBCPP_INLINE_VISIBILITY any & operator=(any const & __rhs) { any(__rhs).swap(*this); return *this; } _LIBCPP_INLINE_VISIBILITY any & operator=(any && __rhs) _NOEXCEPT { any(_VSTD::move(__rhs)).swap(*this); return *this; } template < class _ValueType , class = __any_imp::_EnableIfNotAny<_ValueType> > _LIBCPP_INLINE_VISIBILITY any & operator=(_ValueType && __rhs); // 6.3.3 any modifiers _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); } _LIBCPP_INLINE_VISIBILITY void swap(any & __rhs) _NOEXCEPT; // 6.3.4 any observers _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return __h == nullptr; } #if !defined(_LIBCPP_NO_RTTI) _LIBCPP_INLINE_VISIBILITY const type_info & type() const _NOEXCEPT { if (__h) { return *static_cast(this->__call(_Action::_TypeInfo)); } else { return typeid(void); } } #endif private: typedef __any_imp::_Action _Action; typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *); union _Storage { void * __ptr; __any_imp::_Buffer __buf; }; _LIBCPP_ALWAYS_INLINE void * __call(_Action __a, any * __other = nullptr, type_info const * __info = nullptr) const { return __h(__a, this, __other, __info); } _LIBCPP_ALWAYS_INLINE void * __call(_Action __a, any * __other = nullptr, type_info const * __info = nullptr) { return __h(__a, this, __other, __info); } template friend struct __any_imp::_SmallHandler; template friend struct __any_imp::_LargeHandler; template friend typename add_pointer::type>::type any_cast(any const *) _NOEXCEPT; template friend typename add_pointer<_ValueType>::type any_cast(any *) _NOEXCEPT; _HandleFuncPtr __h; _Storage __s; }; namespace __any_imp { template struct _LIBCPP_TEMPLATE_VIS _SmallHandler { _LIBCPP_INLINE_VISIBILITY static void* __handle(_Action __act, any const * __this, any * __other, type_info const * __info) { switch (__act) { case _Action::_Destroy: __destroy(const_cast(*__this)); return nullptr; case _Action::_Copy: __copy(*__this, *__other); return nullptr; case _Action::_Move: __move(const_cast(*__this), *__other); return nullptr; case _Action::_Get: return __get(const_cast(*__this), __info); case _Action::_TypeInfo: return __type_info(); } } template _LIBCPP_INLINE_VISIBILITY static void __create(any & __dest, _Up && __v) { ::new (static_cast(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v)); __dest.__h = &_SmallHandler::__handle; } private: _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __destroy(any & __this) { _Tp & __value = *static_cast<_Tp *>(static_cast(&__this.__s.__buf)); __value.~_Tp(); __this.__h = nullptr; } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __copy(any const & __this, any & __dest) { _SmallHandler::__create(__dest, *static_cast<_Tp const *>( static_cast(&__this.__s.__buf))); } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __move(any & __this, any & __dest) { _SmallHandler::__create(__dest, _VSTD::move( *static_cast<_Tp*>(static_cast(&__this.__s.__buf)))); __destroy(__this); } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void* __get(any & __this, type_info const * __info) { #if !defined(_LIBCPP_NO_RTTI) if (typeid(_Tp) == *__info) { return static_cast(&__this.__s.__buf); } return nullptr; #else return static_cast(&__this.__s.__buf); #endif } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void* __type_info() { #if !defined(_LIBCPP_NO_RTTI) return const_cast(static_cast(&typeid(_Tp))); #else return nullptr; #endif } }; template struct _LIBCPP_TEMPLATE_VIS _LargeHandler { _LIBCPP_INLINE_VISIBILITY static void* __handle(_Action __act, any const * __this, any * __other, type_info const * __info) { switch (__act) { case _Action::_Destroy: __destroy(const_cast(*__this)); return nullptr; case _Action::_Copy: __copy(*__this, *__other); return nullptr; case _Action::_Move: __move(const_cast(*__this), *__other); return nullptr; case _Action::_Get: return __get(const_cast(*__this), __info); case _Action::_TypeInfo: return __type_info(); } } template _LIBCPP_INLINE_VISIBILITY static void __create(any & __dest, _Up && __v) { typedef allocator<_Tp> _Alloc; typedef __allocator_destructor<_Alloc> _Dp; _Alloc __a; unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v)); __dest.__s.__ptr = __hold.release(); __dest.__h = &_LargeHandler::__handle; } private: _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __destroy(any & __this) { delete static_cast<_Tp*>(__this.__s.__ptr); __this.__h = nullptr; } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __copy(any const & __this, any & __dest) { _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr)); } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void __move(any & __this, any & __dest) { __dest.__s.__ptr = __this.__s.__ptr; __dest.__h = &_LargeHandler::__handle; __this.__h = nullptr; } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void* __get(any & __this, type_info const * __info) { #if !defined(_LIBCPP_NO_RTTI) if (typeid(_Tp) == *__info) { return static_cast(__this.__s.__ptr); } return nullptr; #else return static_cast(__this.__s.__ptr); #endif } _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY static void* __type_info() { #if !defined(_LIBCPP_NO_RTTI) return const_cast(static_cast(&typeid(_Tp))); #else return nullptr; #endif } }; } // namespace __any_imp template any::any(_ValueType && __v) : __h(nullptr) { typedef typename decay<_ValueType>::type _Tp; static_assert(is_copy_constructible<_Tp>::value, "_ValueType must be CopyConstructible."); typedef __any_imp::_Handler<_Tp> _HandlerType; _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v)); } template any & any::operator=(_ValueType && __v) { typedef typename decay<_ValueType>::type _Tp; static_assert(is_copy_constructible<_Tp>::value, "_ValueType must be CopyConstructible."); any(_VSTD::forward<_ValueType>(__v)).swap(*this); return *this; } inline void any::swap(any & __rhs) _NOEXCEPT { if (__h && __rhs.__h) { any __tmp; __rhs.__call(_Action::_Move, &__tmp); this->__call(_Action::_Move, &__rhs); __tmp.__call(_Action::_Move, this); } else if (__h) { this->__call(_Action::_Move, &__rhs); } else if (__rhs.__h) { __rhs.__call(_Action::_Move, this); } } // 6.4 Non-member functions inline _LIBCPP_INLINE_VISIBILITY void swap(any & __lhs, any & __rhs) _NOEXCEPT { __lhs.swap(__rhs); } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const & __v) { static_assert( is_reference<_ValueType>::value || is_copy_constructible<_ValueType>::value, "_ValueType is required to be a reference or a CopyConstructible type."); typedef typename add_const::type>::type _Tp; _Tp * __tmp = any_cast<_Tp>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); return *__tmp; } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any & __v) { static_assert( is_reference<_ValueType>::value || is_copy_constructible<_ValueType>::value, "_ValueType is required to be a reference or a CopyConstructible type."); typedef typename remove_reference<_ValueType>::type _Tp; _Tp * __tmp = any_cast<_Tp>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); return *__tmp; } template -_LIBCPP_INLINE_VISIBILITY +_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any && __v) { static_assert( is_reference<_ValueType>::value || is_copy_constructible<_ValueType>::value, "_ValueType is required to be a reference or a CopyConstructible type."); typedef typename remove_reference<_ValueType>::type _Tp; _Tp * __tmp = any_cast<_Tp>(&__v); if (__tmp == nullptr) __throw_bad_any_cast(); return *__tmp; } template inline typename add_pointer::type>::type any_cast(any const * __any) _NOEXCEPT { static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a reference."); return any_cast<_ValueType>(const_cast(__any)); } template typename add_pointer<_ValueType>::type any_cast(any * __any) _NOEXCEPT { using __any_imp::_Action; static_assert(!is_reference<_ValueType>::value, "_ValueType may not be a reference."); typedef typename add_pointer<_ValueType>::type _ReturnType; if (__any && __any->__h) { return static_cast<_ReturnType>( __any->__call(_Action::_Get, nullptr, #if !defined(_LIBCPP_NO_RTTI) &typeid(_ValueType) #else nullptr #endif )); } return nullptr; } #endif // _LIBCPP_STD_VER > 11 _LIBCPP_END_NAMESPACE_LFTS #endif // _LIBCPP_EXPERIMENTAL_ANY Index: vendor/libc++/dist/include/new =================================================================== --- vendor/libc++/dist/include/new (revision 320379) +++ vendor/libc++/dist/include/new (revision 320380) @@ -1,255 +1,255 @@ // -*- C++ -*- //===----------------------------- new ------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_NEW #define _LIBCPP_NEW /* new synopsis namespace std { class bad_alloc : public exception { public: bad_alloc() noexcept; bad_alloc(const bad_alloc&) noexcept; bad_alloc& operator=(const bad_alloc&) noexcept; virtual const char* what() const noexcept; }; class bad_array_length : public bad_alloc // FIXME: Not part of C++ { public: bad_array_length() noexcept; }; class bad_array_new_length : public bad_alloc // C++14 { public: bad_array_new_length() noexcept; }; enum class align_val_t : size_t {}; // C++17 struct nothrow_t {}; extern const nothrow_t nothrow; typedef void (*new_handler)(); new_handler set_new_handler(new_handler new_p) noexcept; new_handler get_new_handler() noexcept; } // std void* operator new(std::size_t size); // replaceable void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17 void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable void* operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept; // replaceable, C++17 void operator delete(void* ptr) noexcept; // replaceable void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14 void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17 void operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept; // replaceable, C++17 void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable void operator delete(void* ptr, std:align_val_t alignment, const std::nothrow_t&) noexcept; // replaceable, C++17 void* operator new[](std::size_t size); // replaceable void* operator new[](std::size_t size, std::align_val_t alignment) noexcept; // replaceable, C++17 void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable void* operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept; // replaceable, C++17 void operator delete[](void* ptr) noexcept; // replaceable void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14 void operator delete[](void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17 void operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept; // replaceable, C++17 void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept; // replaceable, C++17 void* operator new (std::size_t size, void* ptr) noexcept; void* operator new[](std::size_t size, void* ptr) noexcept; void operator delete (void* ptr, void*) noexcept; void operator delete[](void* ptr, void*) noexcept; */ #include <__config> #include #include #ifdef _LIBCPP_NO_EXCEPTIONS #include #endif #if defined(_LIBCPP_ABI_MICROSOFT) #include #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #if !(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \ (defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)) # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION #endif #if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) && \ (!(defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER > 14 || \ (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606))) # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION #endif namespace std // purposefully not using versioning namespace { #if !defined(_LIBCPP_ABI_MICROSOFT) struct _LIBCPP_TYPE_VIS nothrow_t {}; extern _LIBCPP_FUNC_VIS const nothrow_t nothrow; class _LIBCPP_EXCEPTION_ABI bad_alloc : public exception { public: bad_alloc() _NOEXCEPT; virtual ~bad_alloc() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; class _LIBCPP_EXCEPTION_ABI bad_array_new_length : public bad_alloc { public: bad_array_new_length() _NOEXCEPT; virtual ~bad_array_new_length() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; typedef void (*new_handler)(); _LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT; _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; #endif // !_LIBCPP_ABI_MICROSOFT _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec #if defined(_LIBCPP_BUILDING_LIBRARY) || (_LIBCPP_STD_VER > 11) class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH bad_array_length : public bad_alloc { public: bad_array_length() _NOEXCEPT; virtual ~bad_array_length() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; #define _LIBCPP_BAD_ARRAY_LENGTH_DEFINED #endif // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) #if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || _LIBCPP_STD_VER > 14 #ifndef _LIBCPP_CXX03_LANG enum class _LIBCPP_ENUM_VIS align_val_t : size_t { }; #else enum align_val_t { __zero = 0, __max = (size_t)-1 }; #endif #endif } // std #if defined(_LIBCPP_CXX03_LANG) #define _THROW_BAD_ALLOC throw(std::bad_alloc) #else #define _THROW_BAD_ALLOC #endif #if !defined(_LIBCPP_ABI_MICROSOFT) _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; #endif _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; #endif #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; -_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; -_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::align_val_t) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION -_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; #endif -_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; -_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; -_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION -_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; +_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_ALIGNED_ALLOCATION void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; #endif #endif inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {} inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {} #endif // !_LIBCPP_ABI_MICROSOFT _LIBCPP_BEGIN_NAMESPACE_STD inline _LIBCPP_INLINE_VISIBILITY void *__allocate(size_t __size) { #ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE return ::operator new(__size); #else return __builtin_operator_new(__size); #endif } inline _LIBCPP_INLINE_VISIBILITY void __libcpp_deallocate(void *__ptr) { #ifdef _LIBCPP_HAS_NO_BUILTIN_OPERATOR_NEW_DELETE ::operator delete(__ptr); #else __builtin_operator_delete(__ptr); #endif } #ifdef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE #ifndef _LIBCPP_NO_EXCEPTIONS _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH #endif void __throw_bad_array_length() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_array_length(); #else _VSTD::abort(); #endif } #endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_NEW Index: vendor/libc++/dist/include/numeric =================================================================== --- vendor/libc++/dist/include/numeric (revision 320379) +++ vendor/libc++/dist/include/numeric (revision 320380) @@ -1,439 +1,526 @@ // -*- C++ -*- //===---------------------------- numeric ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_NUMERIC #define _LIBCPP_NUMERIC /* numeric synopsis namespace std { template T accumulate(InputIterator first, InputIterator last, T init); template T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); template typename iterator_traits::value_type reduce(InputIterator first, InputIterator last); // C++17 template T reduce(InputIterator first, InputIterator last, T init); // C++17 template T reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17 template T inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); template T inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); template T transform_reduce(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); // C++17 template T transform_reduce(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17 template T transform_reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op, UnaryOperation unary_op); // C++17 template OutputIterator partial_sum(InputIterator first, InputIterator last, OutputIterator result); template OutputIterator partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); template OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init); // C++17 template OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op); // C++17 +template + OutputIterator + inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17 + +template + OutputIterator + inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op); // C++17 + +template + OutputIterator + inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, BinaryOperation binary_op, T init); // C++17 + template OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op, UnaryOperation unary_op); // C++17 +template + OutputIterator + transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation binary_op, UnaryOperation unary_op); // C++17 + +template + OutputIterator + transform_inclusive_scan(InputIterator first, InputIterator last, + OutputIterator result, + BinaryOperation binary_op, UnaryOperation unary_op, + T init); // C++17 + template OutputIterator adjacent_difference(InputIterator first, InputIterator last, OutputIterator result); template OutputIterator adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op); template void iota(ForwardIterator first, ForwardIterator last, T value); template constexpr common_type_t gcd(M m, N n); // C++17 template constexpr common_type_t lcm(M m, N n); // C++17 } // std */ #include <__config> #include #include // for numeric_limits #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 inline _LIBCPP_INLINE_VISIBILITY _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) { for (; __first != __last; ++__first) __init = __init + *__first; return __init; } template inline _LIBCPP_INLINE_VISIBILITY _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) { for (; __first != __last; ++__first) __init = __binary_op(__init, *__first); return __init; } #if _LIBCPP_STD_VER > 14 template inline _LIBCPP_INLINE_VISIBILITY _Tp reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b) { for (; __first != __last; ++__first) __init = __b(__init, *__first); return __init; } template inline _LIBCPP_INLINE_VISIBILITY _Tp reduce(_InputIterator __first, _InputIterator __last, _Tp __init) { return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>()); } template inline _LIBCPP_INLINE_VISIBILITY typename iterator_traits<_InputIterator>::value_type reduce(_InputIterator __first, _InputIterator __last) { return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{}); } #endif template inline _LIBCPP_INLINE_VISIBILITY _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) { for (; __first1 != __last1; ++__first1, (void) ++__first2) __init = __init + *__first1 * *__first2; return __init; } template inline _LIBCPP_INLINE_VISIBILITY _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2) { for (; __first1 != __last1; ++__first1, (void) ++__first2) __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); return __init; } #if _LIBCPP_STD_VER > 14 template inline _LIBCPP_INLINE_VISIBILITY _Tp transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b, _UnaryOp __u) { for (; __first != __last; ++__first) __init = __b(__init, __u(*__first)); return __init; } template inline _LIBCPP_INLINE_VISIBILITY _Tp transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2) { for (; __first1 != __last1; ++__first1, (void) ++__first2) __init = __b1(__init, __b2(*__first1, *__first2)); return __init; } template inline _LIBCPP_INLINE_VISIBILITY _Tp transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) { return _VSTD::transform_reduce(__first1, __last1, __first2, __init, _VSTD::plus<>(), _VSTD::multiplies<>()); } #endif template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __t(*__first); *__result = __t; for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { __t = __t + *__first; *__result = __t; } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __t(*__first); *__result = __t; for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { __t = __binary_op(__t, *__first); *__result = __t; } } return __result; } #if _LIBCPP_STD_VER > 14 template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) { if (__first != __last) { _Tp __saved = __init; do { __init = __b(__init, *__first); *__result = __saved; __saved = __init; ++__result; } while (++__first != __last); } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) { return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>()); } +template +_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOp __b, _Tp __init) +{ + for (; __first != __last; ++__first, (void) ++__result) { + __init = __b(__init, *__first); + *__result = __init; + } + return __result; +} + +template +_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOp __b) +{ + if (__first != __last) { + typename std::iterator_traits<_InputIterator>::value_type __init = *__first; + *__result++ = __init; + if (++__first != __last) + return _VSTD::inclusive_scan(__first, __last, __result, __b, __init); + } + + return __result; +} + +template +_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result) +{ + return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>()); +} + template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator transform_exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b, _UnaryOp __u) { if (__first != __last) { _Tp __saved = __init; do { __init = __b(__init, __u(*__first)); *__result = __saved; __saved = __init; ++__result; } while (++__first != __last); } + return __result; +} + +template +_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init) +{ + for (; __first != __last; ++__first, (void) ++__result) { + __init = __b(__init, __u(*__first)); + *__result = __init; + } + + return __result; +} + +template +_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _BinaryOp __b, _UnaryOp __u) +{ + if (__first != __last) { + typename std::iterator_traits<_InputIterator>::value_type __init = __u(*__first); + *__result++ = __init; + if (++__first != __last) + return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); + } + return __result; } #endif template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __t1(*__first); *__result = __t1; for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __t2 - __t1; __t1 = _VSTD::move(__t2); } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __t1(*__first); *__result = __t1; for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __binary_op(__t2, __t1); __t1 = _VSTD::move(__t2); } } return __result; } template inline _LIBCPP_INLINE_VISIBILITY void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) { for (; __first != __last; ++__first, (void) ++__value_) *__first = __value_; } #if _LIBCPP_STD_VER > 14 template ::value> struct __abs; template struct __abs<_Result, _Source, true> { _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY _Result operator()(_Source __t) const noexcept { if (__t >= 0) return __t; if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t); return -__t; } }; template struct __abs<_Result, _Source, false> { _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY _Result operator()(_Source __t) const noexcept { return __t; } }; template _LIBCPP_CONSTEXPR _LIBCPP_HIDDEN _Tp __gcd(_Tp __m, _Tp __n) { static_assert((!is_signed<_Tp>::value), ""); return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n); } template _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY common_type_t<_Tp,_Up> gcd(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); static_assert((!is_same::type, bool>::value), "First argument to gcd cannot be bool" ); static_assert((!is_same::type, bool>::value), "Second argument to gcd cannot be bool" ); using _Rp = common_type_t<_Tp,_Up>; using _Wp = make_unsigned_t<_Rp>; return static_cast<_Rp>(_VSTD::__gcd( static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)), static_cast<_Wp>(__abs<_Rp, _Up>()(__n)))); } template _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY common_type_t<_Tp,_Up> lcm(_Tp __m, _Up __n) { static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); static_assert((!is_same::type, bool>::value), "First argument to lcm cannot be bool" ); static_assert((!is_same::type, bool>::value), "Second argument to lcm cannot be bool" ); if (__m == 0 || __n == 0) return 0; using _Rp = common_type_t<_Tp,_Up>; _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n); _Rp __val2 = __abs<_Rp, _Up>()(__n); _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); return __val1 * __val2; } #endif /* _LIBCPP_STD_VER > 14 */ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP_NUMERIC Index: vendor/libc++/dist/include/variant =================================================================== --- vendor/libc++/dist/include/variant (revision 320379) +++ vendor/libc++/dist/include/variant (revision 320380) @@ -1,1562 +1,1564 @@ // -*- C++ -*- //===------------------------------ variant -------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_VARIANT #define _LIBCPP_VARIANT /* variant synopsis namespace std { // 20.7.2, class template variant template class variant { public: // 20.7.2.1, constructors constexpr variant() noexcept(see below); variant(const variant&); variant(variant&&) noexcept(see below); template constexpr variant(T&&) noexcept(see below); template constexpr explicit variant(in_place_type_t, Args&&...); template constexpr explicit variant( in_place_type_t, initializer_list, Args&&...); template constexpr explicit variant(in_place_index_t, Args&&...); template constexpr explicit variant( in_place_index_t, initializer_list, Args&&...); // 20.7.2.2, destructor ~variant(); // 20.7.2.3, assignment variant& operator=(const variant&); variant& operator=(variant&&) noexcept(see below); template variant& operator=(T&&) noexcept(see below); // 20.7.2.4, modifiers template T& emplace(Args&&...); template T& emplace(initializer_list, Args&&...); template variant_alternative_t& emplace(Args&&...); template variant_alternative_t& emplace(initializer_list, Args&&...); // 20.7.2.5, value status constexpr bool valueless_by_exception() const noexcept; constexpr size_t index() const noexcept; // 20.7.2.6, swap void swap(variant&) noexcept(see below); }; // 20.7.3, variant helper classes template struct variant_size; // undefined template constexpr size_t variant_size_v = variant_size::value; template struct variant_size; template struct variant_size; template struct variant_size; template struct variant_size>; template struct variant_alternative; // undefined template using variant_alternative_t = typename variant_alternative::type; template struct variant_alternative; template struct variant_alternative; template struct variant_alternative; template struct variant_alternative>; constexpr size_t variant_npos = -1; // 20.7.4, value access template constexpr bool holds_alternative(const variant&) noexcept; template constexpr variant_alternative_t>& get(variant&); template constexpr variant_alternative_t>&& get(variant&&); template constexpr variant_alternative_t> const& get(const variant&); template constexpr variant_alternative_t> const&& get(const variant&&); template constexpr T& get(variant&); template constexpr T&& get(variant&&); template constexpr const T& get(const variant&); template constexpr const T&& get(const variant&&); template constexpr add_pointer_t>> get_if(variant*) noexcept; template constexpr add_pointer_t>> get_if(const variant*) noexcept; template constexpr add_pointer_t get_if(variant*) noexcept; template constexpr add_pointer_t get_if(const variant*) noexcept; // 20.7.5, relational operators template constexpr bool operator==(const variant&, const variant&); template constexpr bool operator!=(const variant&, const variant&); template constexpr bool operator<(const variant&, const variant&); template constexpr bool operator>(const variant&, const variant&); template constexpr bool operator<=(const variant&, const variant&); template constexpr bool operator>=(const variant&, const variant&); // 20.7.6, visitation template constexpr see below visit(Visitor&&, Variants&&...); // 20.7.7, class monostate struct monostate; // 20.7.8, monostate relational operators constexpr bool operator<(monostate, monostate) noexcept; constexpr bool operator>(monostate, monostate) noexcept; constexpr bool operator<=(monostate, monostate) noexcept; constexpr bool operator>=(monostate, monostate) noexcept; constexpr bool operator==(monostate, monostate) noexcept; constexpr bool operator!=(monostate, monostate) noexcept; // 20.7.9, specialized algorithms template void swap(variant&, variant&) noexcept(see below); // 20.7.10, class bad_variant_access class bad_variant_access; // 20.7.11, hash support template struct hash; template struct hash>; template <> struct hash; } // namespace std */ #include <__config> #include <__tuple> #include #include #include #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif namespace std { // explicitly not using versioning namespace class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception { public: virtual const char* what() const _NOEXCEPT; }; } // namespace std _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 14 _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_bad_variant_access() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_variant_access(); #else _VSTD::abort(); #endif } template class _LIBCPP_TEMPLATE_VIS variant; template struct _LIBCPP_TEMPLATE_VIS variant_size; template constexpr size_t variant_size_v = variant_size<_Tp>::value; template struct _LIBCPP_TEMPLATE_VIS variant_size : variant_size<_Tp> {}; template struct _LIBCPP_TEMPLATE_VIS variant_size : variant_size<_Tp> {}; template struct _LIBCPP_TEMPLATE_VIS variant_size : variant_size<_Tp> {}; template struct _LIBCPP_TEMPLATE_VIS variant_size> : integral_constant {}; template struct _LIBCPP_TEMPLATE_VIS variant_alternative; template using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; template struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const> {}; template struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, volatile _Tp> : add_volatile> {}; template struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const volatile _Tp> : add_cv> {}; template struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>"); using type = __type_pack_element<_Ip, _Types...>; }; constexpr size_t variant_npos = static_cast(-1); constexpr unsigned int __variant_npos = static_cast(-1); namespace __find_detail { template inline _LIBCPP_INLINE_VISIBILITY constexpr size_t __find_index() { constexpr bool __matches[] = {is_same_v<_Tp, _Types>...}; size_t __result = __not_found; for (size_t __i = 0; __i < sizeof...(_Types); ++__i) { if (__matches[__i]) { if (__result != __not_found) { return __ambiguous; } __result = __i; } } return __result; } template struct __find_unambiguous_index_sfinae_impl : integral_constant {}; template <> struct __find_unambiguous_index_sfinae_impl<__not_found> {}; template <> struct __find_unambiguous_index_sfinae_impl<__ambiguous> {}; template struct __find_unambiguous_index_sfinae : __find_unambiguous_index_sfinae_impl<__find_index<_Tp, _Types...>()> {}; } // namespace __find_detail namespace __variant_detail { struct __valueless_t {}; enum class _Trait { _TriviallyAvailable, _Available, _Unavailable }; template class _IsTriviallyAvailable, template class _IsAvailable> constexpr _Trait __trait = _IsTriviallyAvailable<_Tp>::value ? _Trait::_TriviallyAvailable : _IsAvailable<_Tp>::value ? _Trait::_Available : _Trait::_Unavailable; inline _LIBCPP_INLINE_VISIBILITY constexpr _Trait __common_trait(initializer_list<_Trait> __traits) { _Trait __result = _Trait::_TriviallyAvailable; for (_Trait __t : __traits) { if (static_cast(__t) > static_cast(__result)) { __result = __t; } } return __result; } template struct __traits { static constexpr _Trait __copy_constructible_trait = __common_trait({__trait<_Types, is_trivially_copy_constructible, is_copy_constructible>...}); static constexpr _Trait __move_constructible_trait = __common_trait({__trait<_Types, is_trivially_move_constructible, is_move_constructible>...}); static constexpr _Trait __copy_assignable_trait = __common_trait( {__copy_constructible_trait, __trait<_Types, is_trivially_copy_assignable, is_copy_assignable>...}); static constexpr _Trait __move_assignable_trait = __common_trait( {__move_constructible_trait, __trait<_Types, is_trivially_move_assignable, is_move_assignable>...}); static constexpr _Trait __destructible_trait = __common_trait( {__trait<_Types, is_trivially_destructible, is_destructible>...}); }; namespace __access { struct __union { template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<0>) { return _VSTD::forward<_Vp>(__v).__head; } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __get_alt(_Vp&& __v, in_place_index_t<_Ip>) { return __get_alt(_VSTD::forward<_Vp>(__v).__tail, in_place_index<_Ip - 1>); } }; struct __base { template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __get_alt(_Vp&& __v) { return __union::__get_alt(_VSTD::forward<_Vp>(__v).__data, in_place_index<_Ip>); } }; struct __variant { template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __get_alt(_Vp&& __v) { return __base::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v).__impl); } }; } // namespace __access namespace __visitation { struct __base { template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) { constexpr auto __fdiagonal = __make_fdiagonal<_Visitor&&, decltype(_VSTD::forward<_Vs>(__vs).__as_base())...>(); return __fdiagonal[__index](_VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Vs>(__vs).__as_base()...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor, _Vs&&... __vs) { constexpr auto __fmatrix = __make_fmatrix<_Visitor&&, decltype(_VSTD::forward<_Vs>(__vs).__as_base())...>(); return __at(__fmatrix, __vs.index()...)( _VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Vs>(__vs).__as_base()...); } private: template inline _LIBCPP_INLINE_VISIBILITY static constexpr const _Tp& __at(const _Tp& __elem) { return __elem; } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __at(const array<_Tp, _Np>& __elems, size_t __index, _Indices... __indices) { return __at(__elems[__index], __indices...); } template static constexpr void __std_visit_visitor_return_type_check() { static_assert( __all...>::value, "`std::visit` requires the visitor to have a single return type."); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_farray(_Fs&&... __fs) { __std_visit_visitor_return_type_check...>(); using __result = array...>, sizeof...(_Fs)>; return __result{{_VSTD::forward<_Fs>(__fs)...}}; } template struct __dispatcher { template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) { return __invoke_constexpr( static_cast<_Fp>(__f), __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...); } }; template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_dispatch(index_sequence<_Is...>) { return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>; } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fdiagonal_impl() { return __make_dispatch<_Fp, _Vs...>( index_sequence<(__identity<_Vs>{}, _Ip)...>{}); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fdiagonal_impl(index_sequence<_Is...>) { return __base::__make_farray(__make_fdiagonal_impl<_Is, _Fp, _Vs...>()...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fdiagonal() { constexpr size_t _Np = decay_t<_Vp>::__size(); static_assert(__all<(_Np == decay_t<_Vs>::__size())...>::value); return __make_fdiagonal_impl<_Fp, _Vp, _Vs...>(make_index_sequence<_Np>{}); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fmatrix_impl(index_sequence<_Is...> __is) { return __make_dispatch<_Fp, _Vs...>(__is); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fmatrix_impl(index_sequence<_Is...>, index_sequence<_Js...>, _Ls... __ls) { return __base::__make_farray(__make_fmatrix_impl<_Fp, _Vs...>( index_sequence<_Is..., _Js>{}, __ls...)...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_fmatrix() { return __make_fmatrix_impl<_Fp, _Vs...>( index_sequence<>{}, make_index_sequence::__size()>{}...); } }; struct __variant { template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_alt_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) { return __base::__visit_alt_at(__index, _VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Vs>(__vs).__impl...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_alt(_Visitor&& __visitor, _Vs&&... __vs) { return __base::__visit_alt(_VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Vs>(__vs).__impl...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_value_at(size_t __index, _Visitor&& __visitor, _Vs&&... __vs) { return __visit_alt_at( __index, __make_value_visitor(_VSTD::forward<_Visitor>(__visitor)), _VSTD::forward<_Vs>(__vs)...); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr decltype(auto) __visit_value(_Visitor&& __visitor, _Vs&&... __vs) { return __visit_alt( __make_value_visitor(_VSTD::forward<_Visitor>(__visitor)), _VSTD::forward<_Vs>(__vs)...); } private: template static constexpr void __std_visit_exhaustive_visitor_check() { static_assert(is_callable_v<_Visitor(_Values...)>, "`std::visit` requires the visitor to be exhaustive."); } template struct __value_visitor { template inline _LIBCPP_INLINE_VISIBILITY constexpr decltype(auto) operator()(_Alts&&... __alts) const { __std_visit_exhaustive_visitor_check< _Visitor, decltype((_VSTD::forward<_Alts>(__alts).__value))...>(); return __invoke_constexpr(_VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Alts>(__alts).__value...); } _Visitor&& __visitor; }; template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto __make_value_visitor(_Visitor&& __visitor) { return __value_visitor<_Visitor>{_VSTD::forward<_Visitor>(__visitor)}; } }; } // namespace __visitation template struct _LIBCPP_TEMPLATE_VIS __alt { using __value_type = _Tp; template inline _LIBCPP_INLINE_VISIBILITY explicit constexpr __alt(in_place_t, _Args&&... __args) : __value(_VSTD::forward<_Args>(__args)...) {} __value_type __value; }; template <_Trait _DestructibleTrait, size_t _Index, class... _Types> union _LIBCPP_TEMPLATE_VIS __union; template <_Trait _DestructibleTrait, size_t _Index> union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; #define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \ template \ union _LIBCPP_TEMPLATE_VIS __union { \ public: \ inline _LIBCPP_INLINE_VISIBILITY \ explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \ \ template \ inline _LIBCPP_INLINE_VISIBILITY \ explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \ : __head(in_place, _VSTD::forward<_Args>(__args)...) {} \ \ template \ inline _LIBCPP_INLINE_VISIBILITY \ explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \ : __tail(in_place_index<_Ip - 1>, _VSTD::forward<_Args>(__args)...) {} \ \ __union(const __union&) = default; \ __union(__union&&) = default; \ \ destructor \ \ __union& operator=(const __union&) = default; \ __union& operator=(__union&&) = default; \ \ private: \ char __dummy; \ __alt<_Index, _Tp> __head; \ __union __tail; \ \ friend struct __access::__union; \ } _LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, ~__union() = default;); _LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union() {}); _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, ~__union() = delete;); #undef _LIBCPP_VARIANT_UNION template <_Trait _DestructibleTrait, class... _Types> class _LIBCPP_TEMPLATE_VIS __base { public: inline _LIBCPP_INLINE_VISIBILITY explicit constexpr __base(__valueless_t tag) noexcept : __data(tag), __index(__variant_npos) {} template inline _LIBCPP_INLINE_VISIBILITY explicit constexpr __base(in_place_index_t<_Ip>, _Args&&... __args) : __data(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...), __index(_Ip) {} inline _LIBCPP_INLINE_VISIBILITY constexpr bool valueless_by_exception() const noexcept { return index() == variant_npos; } inline _LIBCPP_INLINE_VISIBILITY constexpr size_t index() const noexcept { return __index == __variant_npos ? variant_npos : __index; } protected: inline _LIBCPP_INLINE_VISIBILITY constexpr auto&& __as_base() & { return *this; } inline _LIBCPP_INLINE_VISIBILITY constexpr auto&& __as_base() && { return _VSTD::move(*this); } inline _LIBCPP_INLINE_VISIBILITY constexpr auto&& __as_base() const & { return *this; } inline _LIBCPP_INLINE_VISIBILITY constexpr auto&& __as_base() const && { return _VSTD::move(*this); } inline _LIBCPP_INLINE_VISIBILITY static constexpr size_t __size() { return sizeof...(_Types); } __union<_DestructibleTrait, 0, _Types...> __data; unsigned int __index; friend struct __access::__base; friend struct __visitation::__base; }; template class _LIBCPP_TEMPLATE_VIS __destructor; #define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \ template \ class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \ destructible_trait> \ : public __base { \ using __base_type = __base; \ \ public: \ using __base_type::__base_type; \ using __base_type::operator=; \ \ __destructor(const __destructor&) = default; \ __destructor(__destructor&&) = default; \ destructor \ __destructor& operator=(const __destructor&) = default; \ __destructor& operator=(__destructor&&) = default; \ \ protected: \ inline _LIBCPP_INLINE_VISIBILITY \ destroy \ } _LIBCPP_VARIANT_DESTRUCTOR( _Trait::_TriviallyAvailable, ~__destructor() = default;, void __destroy() noexcept { this->__index = __variant_npos; }); _LIBCPP_VARIANT_DESTRUCTOR( _Trait::_Available, ~__destructor() { __destroy(); }, void __destroy() noexcept { if (!this->valueless_by_exception()) { __visitation::__base::__visit_alt( [](auto& __alt) noexcept { using __alt_type = decay_t; __alt.~__alt_type(); }, *this); } this->__index = __variant_npos; }); _LIBCPP_VARIANT_DESTRUCTOR( _Trait::_Unavailable, ~__destructor() = delete;, void __destroy() noexcept = delete;); #undef _LIBCPP_VARIANT_DESTRUCTOR template class _LIBCPP_TEMPLATE_VIS __constructor : public __destructor<_Traits> { using __base_type = __destructor<_Traits>; public: using __base_type::__base_type; using __base_type::operator=; protected: template inline _LIBCPP_INLINE_VISIBILITY static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) { ::new ((void*)_VSTD::addressof(__a)) __alt<_Ip, _Tp>(in_place, _VSTD::forward<_Args>(__args)...); return __a.__value; } template inline _LIBCPP_INLINE_VISIBILITY static void __generic_construct(__constructor& __lhs, _Rhs&& __rhs) { __lhs.__destroy(); if (!__rhs.valueless_by_exception()) { __visitation::__base::__visit_alt_at( __rhs.index(), [](auto& __lhs_alt, auto&& __rhs_alt) { __construct_alt( __lhs_alt, _VSTD::forward(__rhs_alt).__value); }, __lhs, _VSTD::forward<_Rhs>(__rhs)); __lhs.__index = __rhs.index(); } } }; template class _LIBCPP_TEMPLATE_VIS __move_constructor; #define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, \ move_constructor) \ template \ class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, \ move_constructible_trait> \ : public __constructor<__traits<_Types...>> { \ using __base_type = __constructor<__traits<_Types...>>; \ \ public: \ using __base_type::__base_type; \ using __base_type::operator=; \ \ __move_constructor(const __move_constructor&) = default; \ move_constructor \ ~__move_constructor() = default; \ __move_constructor& operator=(const __move_constructor&) = default; \ __move_constructor& operator=(__move_constructor&&) = default; \ } _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( _Trait::_TriviallyAvailable, __move_constructor(__move_constructor&& __that) = default;); _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( _Trait::_Available, __move_constructor(__move_constructor&& __that) noexcept( __all...>::value) : __move_constructor(__valueless_t{}) { this->__generic_construct(*this, _VSTD::move(__that)); }); _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( _Trait::_Unavailable, __move_constructor(__move_constructor&&) = delete;); #undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR template class _LIBCPP_TEMPLATE_VIS __copy_constructor; #define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, \ copy_constructor) \ template \ class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, \ copy_constructible_trait> \ : public __move_constructor<__traits<_Types...>> { \ using __base_type = __move_constructor<__traits<_Types...>>; \ \ public: \ using __base_type::__base_type; \ using __base_type::operator=; \ \ copy_constructor \ __copy_constructor(__copy_constructor&&) = default; \ ~__copy_constructor() = default; \ __copy_constructor& operator=(const __copy_constructor&) = default; \ __copy_constructor& operator=(__copy_constructor&&) = default; \ } _LIBCPP_VARIANT_COPY_CONSTRUCTOR( _Trait::_TriviallyAvailable, __copy_constructor(const __copy_constructor& __that) = default;); _LIBCPP_VARIANT_COPY_CONSTRUCTOR( _Trait::_Available, __copy_constructor(const __copy_constructor& __that) : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); }); _LIBCPP_VARIANT_COPY_CONSTRUCTOR( _Trait::_Unavailable, __copy_constructor(const __copy_constructor&) = delete;); #undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR template class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> { using __base_type = __copy_constructor<_Traits>; public: using __base_type::__base_type; using __base_type::operator=; template inline _LIBCPP_INLINE_VISIBILITY auto& __emplace(_Args&&... __args) { this->__destroy(); auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this), _VSTD::forward<_Args>(__args)...); this->__index = _Ip; return __res; } protected: template inline _LIBCPP_INLINE_VISIBILITY void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) { if (this->index() == _Ip) { __a.__value = _VSTD::forward<_Arg>(__arg); } else { struct { void operator()(true_type) const { __this->__emplace<_Ip>(_VSTD::forward<_Arg>(__arg)); } void operator()(false_type) const { __this->__emplace<_Ip>(_Tp(_VSTD::forward<_Arg>(__arg))); } __assignment* __this; _Arg&& __arg; } __impl{this, _VSTD::forward<_Arg>(__arg)}; __impl(bool_constant || !is_nothrow_move_constructible_v<_Tp>>{}); } } template inline _LIBCPP_INLINE_VISIBILITY void __generic_assign(_That&& __that) { if (this->valueless_by_exception() && __that.valueless_by_exception()) { // do nothing. } else if (__that.valueless_by_exception()) { this->__destroy(); } else { __visitation::__base::__visit_alt_at( __that.index(), [this](auto& __this_alt, auto&& __that_alt) { this->__assign_alt( __this_alt, _VSTD::forward(__that_alt).__value); }, *this, _VSTD::forward<_That>(__that)); } } }; template class _LIBCPP_TEMPLATE_VIS __move_assignment; #define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, \ move_assignment) \ template \ class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, \ move_assignable_trait> \ : public __assignment<__traits<_Types...>> { \ using __base_type = __assignment<__traits<_Types...>>; \ \ public: \ using __base_type::__base_type; \ using __base_type::operator=; \ \ __move_assignment(const __move_assignment&) = default; \ __move_assignment(__move_assignment&&) = default; \ ~__move_assignment() = default; \ __move_assignment& operator=(const __move_assignment&) = default; \ move_assignment \ } _LIBCPP_VARIANT_MOVE_ASSIGNMENT( _Trait::_TriviallyAvailable, __move_assignment& operator=(__move_assignment&& __that) = default;); _LIBCPP_VARIANT_MOVE_ASSIGNMENT( _Trait::_Available, __move_assignment& operator=(__move_assignment&& __that) noexcept( __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_move_assignable_v<_Types>)...>::value) { this->__generic_assign(_VSTD::move(__that)); return *this; }); _LIBCPP_VARIANT_MOVE_ASSIGNMENT( _Trait::_Unavailable, __move_assignment& operator=(__move_assignment&&) = delete;); #undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT template class _LIBCPP_TEMPLATE_VIS __copy_assignment; #define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, \ copy_assignment) \ template \ class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, \ copy_assignable_trait> \ : public __move_assignment<__traits<_Types...>> { \ using __base_type = __move_assignment<__traits<_Types...>>; \ \ public: \ using __base_type::__base_type; \ using __base_type::operator=; \ \ __copy_assignment(const __copy_assignment&) = default; \ __copy_assignment(__copy_assignment&&) = default; \ ~__copy_assignment() = default; \ copy_assignment \ __copy_assignment& operator=(__copy_assignment&&) = default; \ } _LIBCPP_VARIANT_COPY_ASSIGNMENT( _Trait::_TriviallyAvailable, __copy_assignment& operator=(const __copy_assignment& __that) = default;); _LIBCPP_VARIANT_COPY_ASSIGNMENT( _Trait::_Available, __copy_assignment& operator=(const __copy_assignment& __that) { this->__generic_assign(__that); return *this; }); _LIBCPP_VARIANT_COPY_ASSIGNMENT( _Trait::_Unavailable, __copy_assignment& operator=(const __copy_assignment&) = delete;); #undef _LIBCPP_VARIANT_COPY_ASSIGNMENT template class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> { using __base_type = __copy_assignment<__traits<_Types...>>; public: using __base_type::__base_type; using __base_type::operator=; template inline _LIBCPP_INLINE_VISIBILITY void __assign(_Arg&& __arg) { this->__assign_alt(__access::__base::__get_alt<_Ip>(*this), _VSTD::forward<_Arg>(__arg)); } inline _LIBCPP_INLINE_VISIBILITY void __swap(__impl& __that) { if (this->valueless_by_exception() && __that.valueless_by_exception()) { // do nothing. } else if (this->index() == __that.index()) { __visitation::__base::__visit_alt_at( this->index(), [](auto& __this_alt, auto& __that_alt) { using _VSTD::swap; swap(__this_alt.__value, __that_alt.__value); }, *this, __that); } else { __impl* __lhs = this; __impl* __rhs = _VSTD::addressof(__that); if (__lhs->__move_nothrow() && !__rhs->__move_nothrow()) { _VSTD::swap(__lhs, __rhs); } __impl __tmp(_VSTD::move(*__rhs)); #ifndef _LIBCPP_NO_EXCEPTIONS // EXTENSION: When the move construction of `__lhs` into `__rhs` throws // and `__tmp` is nothrow move constructible then we move `__tmp` back // into `__rhs` and provide the strong exception safety guarentee. try { this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); } catch (...) { if (__tmp.__move_nothrow()) { this->__generic_construct(*__rhs, _VSTD::move(__tmp)); } throw; } #else this->__generic_construct(*__rhs, _VSTD::move(*__lhs)); #endif this->__generic_construct(*__lhs, _VSTD::move(__tmp)); } } private: inline _LIBCPP_INLINE_VISIBILITY bool __move_nothrow() const { constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...}; return this->valueless_by_exception() || __results[this->index()]; } }; template struct __overload; template <> struct __overload<> { void operator()() const; }; template struct __overload<_Tp, _Types...> : __overload<_Types...> { using __overload<_Types...>::operator(); __identity<_Tp> operator()(_Tp) const; }; template using __best_match_t = typename result_of_t<__overload<_Types...>(_Tp&&)>::type; } // __variant_detail template class _LIBCPP_TEMPLATE_VIS variant : private __sfinae_ctor_base< __all...>::value, __all...>::value>, private __sfinae_assign_base< __all<(is_copy_constructible_v<_Types> && is_copy_assignable_v<_Types>)...>::value, __all<(is_move_constructible_v<_Types> && is_move_assignable_v<_Types>)...>::value> { static_assert(0 < sizeof...(_Types), "variant must consist of at least one alternative."); static_assert(__all...>::value, "variant can not have an array type as an alternative."); static_assert(__all...>::value, "variant can not have a reference type as an alternative."); static_assert(__all...>::value, "variant can not have a void type as an alternative."); using __first_type = variant_alternative_t<0, variant>; public: template , _Dummy>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>) : __impl(in_place_index<0>) {} variant(const variant&) = default; variant(variant&&) = default; template < class _Arg, enable_if_t, variant>, int> = 0, + enable_if_t>::value, int> = 0, + enable_if_t>::value, int> = 0, class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t, int> = 0> inline _LIBCPP_INLINE_VISIBILITY constexpr variant(_Arg&& __arg) noexcept( is_nothrow_constructible_v<_Tp, _Arg>) : __impl(in_place_index<_Ip>, _VSTD::forward<_Arg>(__arg)) {} template , class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, enable_if_t, int> = 0> inline _LIBCPP_INLINE_VISIBILITY explicit constexpr variant( in_place_index_t<_Ip>, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>) : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {} template < size_t _Ip, class _Up, class... _Args, enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, enable_if_t&, _Args...>, int> = 0> inline _LIBCPP_INLINE_VISIBILITY explicit constexpr variant( in_place_index_t<_Ip>, initializer_list<_Up> __il, _Args&&... __args) noexcept( is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {} template < class _Tp, class... _Args, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t, int> = 0> inline _LIBCPP_INLINE_VISIBILITY explicit constexpr variant(in_place_type_t<_Tp>, _Args&&... __args) noexcept( is_nothrow_constructible_v<_Tp, _Args...>) : __impl(in_place_index<_Ip>, _VSTD::forward<_Args>(__args)...) {} template < class _Tp, class _Up, class... _Args, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t&, _Args...>, int> = 0> inline _LIBCPP_INLINE_VISIBILITY explicit constexpr variant( in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args) noexcept( is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>) : __impl(in_place_index<_Ip>, __il, _VSTD::forward<_Args>(__args)...) {} ~variant() = default; variant& operator=(const variant&) = default; variant& operator=(variant&&) = default; template < class _Arg, enable_if_t, variant>, int> = 0, class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t && is_constructible_v<_Tp, _Arg>, int> = 0> inline _LIBCPP_INLINE_VISIBILITY variant& operator=(_Arg&& __arg) noexcept( is_nothrow_assignable_v<_Tp&, _Arg> && is_nothrow_constructible_v<_Tp, _Arg>) { __impl.template __assign<_Ip>(_VSTD::forward<_Arg>(__arg)); return *this; } template < size_t _Ip, class... _Args, enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, enable_if_t, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _Tp& emplace(_Args&&... __args) { return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...); } template < size_t _Ip, class _Up, class... _Args, enable_if_t<(_Ip < sizeof...(_Types)), int> = 0, class _Tp = variant_alternative_t<_Ip, variant<_Types...>>, enable_if_t&, _Args...>, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...); } template < class _Tp, class... _Args, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _Tp& emplace(_Args&&... __args) { return __impl.template __emplace<_Ip>(_VSTD::forward<_Args>(__args)...); } template < class _Tp, class _Up, class... _Args, size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value, enable_if_t&, _Args...>, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) { return __impl.template __emplace<_Ip>(__il, _VSTD::forward<_Args>(__args)...); } inline _LIBCPP_INLINE_VISIBILITY constexpr bool valueless_by_exception() const noexcept { return __impl.valueless_by_exception(); } inline _LIBCPP_INLINE_VISIBILITY constexpr size_t index() const noexcept { return __impl.index(); } template < bool _Dummy = true, enable_if_t< __all<( __dependent_type, _Dummy>::value && __dependent_type, _Dummy>::value)...>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY void swap(variant& __that) noexcept( __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) { __impl.__swap(__that.__impl); } private: __variant_detail::__impl<_Types...> __impl; friend struct __variant_detail::__access::__variant; friend struct __variant_detail::__visitation::__variant; }; template inline _LIBCPP_INLINE_VISIBILITY constexpr bool __holds_alternative(const variant<_Types...>& __v) noexcept { return __v.index() == _Ip; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool holds_alternative(const variant<_Types...>& __v) noexcept { return __holds_alternative<__find_exactly_one_t<_Tp, _Types...>::value>(__v); } template inline _LIBCPP_INLINE_VISIBILITY static constexpr auto&& __generic_get(_Vp&& __v) { using __variant_detail::__access::__variant; if (!__holds_alternative<_Ip>(__v)) { __throw_bad_variant_access(); } return __variant::__get_alt<_Ip>(_VSTD::forward<_Vp>(__v)).__value; } template inline _LIBCPP_INLINE_VISIBILITY constexpr variant_alternative_t<_Ip, variant<_Types...>>& get( variant<_Types...>& __v) { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get<_Ip>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get( variant<_Types...>&& __v) { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get<_Ip>(_VSTD::move(__v)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get( const variant<_Types...>& __v) { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get<_Ip>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get( const variant<_Types...>&& __v) { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get<_Ip>(_VSTD::move(__v)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp& get(variant<_Types...>& __v) { static_assert(!is_void_v<_Tp>); return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp&& get(variant<_Types...>&& __v) { static_assert(!is_void_v<_Tp>); return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>( _VSTD::move(__v)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr const _Tp& get(const variant<_Types...>& __v) { static_assert(!is_void_v<_Tp>); return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr const _Tp&& get(const variant<_Types...>&& __v) { static_assert(!is_void_v<_Tp>); return _VSTD::get<__find_exactly_one_t<_Tp, _Types...>::value>( _VSTD::move(__v)); } template inline _LIBCPP_INLINE_VISIBILITY constexpr auto* __generic_get_if(_Vp* __v) noexcept { using __variant_detail::__access::__variant; return __v && __holds_alternative<_Ip>(*__v) ? _VSTD::addressof(__variant::__get_alt<_Ip>(*__v).__value) : nullptr; } template inline _LIBCPP_INLINE_VISIBILITY constexpr add_pointer_t>> get_if(variant<_Types...>* __v) noexcept { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get_if<_Ip>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr add_pointer_t>> get_if(const variant<_Types...>* __v) noexcept { static_assert(_Ip < sizeof...(_Types)); static_assert(!is_void_v>>); return __generic_get_if<_Ip>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr add_pointer_t<_Tp> get_if(variant<_Types...>* __v) noexcept { static_assert(!is_void_v<_Tp>); return _VSTD::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr add_pointer_t get_if(const variant<_Types...>* __v) noexcept { static_assert(!is_void_v<_Tp>); return _VSTD::get_if<__find_exactly_one_t<_Tp, _Types...>::value>(__v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__lhs.index() != __rhs.index()) return false; if (__lhs.valueless_by_exception()) return true; return __variant::__visit_value_at(__lhs.index(), equal_to<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__lhs.index() != __rhs.index()) return true; if (__lhs.valueless_by_exception()) return false; return __variant::__visit_value_at( __lhs.index(), not_equal_to<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__rhs.valueless_by_exception()) return false; if (__lhs.valueless_by_exception()) return true; if (__lhs.index() < __rhs.index()) return true; if (__lhs.index() > __rhs.index()) return false; return __variant::__visit_value_at(__lhs.index(), less<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__lhs.valueless_by_exception()) return false; if (__rhs.valueless_by_exception()) return true; if (__lhs.index() > __rhs.index()) return true; if (__lhs.index() < __rhs.index()) return false; return __variant::__visit_value_at(__lhs.index(), greater<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__lhs.valueless_by_exception()) return true; if (__rhs.valueless_by_exception()) return false; if (__lhs.index() < __rhs.index()) return true; if (__lhs.index() > __rhs.index()) return false; return __variant::__visit_value_at( __lhs.index(), less_equal<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; if (__rhs.valueless_by_exception()) return true; if (__lhs.valueless_by_exception()) return false; if (__lhs.index() > __rhs.index()) return true; if (__lhs.index() < __rhs.index()) return false; return __variant::__visit_value_at( __lhs.index(), greater_equal<>{}, __lhs, __rhs); } template inline _LIBCPP_INLINE_VISIBILITY constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) { using __variant_detail::__visitation::__variant; bool __results[] = {__vs.valueless_by_exception()...}; for (bool __result : __results) { if (__result) { __throw_bad_variant_access(); } } return __variant::__visit_value(_VSTD::forward<_Visitor>(__visitor), _VSTD::forward<_Vs>(__vs)...); } struct _LIBCPP_TEMPLATE_VIS monostate {}; inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(monostate, monostate) noexcept { return false; } inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(monostate, monostate) noexcept { return false; } inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(monostate, monostate) noexcept { return true; } inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(monostate, monostate) noexcept { return true; } inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(monostate, monostate) noexcept { return true; } inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(monostate, monostate) noexcept { return false; } template inline _LIBCPP_INLINE_VISIBILITY auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) { __lhs.swap(__rhs); } template struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper, remove_const_t<_Types>...>> { using argument_type = variant<_Types...>; using result_type = size_t; inline _LIBCPP_INLINE_VISIBILITY result_type operator()(const argument_type& __v) const { using __variant_detail::__visitation::__variant; size_t __res = __v.valueless_by_exception() ? 299792458 // Random value chosen by the universe upon creation : __variant::__visit_alt( [](const auto& __alt) { using __alt_type = decay_t; using __value_type = remove_const_t< typename __alt_type::__value_type>; return hash<__value_type>{}(__alt.__value); }, __v); return __hash_combine(__res, hash{}(__v.index())); } }; template <> struct _LIBCPP_TEMPLATE_VIS hash { using argument_type = monostate; using result_type = size_t; inline _LIBCPP_INLINE_VISIBILITY result_type operator()(const argument_type&) const _NOEXCEPT { return 66740831; // return a fundamentally attractive random value. } }; #endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_VARIANT Index: vendor/libc++/dist/src/experimental/filesystem/path.cpp =================================================================== --- vendor/libc++/dist/src/experimental/filesystem/path.cpp (revision 320379) +++ vendor/libc++/dist/src/experimental/filesystem/path.cpp (revision 320380) @@ -1,447 +1,448 @@ //===--------------------- filesystem/path.cpp ----------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "experimental/filesystem" #include "string_view" #include "utility" namespace { namespace parser { using namespace std; using namespace std::experimental::filesystem; using string_view_t = path::__string_view; using string_view_pair = pair; using PosPtr = path::value_type const*; struct PathParser { enum ParserState : unsigned char { // Zero is a special sentinel value used by default constructed iterators. PS_BeforeBegin = 1, PS_InRootName, PS_InRootDir, PS_InFilenames, PS_InTrailingSep, PS_AtEnd }; const string_view_t Path; string_view_t RawEntry; ParserState State; private: PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {} public: PathParser(string_view_t P, string_view_t E, unsigned char S) : Path(P), RawEntry(E), State(static_cast(S)) { // S cannot be '0' or PS_BeforeBegin. } static PathParser CreateBegin(string_view_t P) noexcept { PathParser PP(P, PS_BeforeBegin); PP.increment(); return PP; } static PathParser CreateEnd(string_view_t P) noexcept { PathParser PP(P, PS_AtEnd); return PP; } PosPtr peek() const noexcept { auto TkEnd = getNextTokenStartPos(); auto End = getAfterBack(); return TkEnd == End ? nullptr : TkEnd; } void increment() noexcept { const PosPtr End = getAfterBack(); const PosPtr Start = getNextTokenStartPos(); if (Start == End) return makeState(PS_AtEnd); switch (State) { case PS_BeforeBegin: { PosPtr TkEnd = consumeSeparator(Start, End); // If we consumed exactly two separators we have a root name. if (TkEnd && TkEnd == Start + 2) { // FIXME Do we need to consume a name or is '//' a root name on its own? // what about '//.', '//..', '//...'? auto NameEnd = consumeName(TkEnd, End); if (NameEnd) TkEnd = NameEnd; return makeState(PS_InRootName, Start, TkEnd); } else if (TkEnd) return makeState(PS_InRootDir, Start, TkEnd); else return makeState(PS_InFilenames, Start, consumeName(Start, End)); } case PS_InRootName: return makeState(PS_InRootDir, Start, consumeSeparator(Start, End)); case PS_InRootDir: return makeState(PS_InFilenames, Start, consumeName(Start, End)); case PS_InFilenames: { PosPtr SepEnd = consumeSeparator(Start, End); if (SepEnd != End) { PosPtr TkEnd = consumeName(SepEnd, End); if (TkEnd) return makeState(PS_InFilenames, SepEnd, TkEnd); } return makeState(PS_InTrailingSep, Start, SepEnd); } case PS_InTrailingSep: return makeState(PS_AtEnd); case PS_AtEnd: _LIBCPP_UNREACHABLE(); } } void decrement() noexcept { const PosPtr REnd = getBeforeFront(); const PosPtr RStart = getCurrentTokenStartPos() - 1; switch (State) { case PS_AtEnd: { // Try to consume a trailing separator or root directory first. if (PosPtr SepEnd = consumeSeparator(RStart, REnd)) { if (SepEnd == REnd) return makeState((RStart == REnd + 2) ? PS_InRootName : PS_InRootDir, Path.data(), RStart + 1); // Check if we're seeing the root directory separator auto PP = CreateBegin(Path); bool InRootDir = PP.State == PS_InRootName && &PP.RawEntry.back() == SepEnd; return makeState(InRootDir ? PS_InRootDir : PS_InTrailingSep, SepEnd + 1, RStart + 1); } else { PosPtr TkStart = consumeName(RStart, REnd); if (TkStart == REnd + 2 && consumeSeparator(TkStart, REnd) == REnd) return makeState(PS_InRootName, Path.data(), RStart + 1); else return makeState(PS_InFilenames, TkStart + 1, RStart + 1); } } case PS_InTrailingSep: return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1, RStart + 1); case PS_InFilenames: { PosPtr SepEnd = consumeSeparator(RStart, REnd); if (SepEnd == REnd) return makeState((RStart == REnd + 2) ? PS_InRootName : PS_InRootDir, Path.data(), RStart + 1); PosPtr TkEnd = consumeName(SepEnd, REnd); if (TkEnd == REnd + 2 && consumeSeparator(TkEnd, REnd) == REnd) return makeState(PS_InRootDir, SepEnd + 1, RStart + 1); return makeState(PS_InFilenames, TkEnd + 1, SepEnd + 1); } case PS_InRootDir: return makeState(PS_InRootName, Path.data(), RStart + 1); case PS_InRootName: case PS_BeforeBegin: _LIBCPP_UNREACHABLE(); } } /// \brief Return a view with the "preferred representation" of the current /// element. For example trailing separators are represented as a '.' string_view_t operator*() const noexcept { switch (State) { case PS_BeforeBegin: case PS_AtEnd: return ""; case PS_InRootDir: return "/"; case PS_InTrailingSep: return "."; case PS_InRootName: case PS_InFilenames: return RawEntry; } _LIBCPP_UNREACHABLE(); } explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; } PathParser& operator++() noexcept { increment(); return *this; } PathParser& operator--() noexcept { decrement(); return *this; } private: void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept { State = NewState; RawEntry = string_view_t(Start, End - Start); } void makeState(ParserState NewState) noexcept { State = NewState; RawEntry = {}; } PosPtr getAfterBack() const noexcept { return Path.data() + Path.size(); } PosPtr getBeforeFront() const noexcept { return Path.data() - 1; } /// \brief Return a pointer to the first character after the currently /// lexed element. PosPtr getNextTokenStartPos() const noexcept { switch (State) { case PS_BeforeBegin: return Path.data(); case PS_InRootName: case PS_InRootDir: case PS_InFilenames: return &RawEntry.back() + 1; case PS_InTrailingSep: case PS_AtEnd: return getAfterBack(); } _LIBCPP_UNREACHABLE(); } /// \brief Return a pointer to the first character in the currently lexed /// element. PosPtr getCurrentTokenStartPos() const noexcept { switch (State) { case PS_BeforeBegin: case PS_InRootName: return &Path.front(); case PS_InRootDir: case PS_InFilenames: case PS_InTrailingSep: return &RawEntry.front(); case PS_AtEnd: return &Path.back() + 1; } _LIBCPP_UNREACHABLE(); } PosPtr consumeSeparator(PosPtr P, PosPtr End) const noexcept { if (P == End || *P != '/') return nullptr; const int Inc = P < End ? 1 : -1; P += Inc; while (P != End && *P == '/') P += Inc; return P; } PosPtr consumeName(PosPtr P, PosPtr End) const noexcept { if (P == End || *P == '/') return nullptr; const int Inc = P < End ? 1 : -1; P += Inc; while (P != End && *P != '/') P += Inc; return P; } }; string_view_pair separate_filename(string_view_t const & s) { if (s == "." || s == ".." || s.empty()) return string_view_pair{s, ""}; auto pos = s.find_last_of('.'); - if (pos == string_view_t::npos) return string_view_pair{s, string_view{}}; + if (pos == string_view_t::npos) + return string_view_pair{s, string_view_t{}}; return string_view_pair{s.substr(0, pos), s.substr(pos)}; } string_view_t createView(PosPtr S, PosPtr E) noexcept { return {S, static_cast(E - S) + 1}; } }} // namespace parser _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM using parser::string_view_t; using parser::string_view_pair; using parser::PathParser; using parser::createView; /////////////////////////////////////////////////////////////////////////////// // path definitions /////////////////////////////////////////////////////////////////////////////// constexpr path::value_type path::preferred_separator; path & path::replace_extension(path const & replacement) { path p = extension(); if (not p.empty()) { __pn_.erase(__pn_.size() - p.native().size()); } if (!replacement.empty()) { if (replacement.native()[0] != '.') { __pn_ += "."; } __pn_.append(replacement.__pn_); } return *this; } /////////////////////////////////////////////////////////////////////////////// // path.decompose string_view_t path::__root_name() const { auto PP = PathParser::CreateBegin(__pn_); if (PP.State == PathParser::PS_InRootName) return *PP; return {}; } string_view_t path::__root_directory() const { auto PP = PathParser::CreateBegin(__pn_); if (PP.State == PathParser::PS_InRootName) ++PP; if (PP.State == PathParser::PS_InRootDir) return *PP; return {}; } string_view_t path::__root_path_raw() const { auto PP = PathParser::CreateBegin(__pn_); if (PP.State == PathParser::PS_InRootName) { auto NextCh = PP.peek(); if (NextCh && *NextCh == '/') { ++PP; return createView(__pn_.data(), &PP.RawEntry.back()); } return PP.RawEntry; } if (PP.State == PathParser::PS_InRootDir) return *PP; return {}; } string_view_t path::__relative_path() const { auto PP = PathParser::CreateBegin(__pn_); while (PP.State <= PathParser::PS_InRootDir) ++PP; if (PP.State == PathParser::PS_AtEnd) return {}; return createView(PP.RawEntry.data(), &__pn_.back()); } string_view_t path::__parent_path() const { if (empty()) return {}; auto PP = PathParser::CreateEnd(__pn_); --PP; if (PP.RawEntry.data() == __pn_.data()) return {}; --PP; return createView(__pn_.data(), &PP.RawEntry.back()); } string_view_t path::__filename() const { if (empty()) return {}; return *(--PathParser::CreateEnd(__pn_)); } string_view_t path::__stem() const { return parser::separate_filename(__filename()).first; } string_view_t path::__extension() const { return parser::separate_filename(__filename()).second; } //////////////////////////////////////////////////////////////////////////// // path.comparisons int path::__compare(string_view_t __s) const { auto PP = PathParser::CreateBegin(__pn_); auto PP2 = PathParser::CreateBegin(__s); while (PP && PP2) { int res = (*PP).compare(*PP2); if (res != 0) return res; ++PP; ++PP2; } if (PP.State == PP2.State && PP.State == PathParser::PS_AtEnd) return 0; if (PP.State == PathParser::PS_AtEnd) return -1; return 1; } //////////////////////////////////////////////////////////////////////////// // path.nonmembers size_t hash_value(const path& __p) noexcept { auto PP = PathParser::CreateBegin(__p.native()); size_t hash_value = 0; - std::hash hasher; + std::hash hasher; while (PP) { hash_value = __hash_combine(hash_value, hasher(*PP)); ++PP; } return hash_value; } //////////////////////////////////////////////////////////////////////////// // path.itr path::iterator path::begin() const { auto PP = PathParser::CreateBegin(__pn_); iterator it; it.__path_ptr_ = this; it.__state_ = PP.State; it.__entry_ = PP.RawEntry; it.__stashed_elem_.__assign_view(*PP); return it; } path::iterator path::end() const { iterator it{}; it.__state_ = PathParser::PS_AtEnd; it.__path_ptr_ = this; return it; } path::iterator& path::iterator::__increment() { static_assert(__at_end == PathParser::PS_AtEnd, ""); PathParser PP(__path_ptr_->native(), __entry_, __state_); ++PP; __state_ = PP.State; __entry_ = PP.RawEntry; __stashed_elem_.__assign_view(*PP); return *this; } path::iterator& path::iterator::__decrement() { PathParser PP(__path_ptr_->native(), __entry_, __state_); --PP; __state_ = PP.State; __entry_ = PP.RawEntry; __stashed_elem_.__assign_view(*PP); return *this; } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM Index: vendor/libc++/dist/test/std/algorithms/alg.nonmodifying/alg.foreach/for_each_n.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/algorithms/alg.nonmodifying/alg.foreach/for_each_n.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/algorithms/alg.nonmodifying/alg.foreach/for_each_n.pass.cpp (revision 320380) @@ -1,61 +1,61 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // InputIterator for_each_n(InputIterator first, Size n, Function f); #include #include #include "test_iterators.h" struct for_each_test { for_each_test(int c) : count(c) {} int count; void operator()(int& i) {++i; ++count;} }; int main() { typedef input_iterator Iter; int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned s = sizeof(ia)/sizeof(ia[0]); { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), 0, std::ref(f)); assert(it == Iter(ia)); - assert(f.count == 0); + assert(f.count == 0); } { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), s, std::ref(f)); - + assert(it == Iter(ia+s)); - assert(f.count == s); + assert(f.count == s); for (unsigned i = 0; i < s; ++i) assert(ia[i] == static_cast(i+1)); } { auto f = for_each_test(0); Iter it = std::for_each_n(Iter(ia), 1, std::ref(f)); - + assert(it == Iter(ia+1)); - assert(f.count == 1); + assert(f.count == 1); for (unsigned i = 0; i < 1; ++i) assert(ia[i] == static_cast(i+2)); } } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/copy.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/copy.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/copy.pass.cpp (revision 320380) @@ -1,204 +1,199 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any& operator=(any const &); // Test copy assignment #include #include #include "experimental_any_helpers.h" #include "count_new.hpp" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; template void test_copy_assign() { assert(LHS::count == 0); assert(RHS::count == 0); LHS::reset(); RHS::reset(); { any lhs(LHS(1)); any const rhs(RHS(2)); assert(LHS::count == 1); assert(RHS::count == 1); assert(RHS::copied == 0); lhs = rhs; assert(RHS::copied == 1); assert(LHS::count == 0); assert(RHS::count == 2); assertContains(lhs, 2); assertContains(rhs, 2); } assert(LHS::count == 0); assert(RHS::count == 0); } template void test_copy_assign_empty() { assert(LHS::count == 0); LHS::reset(); { any lhs; any const rhs(LHS(42)); assert(LHS::count == 1); assert(LHS::copied == 0); lhs = rhs; assert(LHS::copied == 1); assert(LHS::count == 2); assertContains(lhs, 42); assertContains(rhs, 42); } assert(LHS::count == 0); LHS::reset(); { any lhs(LHS(1)); any const rhs; assert(LHS::count == 1); assert(LHS::copied == 0); lhs = rhs; assert(LHS::copied == 0); assert(LHS::count == 0); assertEmpty(lhs); assertEmpty(rhs); } assert(LHS::count == 0); } void test_copy_assign_self() { // empty { any a; a = a; assertEmpty(a); assert(globalMemCounter.checkOutstandingNewEq(0)); } assert(globalMemCounter.checkOutstandingNewEq(0)); // small { any a((small(1))); assert(small::count == 1); a = a; assert(small::count == 1); assertContains(a, 1); assert(globalMemCounter.checkOutstandingNewEq(0)); } assert(small::count == 0); assert(globalMemCounter.checkOutstandingNewEq(0)); // large { any a(large(1)); assert(large::count == 1); a = a; assert(large::count == 1); assertContains(a, 1); assert(globalMemCounter.checkOutstandingNewEq(1)); } assert(large::count == 0); assert(globalMemCounter.checkOutstandingNewEq(0)); } template void test_copy_assign_throws() { #if !defined(TEST_HAS_NO_EXCEPTIONS) auto try_throw = [](any& lhs, any const& rhs) { try { lhs = rhs; assert(false); } catch (my_any_exception const &) { // do nothing } catch (...) { assert(false); } }; // const lvalue to empty { any lhs; any const rhs((Tp(1))); assert(Tp::count == 1); try_throw(lhs, rhs); assert(Tp::count == 1); assertEmpty(lhs); assertContains(rhs); } { any lhs((small(2))); any const rhs((Tp(1))); assert(small::count == 1); assert(Tp::count == 1); try_throw(lhs, rhs); assert(small::count == 1); assert(Tp::count == 1); assertContains(lhs, 2); assertContains(rhs); } { any lhs((large(2))); any const rhs((Tp(1))); assert(large::count == 1); assert(Tp::count == 1); try_throw(lhs, rhs); assert(large::count == 1); assert(Tp::count == 1); assertContains(lhs, 2); assertContains(rhs); } #endif } int main() { test_copy_assign(); test_copy_assign(); test_copy_assign(); test_copy_assign(); test_copy_assign_empty(); test_copy_assign_empty(); test_copy_assign_self(); test_copy_assign_throws(); test_copy_assign_throws(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/move.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/move.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/move.pass.cpp (revision 320380) @@ -1,109 +1,104 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any& operator=(any &&); // Test move assignment. #include #include #include "experimental_any_helpers.h" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; template void test_move_assign() { assert(LHS::count == 0); assert(RHS::count == 0); { LHS const s1(1); any a(s1); RHS const s2(2); any a2(s2); assert(LHS::count == 2); assert(RHS::count == 2); a = std::move(a2); assert(LHS::count == 1); assert(RHS::count == 2); assertContains(a, 2); assertEmpty(a2); } assert(LHS::count == 0); assert(RHS::count == 0); } template void test_move_assign_empty() { assert(LHS::count == 0); { any a; any a2((LHS(1))); assert(LHS::count == 1); a = std::move(a2); assert(LHS::count == 1); assertContains(a, 1); assertEmpty(a2); } assert(LHS::count == 0); { any a((LHS(1))); any a2; assert(LHS::count == 1); a = std::move(a2); assert(LHS::count == 0); assertEmpty(a); assertEmpty(a2); } assert(LHS::count == 0); } void test_move_assign_noexcept() { any a1; any a2; static_assert( noexcept(a1 = std::move(a2)) , "any & operator=(any &&) must be noexcept" ); } int main() { test_move_assign_noexcept(); test_move_assign(); test_move_assign(); test_move_assign(); test_move_assign(); test_move_assign_empty(); test_move_assign_empty(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/value.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/value.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.assign/value.pass.cpp (revision 320380) @@ -1,184 +1,179 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any& operator=(any const &); // Test value copy and move assignment. #include #include #include "experimental_any_helpers.h" #include "count_new.hpp" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; template void test_assign_value() { assert(LHS::count == 0); assert(RHS::count == 0); LHS::reset(); RHS::reset(); { any lhs(LHS(1)); any const rhs(RHS(2)); assert(LHS::count == 1); assert(RHS::count == 1); assert(RHS::copied == 0); lhs = rhs; assert(RHS::copied == 1); assert(LHS::count == 0); assert(RHS::count == 2); assertContains(lhs, 2); assertContains(rhs, 2); } assert(LHS::count == 0); assert(RHS::count == 0); LHS::reset(); RHS::reset(); { any lhs(LHS(1)); any rhs(RHS(2)); assert(LHS::count == 1); assert(RHS::count == 1); assert(RHS::moved == 1); lhs = std::move(rhs); assert(RHS::moved >= 1); assert(RHS::copied == 0); assert(LHS::count == 0); assert(RHS::count == 1); assertContains(lhs, 2); assertEmpty(rhs); } assert(LHS::count == 0); assert(RHS::count == 0); } template void test_assign_value_empty() { assert(RHS::count == 0); RHS::reset(); { any lhs; RHS rhs(42); assert(RHS::count == 1); assert(RHS::copied == 0); lhs = rhs; assert(RHS::count == 2); assert(RHS::copied == 1); assert(RHS::moved >= 0); assertContains(lhs, 42); } assert(RHS::count == 0); RHS::reset(); { any lhs; RHS rhs(42); assert(RHS::count == 1); assert(RHS::moved == 0); lhs = std::move(rhs); assert(RHS::count == 2); assert(RHS::copied == 0); assert(RHS::moved >= 1); assertContains(lhs, 42); } assert(RHS::count == 0); RHS::reset(); } template void test_assign_throws() { #if !defined(TEST_HAS_NO_EXCEPTIONS) auto try_throw= [](any& lhs, auto&& rhs) { try { Move ? lhs = std::move(rhs) : lhs = rhs; assert(false); } catch (my_any_exception const &) { // do nothing } catch (...) { assert(false); } }; // const lvalue to empty { any lhs; Tp rhs(1); assert(Tp::count == 1); try_throw(lhs, rhs); assert(Tp::count == 1); assertEmpty(lhs); } { any lhs((small(2))); Tp rhs(1); assert(small::count == 1); assert(Tp::count == 1); try_throw(lhs, rhs); assert(small::count == 1); assert(Tp::count == 1); assertContains(lhs, 2); } { any lhs((large(2))); Tp rhs(1); assert(large::count == 1); assert(Tp::count == 1); try_throw(lhs, rhs); assert(large::count == 1); assert(Tp::count == 1); assertContains(lhs, 2); } #endif } int main() { test_assign_value(); test_assign_value(); test_assign_value(); test_assign_value(); test_assign_value_empty(); test_assign_value_empty(); test_assign_throws(); test_assign_throws(); test_assign_throws(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/copy.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/copy.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/copy.pass.cpp (revision 320380) @@ -1,107 +1,102 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any(any const &); #include #include #include "experimental_any_helpers.h" #include "count_new.hpp" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; template void test_copy_throws() { #if !defined(TEST_HAS_NO_EXCEPTIONS) assert(Type::count == 0); { any const a((Type(42))); assert(Type::count == 1); try { any const a2(a); assert(false); } catch (my_any_exception const &) { // do nothing } catch (...) { assert(false); } assert(Type::count == 1); assertContains(a, 42); } assert(Type::count == 0); #endif } void test_copy_empty() { DisableAllocationGuard g; ((void)g); // No allocations should occur. any a1; any a2(a1); assertEmpty(a1); assertEmpty(a2); } template void test_copy() { // Copying small types should not perform any allocations. DisableAllocationGuard g(isSmallType()); ((void)g); assert(Type::count == 0); Type::reset(); { any a((Type(42))); assert(Type::count == 1); assert(Type::copied == 0); any a2(a); assert(Type::copied == 1); assert(Type::count == 2); assertContains(a, 42); assertContains(a, 42); // Modify a and check that a2 is unchanged modifyValue(a, -1); assertContains(a, -1); assertContains(a2, 42); // modify a2 and check that a is unchanged modifyValue(a2, 999); assertContains(a, -1); assertContains(a2, 999); // clear a and check that a2 is unchanged a.clear(); assertEmpty(a); assertContains(a2, 999); } assert(Type::count == 0); } int main() { test_copy(); test_copy(); test_copy_empty(); test_copy_throws(); test_copy_throws(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/move.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/move.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/move.pass.cpp (revision 320380) @@ -1,109 +1,104 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any(any &&) noexcept; #include #include #include #include #include "experimental_any_helpers.h" #include "count_new.hpp" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; // Moves are always noexcept. The throws_on_move object // must be stored dynamically so the pointer is moved and // not the stored object. void test_move_does_not_throw() { #if !defined(TEST_HAS_NO_EXCEPTIONS) assert(throws_on_move::count == 0); { throws_on_move v(42); any a(v); assert(throws_on_move::count == 2); // No allocations should be performed after this point. DisableAllocationGuard g; ((void)g); try { any const a2(std::move(a)); assertEmpty(a); assertContains(a2, 42); } catch (...) { assert(false); } assert(throws_on_move::count == 1); assertEmpty(a); } assert(throws_on_move::count == 0); #endif } void test_move_empty() { DisableAllocationGuard g; ((void)g); // no allocations should be performed. any a1; any a2(std::move(a1)); assertEmpty(a1); assertEmpty(a2); } template void test_move() { assert(Type::count == 0); Type::reset(); { any a((Type(42))); assert(Type::count == 1); assert(Type::copied == 0); assert(Type::moved == 1); // Moving should not perform allocations since it must be noexcept. DisableAllocationGuard g; ((void)g); any a2(std::move(a)); assert(Type::moved >= 1); // zero or more move operations can be performed. assert(Type::copied == 0); // no copies can be performed. assert(Type::count == 1); assertEmpty(a); // Moves are always destructive. assertContains(a2, 42); } assert(Type::count == 0); } int main() { // noexcept test { static_assert( std::is_nothrow_move_constructible::value , "any must be nothrow move constructible" ); } test_move(); test_move(); test_move_empty(); test_move_does_not_throw(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/value.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/value.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.cons/value.pass.cpp (revision 320380) @@ -1,123 +1,118 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // template any(Value &&) // Test construction from a value. // Concerns: // --------- // 1. The value is properly move/copied depending on the value category. // 2. Both small and large values are properly handled. #include #include #include "experimental_any_helpers.h" #include "count_new.hpp" #include "test_macros.h" using std::experimental::any; using std::experimental::any_cast; template void test_copy_value_throws() { #if !defined(TEST_HAS_NO_EXCEPTIONS) assert(Type::count == 0); { Type const t(42); assert(Type::count == 1); try { any const a2(t); assert(false); } catch (my_any_exception const &) { // do nothing } catch (...) { assert(false); } assert(Type::count == 1); assert(t.value == 42); } assert(Type::count == 0); #endif } void test_move_value_throws() { #if !defined(TEST_HAS_NO_EXCEPTIONS) assert(throws_on_move::count == 0); { throws_on_move v; assert(throws_on_move::count == 1); try { any const a(std::move(v)); assert(false); } catch (my_any_exception const &) { // do nothing } catch (...) { assert(false); } assert(throws_on_move::count == 1); } assert(throws_on_move::count == 0); #endif } template void test_copy_move_value() { // constructing from a small type should perform no allocations. DisableAllocationGuard g(isSmallType()); ((void)g); assert(Type::count == 0); Type::reset(); { Type t(42); assert(Type::count == 1); any a(t); assert(Type::count == 2); assert(Type::copied == 1); assert(Type::moved == 0); assertContains(a, 42); } assert(Type::count == 0); Type::reset(); { Type t(42); assert(Type::count == 1); any a(std::move(t)); assert(Type::count == 2); assert(Type::copied == 0); assert(Type::moved == 1); assertContains(a, 42); } } int main() { test_copy_move_value(); test_copy_move_value(); test_copy_value_throws(); test_copy_value_throws(); test_move_value_throws(); } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp (revision 320380) @@ -1,70 +1,65 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any::clear() noexcept #include #include #include "experimental_any_helpers.h" int main() { using std::experimental::any; using std::experimental::any_cast; // empty { any a; // noexcept check static_assert( noexcept(a.clear()) , "any.clear() must be noexcept" ); assertEmpty(a); a.clear(); assertEmpty(a); } // small object { any a((small(1))); assert(small::count == 1); assertContains(a, 1); a.clear(); assertEmpty(a); assert(small::count == 0); } // large object { any a(large(1)); assert(large::count == 1); assertContains(a); a.clear(); assertEmpty(a); assert(large::count == 0); } } Index: vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp (revision 320380) @@ -1,108 +1,103 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: with_system_cxx_lib=macosx10.12 -// XFAIL: with_system_cxx_lib=macosx10.11 -// XFAIL: with_system_cxx_lib=macosx10.10 -// XFAIL: with_system_cxx_lib=macosx10.9 -// XFAIL: with_system_cxx_lib=macosx10.7 -// XFAIL: with_system_cxx_lib=macosx10.8 +// XFAIL: availability=macosx // // any::swap(any &) noexcept // Test swap(large, small) and swap(small, large) #include #include #include "experimental_any_helpers.h" using std::experimental::any; using std::experimental::any_cast; template void test_swap() { assert(LHS::count == 0); assert(RHS::count == 0); { any a1((LHS(1))); any a2(RHS{2}); assert(LHS::count == 1); assert(RHS::count == 1); a1.swap(a2); assert(LHS::count == 1); assert(RHS::count == 1); assertContains(a1, 2); assertContains(a2, 1); } assert(LHS::count == 0); assert(RHS::count == 0); assert(LHS::copied == 0); assert(RHS::copied == 0); } template void test_swap_empty() { assert(Tp::count == 0); { any a1((Tp(1))); any a2; assert(Tp::count == 1); a1.swap(a2); assert(Tp::count == 1); assertContains(a2, 1); assertEmpty(a1); } assert(Tp::count == 0); { any a1((Tp(1))); any a2; assert(Tp::count == 1); a2.swap(a1); assert(Tp::count == 1); assertContains(a2, 1); assertEmpty(a1); } assert(Tp::count == 0); assert(Tp::copied == 0); } void test_noexcept() { any a1; any a2; static_assert( noexcept(a1.swap(a2)) , "any::swap(any&) must be noexcept" ); } int main() { test_noexcept(); test_swap_empty(); test_swap_empty(); test_swap(); test_swap(); test_swap(); test_swap(); } Index: vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp (revision 320380) @@ -1,72 +1,72 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // All of these became constexpr in C++17 // // template // constexpr void advance(Iter& i, Iter::difference_type n); // // template // constexpr void advance(Iter& i, Iter::difference_type n); // // template // constexpr void advance(Iter& i, Iter::difference_type n); #include #include #include "test_iterators.h" template void test(It i, typename std::iterator_traits::difference_type n, It x) { std::advance(i, n); assert(i == x); } #if TEST_STD_VER > 14 template -constexpr bool +constexpr bool constepxr_test(It i, typename std::iterator_traits::difference_type n, It x) { std::advance(i, n); return i == x; } #endif int main() { { const char* s = "1234567890"; test(input_iterator(s), 10, input_iterator(s+10)); test(forward_iterator(s), 10, forward_iterator(s+10)); test(bidirectional_iterator(s+5), 5, bidirectional_iterator(s+10)); test(bidirectional_iterator(s+5), -5, bidirectional_iterator(s)); test(random_access_iterator(s+5), 5, random_access_iterator(s+10)); test(random_access_iterator(s+5), -5, random_access_iterator(s)); test(s+5, 5, s+10); test(s+5, -5, s); } #if TEST_STD_VER > 14 { constexpr const char* s = "1234567890"; static_assert( constepxr_test(input_iterator(s), 10, input_iterator(s+10)), "" ); static_assert( constepxr_test(forward_iterator(s), 10, forward_iterator(s+10)), "" ); static_assert( constepxr_test(bidirectional_iterator(s+5), 5, bidirectional_iterator(s+10)), "" ); static_assert( constepxr_test(bidirectional_iterator(s+5), -5, bidirectional_iterator(s)), "" ); static_assert( constepxr_test(random_access_iterator(s+5), 5, random_access_iterator(s+10)), "" ); static_assert( constepxr_test(random_access_iterator(s+5), -5, random_access_iterator(s)), "" ); static_assert( constepxr_test(s+5, 5, s+10), "" ); static_assert( constepxr_test(s+5, -5, s), "" ); } #endif } Index: vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp (revision 320380) @@ -1,75 +1,75 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // Iter prev(Iter x, Iter::difference_type n = 1); #include #include #include "test_iterators.h" template void test(It i, typename std::iterator_traits::difference_type n, It x) { assert(std::prev(i, n) == x); } template void test(It i, It x) { assert(std::prev(i) == x); } #if TEST_STD_VER > 14 template constexpr bool constexpr_test(It i, typename std::iterator_traits::difference_type n, It x) { return std::prev(i, n) == x; } template constexpr bool constexpr_test(It i, It x) { return std::prev(i) == x; } #endif int main() { { const char* s = "1234567890"; test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s)); test(random_access_iterator(s+10), 10, random_access_iterator(s)); test(s+10, 10, s); test(bidirectional_iterator(s+1), bidirectional_iterator(s)); test(random_access_iterator(s+1), random_access_iterator(s)); test(s+1, s); } #if TEST_STD_VER > 14 { constexpr const char* s = "1234567890"; static_assert( constexpr_test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s)), "" ); static_assert( constexpr_test(random_access_iterator(s+10), 10, random_access_iterator(s)), "" ); static_assert( constexpr_test(s+10, 10, s), "" ); static_assert( constexpr_test(bidirectional_iterator(s+1), bidirectional_iterator(s)), "" ); static_assert( constexpr_test(random_access_iterator(s+1), random_access_iterator(s)), "" ); static_assert( constexpr_test(s+1, s), "" ); } #endif - + } Index: vendor/libc++/dist/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp =================================================================== --- vendor/libc++/dist/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp (nonexistent) +++ vendor/libc++/dist/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp (revision 320380) @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// REQUIRES: availability=macosx10.12 + +// test availability of new/delete operators introduced in c++17. + +#include + +int main () { + int *p0 = new ((std::align_val_t)16) int(1); + (void)p0; + int *p1 = new ((std::align_val_t)16) int[1]; + (void)p1; + // expected-error@-4 {{call to unavailable function 'operator new': introduced in macOS 10.13}} + // expected-note@new:* {{candidate function has been explicitly made unavailable}} + // expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'const std::nothrow_t' for 2nd argument}} + // expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'void *' for 2nd argument}} + // expected-note@new:* {{candidate function not viable: requires single argument '__sz', but 2 arguments were provided}} + // expected-note@new:* {{candidate function not viable: requires 3 arguments, but 2 were provided}} + + // expected-error@-9 {{call to unavailable function 'operator new[]': introduced in macOS 10.13}} + // expected-note@new:* {{candidate function has been explicitly made unavailable}} + // expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'const std::nothrow_t' for 2nd argument}} + // expected-note@new:* {{candidate function not viable: no known conversion from 'std::align_val_t' to 'void *' for 2nd argument}} + // expected-note@new:* {{candidate function not viable: requires single argument '__sz', but 2 arguments were provided}} + // expected-note@new:* {{candidate function not viable: requires 3 arguments, but 2 were provided}} + return 0; +} Property changes on: vendor/libc++/dist/test/std/language.support/support.dynamic/new.delete/new.delete.placement/new_deployment.fail.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp (revision 320380) @@ -1,97 +1,97 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // OutputIterator exclusive_scan(InputIterator first, InputIterator last, // OutputIterator result, T init); -// +// #include #include #include #include "test_iterators.h" template void test(Iter1 first, Iter1 last, T init, Iter2 rFirst, Iter2 rLast) { std::vector::value_type> v; - + // Not in place std::exclusive_scan(first, last, std::back_inserter(v), init); assert(std::equal(v.begin(), v.end(), rFirst, rLast)); // In place v.clear(); v.assign(first, last); std::exclusive_scan(v.begin(), v.end(), v.begin(), init); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); } template void test() { int ia[] = {1, 3, 5, 7, 9}; const int pRes[] = {0, 1, 4, 9, 16}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) test(Iter(ia), Iter(ia + i), 0, pRes, pRes + i); } int triangle(int n) { return n*(n+1)/2; } // Basic sanity void basic_tests() { { std::vector v(10); std::fill(v.begin(), v.end(), 3); std::exclusive_scan(v.begin(), v.end(), v.begin(), 50); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 50 + (int) i * 3); } { std::vector v(10); std::iota(v.begin(), v.end(), 0); std::exclusive_scan(v.begin(), v.end(), v.begin(), 30); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 30 + triangle(i-1)); } { std::vector v(10); std::iota(v.begin(), v.end(), 1); std::exclusive_scan(v.begin(), v.end(), v.begin(), 40); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 40 + triangle(i)); } } int main() { basic_tests(); // All the iterator categories test >(); test >(); test >(); test >(); test(); test< int*>(); } Index: vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp (revision 320380) @@ -1,87 +1,86 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // OutputIterator // exclusive_scan(InputIterator first, InputIterator last, -// OutputIterator result, +// OutputIterator result, // T init, BinaryOperation binary_op); // C++17 #include #include #include #include "test_iterators.h" template void test(Iter1 first, Iter1 last, T init, Op op, Iter2 rFirst, Iter2 rLast) { std::vector::value_type> v; // Not in place std::exclusive_scan(first, last, std::back_inserter(v), init, op); assert(std::equal(v.begin(), v.end(), rFirst, rLast)); // In place v.clear(); v.assign(first, last); std::exclusive_scan(v.begin(), v.end(), v.begin(), init, op); - assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); } template void test() { int ia[] = {1, 3, 5, 7, 9}; const int pRes[] = {0, 1, 4, 9, 16}; const int mRes[] = {1, 1, 3, 15, 105}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) { test(Iter(ia), Iter(ia + i), 0, std::plus<>(), pRes, pRes + i); test(Iter(ia), Iter(ia + i), 1, std::multiplies<>(), mRes, mRes + i); } } int main() { // All the iterator categories test >(); test >(); test >(); test >(); test(); test< int*>(); // Make sure that the calculations are done using the init typedef { std::vector v(10); std::iota(v.begin(), v.end(), 1); std::vector res; std::exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>()); assert(res.size() == 10); int j = 1; assert(res[0] == 1); for (size_t i = 1; i < v.size(); ++i) { j *= i; assert(res[i] == j); } } } - \ No newline at end of file Index: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp (nonexistent) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp (revision 320380) @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator inclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, T init); +// + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first, Iter1 last, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; + +// Not in place + std::inclusive_scan(first, last, std::back_inserter(v)); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// In place + v.clear(); + v.assign(first, last); + std::inclusive_scan(v.begin(), v.end(), v.begin()); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = {1, 3, 5, 7, 9}; + const int pRes[] = {1, 4, 9, 16, 25}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) + test(Iter(ia), Iter(ia + i), pRes, pRes + i); +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::inclusive_scan(v.begin(), v.end(), v.begin()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == (int)(i+1) * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::inclusive_scan(v.begin(), v.end(), v.begin()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::inclusive_scan(v.begin(), v.end(), v.begin()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i + 1)); + } + + { + std::vector v, res; + std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res)); + assert(res.empty()); + } +} + +int main() +{ + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); +} Property changes on: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp (nonexistent) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp (revision 320380) @@ -0,0 +1,112 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator +// inclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, +// BinaryOperation binary_op); // C++17 + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first, Iter1 last, Op op, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; + +// Not in place + std::inclusive_scan(first, last, std::back_inserter(v), op); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// In place + v.clear(); + v.assign(first, last); + std::inclusive_scan(v.begin(), v.end(), v.begin(), op); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = {1, 3, 5, 7, 9}; + const int pRes[] = {1, 4, 9, 16, 25}; + const int mRes[] = {1, 3, 15, 105, 945}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure + static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), std::plus<>(), pRes, pRes + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), mRes, mRes + i); + } +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == (int)(i+1) * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i + 1)); + } + + { + std::vector v, res; + std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>()); + assert(res.empty()); + } +} + + +int main() +{ + + basic_tests(); + +// All the iterator categories +// test >(); +// test >(); +// test >(); +// test >(); +// test(); +// test< int*>(); + +} + \ No newline at end of file Property changes on: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp (nonexistent) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp (revision 320380) @@ -0,0 +1,128 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator +// inclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, +// BinaryOperation binary_op, T init); // C++17 + +#include +#include +#include + +#include "test_iterators.h" + +template +void +test(Iter1 first, Iter1 last, Op op, T init, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; + +// Not in place + std::inclusive_scan(first, last, std::back_inserter(v), op, init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// In place + v.clear(); + v.assign(first, last); + std::inclusive_scan(v.begin(), v.end(), v.begin(), op, init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = {1, 3, 5, 7, 9}; + const int pRes[] = {1, 4, 9, 16, 25}; + const int mRes[] = {1, 3, 15, 105, 945}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pRes) / sizeof(pRes[0])); // just to be sure + static_assert(sa == sizeof(mRes) / sizeof(mRes[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), std::plus<>(), 0, pRes, pRes + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), 1, mRes, mRes + i); + } +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 50); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 50 + (int)(i+1) * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 40); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 40 + triangle(i)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), 30); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 30 + triangle(i + 1)); + } + + { + std::vector v, res; + std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), 40); + assert(res.empty()); + } + +// Make sure that the calculations are done using the init typedef + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::vector res; + std::inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), 1); + + assert(res.size() == 10); + int j = 1; + assert(res[0] == 1); + for (size_t i = 1; i < v.size(); ++i) + { + j *= i + 1; + assert(res[i] == j); + } + } +} + + +int main() +{ + + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); + +} + \ No newline at end of file Property changes on: vendor/libc++/dist/test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/reduce/reduce_init_op.pass.cpp (revision 320380) @@ -1,74 +1,74 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // T reduce(InputIterator first, InputIterator last, T init, BinaryOperation op); - + #include #include #include "test_iterators.h" template void test(Iter first, Iter last, T init, Op op, T x) { static_assert( std::is_same_v, "" ); assert(std::reduce(first, last, init, op) == x); } template void test() { int ia[] = {1, 2, 3, 4, 5, 6}; unsigned sa = sizeof(ia) / sizeof(ia[0]); test(Iter(ia), Iter(ia), 0, std::plus<>(), 0); test(Iter(ia), Iter(ia), 1, std::multiplies<>(), 1); test(Iter(ia), Iter(ia+1), 0, std::plus<>(), 1); test(Iter(ia), Iter(ia+1), 2, std::multiplies<>(), 2); test(Iter(ia), Iter(ia+2), 0, std::plus<>(), 3); test(Iter(ia), Iter(ia+2), 3, std::multiplies<>(), 6); test(Iter(ia), Iter(ia+sa), 0, std::plus<>(), 21); test(Iter(ia), Iter(ia+sa), 4, std::multiplies<>(), 2880); } template void test_return_type() { T *p = nullptr; static_assert( std::is_same_v()))>, "" ); } int main() { test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test >(); test >(); test >(); test >(); test(); // Make sure the math is done using the correct type { auto v = {1, 2, 3, 4, 5, 6, 7, 8}; unsigned res = std::reduce(v.begin(), v.end(), 1U, std::multiplies<>()); assert(res == 40320); // 8! will not fit into a char } } Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp (revision 320380) @@ -1,160 +1,160 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 -// template // OutputIterator transform_exclusive_scan(InputIterator first, InputIterator last, // OutputIterator result, T init, // BinaryOperation binary_op, // UnaryOperation unary_op); #include #include #include #include #include "test_iterators.h" template struct identity : std::unary_function<_Tp, _Tp> { constexpr const _Tp& operator()(const _Tp& __x) const { return __x;} }; template <> struct identity { template constexpr auto operator()(_Tp&& __x) const _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x))) -> decltype (_VSTD::forward<_Tp>(__x)) { return _VSTD::forward<_Tp>(__x); } }; template void test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast) { std::vector::value_type> v; // Test not in-place std::transform_exclusive_scan(first, last, std::back_inserter(v), init, bop, uop); assert(std::equal(v.begin(), v.end(), rFirst, rLast)); // Test in-place v.clear(); v.assign(first, last); std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), init, bop, uop); assert(std::equal(v.begin(), v.end(), rFirst, rLast)); } template void test() { int ia[] = { 1, 3, 5, 7, 9}; const int pResI0[] = { 0, 1, 4, 9, 16}; // with identity - const int mResI0[] = { 0, 0, 0, 0, 0}; + const int mResI0[] = { 0, 0, 0, 0, 0}; const int pResN0[] = { 0, -1, -4, -9, -16}; // with negate const int mResN0[] = { 0, 0, 0, 0, 0}; const int pResI2[] = { 2, 3, 6, 11, 18}; // with identity - const int mResI2[] = { 2, 2, 6, 30, 210}; + const int mResI2[] = { 2, 2, 6, 30, 210}; const int pResN2[] = { 2, 1, -2, -7, -14}; // with negate const int mResN2[] = { 2, -2, 6, -30, 210}; const unsigned sa = sizeof(ia) / sizeof(ia[0]); static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0])); // just to be sure static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0])); // just to be sure static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0])); // just to be sure static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure for (unsigned int i = 0; i < sa; ++i ) { test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i); test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i); test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i); } } int triangle(int n) { return n*(n+1)/2; } // Basic sanity void basic_tests() { { std::vector v(10); std::fill(v.begin(), v.end(), 3); std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, std::plus<>(), identity<>()); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 50 + (int) i * 3); } { std::vector v(10); std::iota(v.begin(), v.end(), 0); std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, std::plus<>(), identity<>()); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 30 + triangle(i-1)); } { std::vector v(10); std::iota(v.begin(), v.end(), 1); std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 40, std::plus<>(), identity<>()); for (size_t i = 0; i < v.size(); ++i) assert(v[i] == 40 + triangle(i)); } { std::vector v, res; std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 40, std::plus<>(), identity<>()); assert(res.empty()); } // Make sure that the calculations are done using the init typedef { std::vector v(10); std::iota(v.begin(), v.end(), 1); std::vector res; std::transform_exclusive_scan(v.begin(), v.end(), std::back_inserter(res), 1, std::multiplies<>(), identity<>()); assert(res.size() == 10); int j = 1; assert(res[0] == 1); for (size_t i = 1; i < res.size(); ++i) { j *= i; assert(res[i] == j); } } } int main() { basic_tests(); - + // All the iterator categories test >(); test >(); test >(); test >(); test(); test< int*>(); } Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp (nonexistent) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp (revision 320380) @@ -0,0 +1,133 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, +// BinaryOperation binary_op, +// UnaryOperation unary_op); + + +#include +#include +#include +#include + +#include "test_iterators.h" + +template +struct identity : std::unary_function<_Tp, _Tp> +{ + constexpr const _Tp& operator()(const _Tp& __x) const { return __x;} +}; + +template <> +struct identity +{ + template + constexpr auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x))) + -> decltype (_VSTD::forward<_Tp>(__x)) + { return _VSTD::forward<_Tp>(__x); } +}; + +template +void +test(Iter1 first, Iter1 last, BOp bop, UOp uop, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; +// Test not in-place + std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// Test in-place + v.clear(); + v.assign(first, last); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = { 1, 3, 5, 7, 9}; + const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity + const int mResI0[] = { 1, 3, 15, 105, 945}; + const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate + const int mResN0[] = { -1, 3, -15, 105, -945}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure + static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure + static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure + static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), pResN0, pResN0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), mResN0, mResN0 + i); + } +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + std::copy(v.begin(), v.end(), std::ostream_iterator(std::cout, " ")); + std::cout << std::endl; + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == (int)(i+1) * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>()); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == triangle(i + 1)); + } + + { + std::vector v, res; + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>()); + assert(res.empty()); + } +} + +int main() +{ + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); +} Property changes on: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp (nonexistent) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp (revision 320380) @@ -0,0 +1,160 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template +// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last, +// OutputIterator result, +// BinaryOperation binary_op, +// UnaryOperation unary_op, +// T init); + + +#include +#include +#include + +#include "test_iterators.h" + +template +struct identity : std::unary_function<_Tp, _Tp> +{ + constexpr const _Tp& operator()(const _Tp& __x) const { return __x;} +}; + +template <> +struct identity +{ + template + constexpr auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x))) + -> decltype (_VSTD::forward<_Tp>(__x)) + { return _VSTD::forward<_Tp>(__x); } +}; + +template +void +test(Iter1 first, Iter1 last, BOp bop, UOp uop, T init, Iter2 rFirst, Iter2 rLast) +{ + std::vector::value_type> v; +// Test not in-place + std::transform_inclusive_scan(first, last, std::back_inserter(v), bop, uop, init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); + +// Test in-place + v.clear(); + v.assign(first, last); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), bop, uop, init); + assert(std::equal(v.begin(), v.end(), rFirst, rLast)); +} + + +template +void +test() +{ + int ia[] = { 1, 3, 5, 7, 9}; + const int pResI0[] = { 1, 4, 9, 16, 25}; // with identity + const int mResI0[] = { 0, 0, 0, 0, 0}; + const int pResN0[] = { -1, -4, -9, -16, -25}; // with negate + const int mResN0[] = { 0, 0, 0, 0, 0}; + const int pResI2[] = { 3, 6, 11, 18, 27}; // with identity + const int mResI2[] = { 2, 6, 30, 210, 1890}; + const int pResN2[] = { 1, -2, -7, -14, -23}; // with negate + const int mResN2[] = { -2, 6, -30, 210, -1890}; + const unsigned sa = sizeof(ia) / sizeof(ia[0]); + static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0])); // just to be sure + static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0])); // just to be sure + static_assert(sa == sizeof(pResN0) / sizeof(pResN0[0])); // just to be sure + static_assert(sa == sizeof(mResN0) / sizeof(mResN0[0])); // just to be sure + static_assert(sa == sizeof(pResI2) / sizeof(pResI2[0])); // just to be sure + static_assert(sa == sizeof(mResI2) / sizeof(mResI2[0])); // just to be sure + static_assert(sa == sizeof(pResN2) / sizeof(pResN2[0])); // just to be sure + static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0])); // just to be sure + + for (unsigned int i = 0; i < sa; ++i ) { + test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 0, pResI0, pResI0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 0, mResI0, mResI0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 0, pResN0, pResN0 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, mResN0, mResN0 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), identity<>(), 2, pResI2, pResI2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), identity<>(), 2, mResI2, mResI2 + i); + test(Iter(ia), Iter(ia + i), std::plus<>(), std::negate<>(), 2, pResN2, pResN2 + i); + test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, mResN2, mResN2 + i); + } +} + +int triangle(int n) { return n*(n+1)/2; } + +// Basic sanity +void basic_tests() +{ + { + std::vector v(10); + std::fill(v.begin(), v.end(), 3); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 50); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 50 + (int) (i + 1) * 3); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 0); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 30); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 30 + triangle(i)); + } + + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::transform_inclusive_scan(v.begin(), v.end(), v.begin(), std::plus<>(), identity<>(), 40); + for (size_t i = 0; i < v.size(); ++i) + assert(v[i] == 40 + triangle(i + 1)); + } + + { + std::vector v, res; + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::plus<>(), identity<>(), 1); + assert(res.empty()); + } + +// Make sure that the calculations are done using the init typedef + { + std::vector v(10); + std::iota(v.begin(), v.end(), 1); + std::vector res; + std::transform_inclusive_scan(v.begin(), v.end(), std::back_inserter(res), std::multiplies<>(), identity<>(), 1); + + assert(res.size() == 10); + int j = 1; + assert(res[0] == 1); + for (size_t i = 1; i < res.size(); ++i) + { + j *= i + 1; + assert(res[i] == j); + } + } +} + +int main() +{ + basic_tests(); + +// All the iterator categories + test >(); + test >(); + test >(); + test >(); + test(); + test< int*>(); +} Property changes on: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp (revision 320380) @@ -1,124 +1,124 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // T transform_reduce(InputIterator1 first1, InputIterator1 last1, // T init, BinaryOperation binary_op, UnaryOperation unary_op); -// - +// + #include #include #include "test_iterators.h" template struct identity : std::unary_function<_Tp, _Tp> { constexpr const _Tp& operator()(const _Tp& __x) const { return __x;} }; template <> struct identity { template constexpr auto operator()(_Tp&& __x) const _NOEXCEPT_(noexcept(_VSTD::forward<_Tp>(__x))) -> decltype (_VSTD::forward<_Tp>(__x)) { return _VSTD::forward<_Tp>(__x); } }; template struct twice { constexpr const _Tp operator()(const _Tp& __x) const noexcept { return 2 * __x; } }; template <> struct twice { template constexpr auto operator()(const _Tp& __x) const _NOEXCEPT_(noexcept(2 * __x)) -> decltype (2 * __x) { return 2 * __x; } }; template void test(Iter1 first1, Iter1 last1, T init, BOp bOp, UOp uOp, T x) { - static_assert( std::is_same_v ); assert(std::transform_reduce(first1, last1, init, bOp, uOp) == x); } template void test() { int ia[] = {1, 2, 3, 4, 5, 6}; unsigned sa = sizeof(ia) / sizeof(ia[0]); test(Iter(ia), Iter(ia), 0, std::plus<>(), identity<>(), 0); test(Iter(ia), Iter(ia), 1, std::multiplies<>(), identity<>(), 1); test(Iter(ia), Iter(ia+1), 0, std::multiplies<>(), identity<>(), 0); test(Iter(ia), Iter(ia+1), 2, std::plus<>(), identity<>(), 3); test(Iter(ia), Iter(ia+2), 0, std::plus<>(), identity<>(), 3); test(Iter(ia), Iter(ia+2), 3, std::multiplies<>(), identity<>(), 6); test(Iter(ia), Iter(ia+sa), 4, std::multiplies<>(), identity<>(), 2880); test(Iter(ia), Iter(ia+sa), 4, std::plus<>(), identity<>(), 25); test(Iter(ia), Iter(ia), 0, std::plus<>(), twice<>(), 0); test(Iter(ia), Iter(ia), 1, std::multiplies<>(), twice<>(), 1); test(Iter(ia), Iter(ia+1), 0, std::multiplies<>(), twice<>(), 0); test(Iter(ia), Iter(ia+1), 2, std::plus<>(), twice<>(), 4); test(Iter(ia), Iter(ia+2), 0, std::plus<>(), twice<>(), 6); test(Iter(ia), Iter(ia+2), 3, std::multiplies<>(), twice<>(), 24); test(Iter(ia), Iter(ia+sa), 4, std::multiplies<>(), twice<>(), 184320); // 64 * 2880 test(Iter(ia), Iter(ia+sa), 4, std::plus<>(), twice<>(), 46); } template void test_return_type() { T *p = nullptr; - static_assert( std::is_same_v(), identity<>()))> ); } int main() { test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); // All the iterator categories test >(); test >(); test >(); test >(); test(); test< int*>(); // Make sure the math is done using the correct type { auto v = {1, 2, 3, 4, 5, 6}; unsigned res = std::transform_reduce(v.begin(), v.end(), 1U, std::multiplies<>(), twice<>()); assert(res == 46080); // 6! * 64 will not fit into a char } } Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init.pass.cpp (revision 320380) @@ -1,95 +1,95 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // T transform_reduce(InputIterator1 first1, InputIterator1 last1, // InputIterator2 first2, T init); #include #include #include "test_iterators.h" template void test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x) { - static_assert( std::is_same_v ); assert(std::transform_reduce(first1, last1, first2, init) == x); } template void test() { int ia[] = {1, 2, 3, 4, 5, 6}; unsigned int ua[] = {2, 4, 6, 8, 10,12}; unsigned sa = sizeof(ia) / sizeof(ia[0]); assert(sa == sizeof(ua) / sizeof(ua[0])); // just to be sure test(SIter(ia), SIter(ia), UIter(ua), 0, 0); test(UIter(ua), UIter(ua), SIter(ia), 1, 1); test(SIter(ia), SIter(ia+1), UIter(ua), 0, 2); test(UIter(ua), UIter(ua+1), SIter(ia), 2, 4); test(SIter(ia), SIter(ia+2), UIter(ua), 0, 10); test(UIter(ua), UIter(ua+2), SIter(ia), 3, 13); test(SIter(ia), SIter(ia+sa), UIter(ua), 0, 182); test(UIter(ua), UIter(ua+sa), SIter(ia), 4, 186); } template void test_return_type() { T *p = nullptr; - static_assert( std::is_same_v ); } int main() { test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); // All the iterator categories test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); // just plain pointers (const vs. non-const, too) test(); test(); test< int*, const unsigned int *>(); test< int*, unsigned int *>(); } Index: vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp (revision 320380) @@ -1,97 +1,97 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11, c++14 // template // T transform_reduce(InputIterator1 first1, InputIterator1 last1, // InputIterator2 first2, T init, // BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); -// - +// + #include #include #include "test_iterators.h" template void test(Iter1 first1, Iter1 last1, Iter2 first2, T init, Op1 op1, Op2 op2, T x) { - static_assert( std::is_same_v ); assert(std::transform_reduce(first1, last1, first2, init, op1, op2) == x); } template void test() { int ia[] = {1, 2, 3, 4, 5, 6}; unsigned int ua[] = {2, 4, 6, 8, 10,12}; unsigned sa = sizeof(ia) / sizeof(ia[0]); assert(sa == sizeof(ua) / sizeof(ua[0])); // just to be sure test(SIter(ia), SIter(ia), UIter(ua), 0, std::plus<>(), std::multiplies<>(), 0); test(UIter(ua), UIter(ua), SIter(ia), 1, std::multiplies<>(), std::plus<>(), 1); test(SIter(ia), SIter(ia+1), UIter(ua), 0, std::multiplies<>(), std::plus<>(), 0); test(UIter(ua), UIter(ua+1), SIter(ia), 2, std::plus<>(), std::multiplies<>(), 4); test(SIter(ia), SIter(ia+2), UIter(ua), 0, std::plus<>(), std::multiplies<>(), 10); test(UIter(ua), UIter(ua+2), SIter(ia), 3, std::multiplies<>(), std::plus<>(), 54); test(SIter(ia), SIter(ia+sa), UIter(ua), 4, std::multiplies<>(), std::plus<>(), 2099520); test(UIter(ua), UIter(ua+sa), SIter(ia), 4, std::plus<>(), std::multiplies<>(), 186); } template void test_return_type() { T *p = nullptr; - static_assert( std::is_same_v(), std::multiplies<>()))> ); } int main() { test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); test_return_type(); // All the iterator categories test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); test, input_iterator >(); test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); // just plain pointers (const vs. non-const, too) test(); test(); test< int*, const unsigned int *>(); test< int*, unsigned int *>(); } Index: vendor/libc++/dist/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/allocator.adaptor/allocator.adaptor.cnstr/allocs.pass.cpp (revision 320380) @@ -1,117 +1,117 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 // // template // class scoped_allocator_adaptor // template // scoped_allocator_adaptor(OuterA2&& outerAlloc, // const InnerAllocs& ...innerAllocs); #include #include #include "allocators.h" int main() { { typedef std::scoped_allocator_adaptor> A; A1 a3(3); A a(a3); assert(a.outer_allocator() == A1(3)); assert(a.inner_allocator() == a); assert(A1::copy_called == true); assert(A1::move_called == false); } A1::copy_called = false; { typedef std::scoped_allocator_adaptor> A; A a(A1(3)); assert(a.outer_allocator() == A1(3)); assert(a.inner_allocator() == a); assert(A1::copy_called == false); assert(A1::move_called == true); } A1::move_called = false; { typedef std::scoped_allocator_adaptor, A2> A; A1 a4(4); A a(a4, A2(5)); assert(A1::copy_called == true); assert(A1::move_called == false); assert(A2::copy_called == true); assert(A2::move_called == false); assert(a.outer_allocator() == A1(4)); assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; { typedef std::scoped_allocator_adaptor, A2> A; A a(A1(4), A2(5)); assert(A1::copy_called == false); assert(A1::move_called == true); assert(A2::copy_called == true); assert(A2::move_called == false); assert(a.outer_allocator() == A1(4)); assert(a.inner_allocator() == std::scoped_allocator_adaptor>(A2(5))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; A1::move_called = false; { typedef std::scoped_allocator_adaptor, A2, A3> A; A1 a4(4); A a(a4, A2(5), A3(6)); assert(A1::copy_called == true); assert(A1::move_called == false); assert(A2::copy_called == true); assert(A2::move_called == false); assert(A3::copy_called == true); assert(A3::move_called == false); assert(a.outer_allocator() == A1(4)); assert((a.inner_allocator() == std::scoped_allocator_adaptor, A3>(A2(5), A3(6)))); } A1::copy_called = false; A1::move_called = false; A2::copy_called = false; A2::move_called = false; A3::copy_called = false; A3::move_called = false; { typedef std::scoped_allocator_adaptor, A2, A3> A; A a(A1(4), A2(5), A3(6)); assert(A1::copy_called == false); assert(A1::move_called == true); assert(A2::copy_called == true); assert(A2::move_called == false); assert(A3::copy_called == true); assert(A3::move_called == false); assert(a.outer_allocator() == A1(4)); assert((a.inner_allocator() == std::scoped_allocator_adaptor, A3>(A2(5), A3(6)))); } // Test for LWG2782 { static_assert(!std::is_convertible, A2>::value, ""); static_assert(!std::is_convertible< - std::scoped_allocator_adaptor>, + std::scoped_allocator_adaptor>, std::scoped_allocator_adaptor>>::value, ""); } } Index: vendor/libc++/dist/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_move.pass.cpp (revision 320380) @@ -1,153 +1,153 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // class function // function(const function& f); -// function(const function&& f); +// function(function&& f); #include #include #include #include #include "test_macros.h" #include "count_new.hpp" class A { int data_[10]; public: static int count; A() { ++count; for (int i = 0; i < 10; ++i) data_[i] = i; } A(const A&) {++count;} ~A() {--count;} int operator()(int i) const { for (int j = 0; j < 10; ++j) i += data_[j]; return i; } }; int A::count = 0; int g(int) {return 0;} int main() { assert(globalMemCounter.checkOutstandingNewEq(0)); { std::function f = A(); assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f.target()); assert(f.target() == 0); std::function f2 = f; assert(A::count == 2); assert(globalMemCounter.checkOutstandingNewEq(2)); assert(f2.target()); assert(f2.target() == 0); } assert(A::count == 0); assert(globalMemCounter.checkOutstandingNewEq(0)); { std::function f = g; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f.target()); assert(f.target() == 0); std::function f2 = f; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f2.target()); assert(f2.target() == 0); } assert(globalMemCounter.checkOutstandingNewEq(0)); { std::function f; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f.target() == 0); assert(f.target() == 0); std::function f2 = f; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f2.target() == 0); assert(f2.target() == 0); } { std::function f; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(f.target() == 0); assert(f.target() == 0); assert(!f); std::function g = f; assert(globalMemCounter.checkOutstandingNewEq(0)); assert(g.target() == 0); assert(g.target() == 0); assert(!g); } #if TEST_STD_VER >= 11 assert(globalMemCounter.checkOutstandingNewEq(0)); { // Test rvalue references std::function f = A(); assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f.target()); assert(f.target() == 0); std::function f2 = std::move(f); assert(A::count == 1); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(f2.target()); assert(f2.target() == 0); assert(f.target() == 0); assert(f.target() == 0); } assert(globalMemCounter.checkOutstandingNewEq(0)); { // Test that moving a function constructed from a reference wrapper // is done without allocating. DisableAllocationGuard g; using Ref = std::reference_wrapper; A a; Ref aref(a); std::function f(aref); assert(A::count == 1); assert(f.target() == nullptr); assert(f.target()); std::function f2(std::move(f)); assert(A::count == 1); assert(f2.target() == nullptr); assert(f2.target()); LIBCPP_ASSERT(f.target()); // f is unchanged because the target is small } { // Test that moving a function constructed from a function pointer // is done without allocating DisableAllocationGuard guard; using Ptr = int(*)(int); Ptr p = g; std::function f(p); assert(f.target() == nullptr); assert(f.target()); std::function f2(std::move(f)); assert(f2.target() == nullptr); assert(f2.target()); LIBCPP_ASSERT(f.target()); // f is unchanged because the target is small } #endif // TEST_STD_VER >= 11 } Index: vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp (revision 320380) @@ -1,228 +1,228 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 // XFAIL: with_system_cxx_lib=macosx10.12 // XFAIL: with_system_cxx_lib=macosx10.11 // XFAIL: with_system_cxx_lib=macosx10.10 // XFAIL: with_system_cxx_lib=macosx10.9 // XFAIL: with_system_cxx_lib=macosx10.7 // XFAIL: with_system_cxx_lib=macosx10.8 // // constexpr optional(optional&& rhs); #include #include #include #include "test_macros.h" #include "archetypes.hpp" using std::optional; template void test(InitArgs&&... args) { const optional orig(std::forward(args)...); optional rhs(orig); bool rhs_engaged = static_cast(rhs); optional lhs = std::move(rhs); assert(static_cast(lhs) == rhs_engaged); if (rhs_engaged) assert(*lhs == *orig); } template constexpr bool constexpr_test(InitArgs&&... args) { static_assert( std::is_trivially_copy_constructible_v, ""); // requirement const optional orig(std::forward(args)...); optional rhs(orig); optional lhs = std::move(rhs); return (lhs.has_value() == orig.has_value()) && (lhs.has_value() ? *lhs == *orig : true); } void test_throwing_ctor() { #ifndef TEST_HAS_NO_EXCEPTIONS struct Z { Z() : count(0) {} Z(Z&& o) : count(o.count + 1) { if (count == 2) throw 6; } int count; }; Z z; optional rhs(std::move(z)); try { optional lhs(std::move(rhs)); assert(false); } catch (int i) { assert(i == 6); } #endif } template void test_ref(InitArgs&&... args) { optional rhs(std::forward(args)...); bool rhs_engaged = static_cast(rhs); optional lhs = std::move(rhs); assert(static_cast(lhs) == rhs_engaged); if (rhs_engaged) assert(&(*lhs) == &(*rhs)); } void test_reference_extension() { #if defined(_LIBCPP_VERSION) && 0 // FIXME these extensions are currently disabled. using T = TestTypes::TestType; T::reset(); { T t; T::reset_constructors(); test_ref(); test_ref(t); assert(T::alive == 1); assert(T::constructed == 0); assert(T::assigned == 0); assert(T::destroyed == 0); } assert(T::destroyed == 1); assert(T::alive == 0); { T t; const T& ct = t; T::reset_constructors(); test_ref(); test_ref(t); test_ref(ct); assert(T::alive == 1); assert(T::constructed == 0); assert(T::assigned == 0); assert(T::destroyed == 0); } assert(T::alive == 0); assert(T::destroyed == 1); { T t; T::reset_constructors(); test_ref(); test_ref(std::move(t)); assert(T::alive == 1); assert(T::constructed == 0); assert(T::assigned == 0); assert(T::destroyed == 0); } assert(T::alive == 0); assert(T::destroyed == 1); { T t; const T& ct = t; T::reset_constructors(); test_ref(); test_ref(std::move(t)); test_ref(std::move(ct)); assert(T::alive == 1); assert(T::constructed == 0); assert(T::assigned == 0); assert(T::destroyed == 0); } assert(T::alive == 0); assert(T::destroyed == 1); { static_assert(!std::is_copy_constructible>::value, ""); static_assert(!std::is_copy_constructible>::value, ""); } #endif } int main() { test(); test(3); static_assert(constexpr_test(), "" ); static_assert(constexpr_test(3), "" ); - + { optional o(42); optional o2(std::move(o)); assert(*o2 == 42); } { using T = TestTypes::TestType; T::reset(); optional rhs; assert(T::alive == 0); const optional lhs(std::move(rhs)); assert(lhs.has_value() == false); assert(rhs.has_value() == false); assert(T::alive == 0); } TestTypes::TestType::reset(); { using T = TestTypes::TestType; T::reset(); optional rhs(42); assert(T::alive == 1); assert(T::value_constructed == 1); assert(T::move_constructed == 0); const optional lhs(std::move(rhs)); assert(lhs.has_value()); assert(rhs.has_value()); assert(lhs.value().value == 42); assert(rhs.value().value == -1); assert(T::move_constructed == 1); assert(T::alive == 2); } TestTypes::TestType::reset(); { using namespace ConstexprTestTypes; test(); test(42); } { using namespace TrivialTestTypes; test(); test(42); } { test_throwing_ctor(); } { struct ThrowsMove { ThrowsMove() noexcept(false) {} ThrowsMove(ThrowsMove const&) noexcept(false) {} ThrowsMove(ThrowsMove &&) noexcept(false) {} }; static_assert(!std::is_nothrow_move_constructible>::value, ""); struct NoThrowMove { NoThrowMove() noexcept(false) {} NoThrowMove(NoThrowMove const&) noexcept(false) {} NoThrowMove(NoThrowMove &&) noexcept(true) {} }; static_assert(std::is_nothrow_move_constructible>::value, ""); } { test_reference_extension(); } { constexpr std::optional o1{4}; constexpr std::optional o2 = std::move(o1); static_assert( *o2 == 4, "" ); } } Index: vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp (revision 320380) @@ -1,39 +1,39 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 // // template class tuple; // ~tuple(); // C++17 added: -// The destructor of tuple shall be a trivial destructor +// The destructor of tuple shall be a trivial destructor // if (is_trivially_destructible_v && ...) is true. #include #include #include #include int main() { static_assert(std::is_trivially_destructible< std::tuple<> >::value, ""); static_assert(std::is_trivially_destructible< std::tuple >::value, ""); static_assert(std::is_trivially_destructible< std::tuple >::value, ""); static_assert(!std::is_trivially_destructible< std::tuple >::value, ""); static_assert(!std::is_trivially_destructible< std::tuple >::value, ""); } Index: vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp (revision 320380) @@ -1,138 +1,150 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template class tuple; // template // class tuple_size> // : public integral_constant { }; // UNSUPPORTED: c++98, c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-structured-bindings #include #include #include #include struct S { int x; }; void test_decomp_user_type() { { S s{99}; auto [m1] = s; auto& [r1] = s; assert(m1 == 99); assert(&r1 == &s.x); } { S const s{99}; auto [m1] = s; auto& [r1] = s; assert(m1 == 99); assert(&r1 == &s.x); } } void test_decomp_tuple() { typedef std::tuple T; { T s{99}; auto [m1] = s; auto& [r1] = s; assert(m1 == 99); assert(&r1 == &std::get<0>(s)); } { T const s{99}; auto [m1] = s; auto& [r1] = s; assert(m1 == 99); assert(&r1 == &std::get<0>(s)); } } void test_decomp_pair() { typedef std::pair T; { - T s{99, 42.1}; + T s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); + assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); + assert(&r2 == &std::get<1>(s)); } { - T const s{99, 42.1}; + T const s{99, 42.5}; auto [m1, m2] = s; auto& [r1, r2] = s; assert(m1 == 99); + assert(m2 == 42.5); assert(&r1 == &std::get<0>(s)); + assert(&r2 == &std::get<1>(s)); } } void test_decomp_array() { typedef std::array T; { T s{{99, 42, -1}}; auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); + assert(m2 == 42); + assert(m3 == -1); assert(&r1 == &std::get<0>(s)); + assert(&r2 == &std::get<1>(s)); + assert(&r3 == &std::get<2>(s)); } { T const s{{99, 42, -1}}; auto [m1, m2, m3] = s; auto& [r1, r2, r3] = s; assert(m1 == 99); + assert(m2 == 42); + assert(m3 == -1); assert(&r1 == &std::get<0>(s)); + assert(&r2 == &std::get<1>(s)); + assert(&r3 == &std::get<2>(s)); } } struct Test { int x; }; template int get(Test const&) { static_assert(N == 0, ""); return -1; } template <> class std::tuple_element<0, Test> { public: typedef int type; }; void test_before_tuple_size_specialization() { Test const t{99}; auto& [p] = t; assert(p == 99); } template <> class std::tuple_size { public: static const size_t value = 1; }; void test_after_tuple_size_specialization() { Test const t{99}; auto& [p] = t; assert(p == -1); } int main() { test_decomp_user_type(); test_decomp_tuple(); test_decomp_pair(); test_decomp_array(); test_before_tuple_size_specialization(); test_after_tuple_size_specialization(); } Index: vendor/libc++/dist/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/utility/pairs/pairs.pair/dtor.pass.cpp (revision 320380) @@ -1,36 +1,36 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 // // template struct pair // ~pair() // C++17 added: -// The destructor of pair shall be a trivial destructor +// The destructor of pair shall be a trivial destructor // if (is_trivially_destructible_v && is_trivially_destructible_v) is true. #include #include #include #include #include "test_macros.h" int main() { static_assert((std::is_trivially_destructible< std::pair >::value), ""); static_assert((!std::is_trivially_destructible< std::pair >::value), ""); } Index: vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp =================================================================== --- vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp (revision 320379) +++ vendor/libc++/dist/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp (revision 320380) @@ -1,112 +1,126 @@ // -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 // // template class variant; // template constexpr variant(T&&) noexcept(see below); #include #include #include #include #include "test_convertible.hpp" #include "test_macros.h" #include "variant_test_helpers.hpp" struct Dummy { Dummy() = default; }; struct ThrowsT { ThrowsT(int) noexcept(false) {} }; struct NoThrowT { NoThrowT(int) noexcept(true) {} }; +struct AnyConstructible { template AnyConstructible(T&&) {} }; +struct NoConstructible { NoConstructible() = delete; }; + void test_T_ctor_noexcept() { { using V = std::variant; static_assert(std::is_nothrow_constructible::value, ""); } { using V = std::variant; static_assert(!std::is_nothrow_constructible::value, ""); } } void test_T_ctor_sfinae() { { using V = std::variant; static_assert(!std::is_constructible::value, "ambiguous"); } { using V = std::variant; static_assert(!std::is_constructible::value, "ambiguous"); } { using V = std::variant; static_assert(!std::is_constructible::value, "no matching constructor"); } + { + using V = std::variant; + static_assert( + !std::is_constructible>::value, + "no matching constructor"); + static_assert(!std::is_constructible>::value, + "no matching constructor"); + } + + + #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { using V = std::variant; static_assert(!std::is_constructible::value, "ambiguous"); } { using V = std::variant; static_assert(!std::is_constructible::value, "ambiguous"); } #endif } void test_T_ctor_basic() { { constexpr std::variant v(42); static_assert(v.index() == 0, ""); static_assert(std::get<0>(v) == 42, ""); } { constexpr std::variant v(42l); static_assert(v.index() == 1, ""); static_assert(std::get<1>(v) == 42, ""); } #if !defined(TEST_VARIANT_HAS_NO_REFERENCES) { using V = std::variant; static_assert(std::is_convertible::value, "must be implicit"); int x = 42; V v(x); assert(v.index() == 0); assert(&std::get<0>(v) == &x); } { using V = std::variant; static_assert(std::is_convertible::value, "must be implicit"); int x = 42; V v(std::move(x)); assert(v.index() == 1); assert(&std::get<1>(v) == &x); } #endif } int main() { test_T_ctor_basic(); test_T_ctor_noexcept(); test_T_ctor_sfinae(); } Index: vendor/libc++/dist/test/support/count_new.hpp =================================================================== --- vendor/libc++/dist/test/support/count_new.hpp (revision 320379) +++ vendor/libc++/dist/test/support/count_new.hpp (revision 320380) @@ -1,322 +1,327 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef COUNT_NEW_HPP #define COUNT_NEW_HPP # include # include # include #include "test_macros.h" #if defined(TEST_HAS_SANITIZERS) #define DISABLE_NEW_COUNT #endif namespace detail { TEST_NORETURN inline void throw_bad_alloc_helper() { #ifndef TEST_HAS_NO_EXCEPTIONS throw std::bad_alloc(); #else std::abort(); #endif } } class MemCounter { public: // Make MemCounter super hard to accidentally construct or copy. class MemCounterCtorArg_ {}; explicit MemCounter(MemCounterCtorArg_) { reset(); } private: MemCounter(MemCounter const &); MemCounter & operator=(MemCounter const &); public: // All checks return true when disable_checking is enabled. static const bool disable_checking; // Disallow any allocations from occurring. Useful for testing that // code doesn't perform any allocations. bool disable_allocations; // number of allocations to throw after. Default (unsigned)-1. If // throw_after has the default value it will never be decremented. static const unsigned never_throw_value = static_cast(-1); unsigned throw_after; int outstanding_new; int new_called; int delete_called; std::size_t last_new_size; int outstanding_array_new; int new_array_called; int delete_array_called; std::size_t last_new_array_size; public: void newCalled(std::size_t s) { assert(disable_allocations == false); assert(s); if (throw_after == 0) { throw_after = never_throw_value; detail::throw_bad_alloc_helper(); } else if (throw_after != never_throw_value) { --throw_after; } ++new_called; ++outstanding_new; last_new_size = s; } void deleteCalled(void * p) { assert(p); --outstanding_new; ++delete_called; } void newArrayCalled(std::size_t s) { assert(disable_allocations == false); assert(s); if (throw_after == 0) { throw_after = never_throw_value; detail::throw_bad_alloc_helper(); } else { // don't decrement throw_after here. newCalled will end up doing that. } ++outstanding_array_new; ++new_array_called; last_new_array_size = s; } void deleteArrayCalled(void * p) { assert(p); --outstanding_array_new; ++delete_array_called; } void disableAllocations() { disable_allocations = true; } void enableAllocations() { disable_allocations = false; } void reset() { disable_allocations = false; throw_after = never_throw_value; outstanding_new = 0; new_called = 0; delete_called = 0; last_new_size = 0; outstanding_array_new = 0; new_array_called = 0; delete_array_called = 0; last_new_array_size = 0; } public: bool checkOutstandingNewEq(int n) const { return disable_checking || n == outstanding_new; } bool checkOutstandingNewNotEq(int n) const { return disable_checking || n != outstanding_new; } bool checkNewCalledEq(int n) const { return disable_checking || n == new_called; } bool checkNewCalledNotEq(int n) const { return disable_checking || n != new_called; } bool checkNewCalledGreaterThan(int n) const { return disable_checking || new_called > n; } bool checkDeleteCalledEq(int n) const { return disable_checking || n == delete_called; } bool checkDeleteCalledNotEq(int n) const { return disable_checking || n != delete_called; } bool checkLastNewSizeEq(std::size_t n) const { return disable_checking || n == last_new_size; } bool checkLastNewSizeNotEq(std::size_t n) const { return disable_checking || n != last_new_size; } bool checkOutstandingArrayNewEq(int n) const { return disable_checking || n == outstanding_array_new; } bool checkOutstandingArrayNewNotEq(int n) const { return disable_checking || n != outstanding_array_new; } bool checkNewArrayCalledEq(int n) const { return disable_checking || n == new_array_called; } bool checkNewArrayCalledNotEq(int n) const { return disable_checking || n != new_array_called; } bool checkDeleteArrayCalledEq(int n) const { return disable_checking || n == delete_array_called; } bool checkDeleteArrayCalledNotEq(int n) const { return disable_checking || n != delete_array_called; } bool checkLastNewArraySizeEq(std::size_t n) const { return disable_checking || n == last_new_array_size; } bool checkLastNewArraySizeNotEq(std::size_t n) const { return disable_checking || n != last_new_array_size; } }; #ifdef DISABLE_NEW_COUNT const bool MemCounter::disable_checking = true; #else const bool MemCounter::disable_checking = false; #endif -MemCounter globalMemCounter((MemCounter::MemCounterCtorArg_())); +inline MemCounter* getGlobalMemCounter() { + static MemCounter counter((MemCounter::MemCounterCtorArg_())); + return &counter; +} +MemCounter &globalMemCounter = *getGlobalMemCounter(); + #ifndef DISABLE_NEW_COUNT void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc) { - globalMemCounter.newCalled(s); + getGlobalMemCounter()->newCalled(s); void* ret = std::malloc(s); if (ret == nullptr) detail::throw_bad_alloc_helper(); return ret; } void operator delete(void* p) TEST_NOEXCEPT { - globalMemCounter.deleteCalled(p); + getGlobalMemCounter()->deleteCalled(p); std::free(p); } void* operator new[](std::size_t s) TEST_THROW_SPEC(std::bad_alloc) { - globalMemCounter.newArrayCalled(s); + getGlobalMemCounter()->newArrayCalled(s); return operator new(s); } void operator delete[](void* p) TEST_NOEXCEPT { - globalMemCounter.deleteArrayCalled(p); + getGlobalMemCounter()->deleteArrayCalled(p); operator delete(p); } #endif // DISABLE_NEW_COUNT struct DisableAllocationGuard { explicit DisableAllocationGuard(bool disable = true) : m_disabled(disable) { // Don't re-disable if already disabled. if (globalMemCounter.disable_allocations == true) m_disabled = false; if (m_disabled) globalMemCounter.disableAllocations(); } void release() { if (m_disabled) globalMemCounter.enableAllocations(); m_disabled = false; } ~DisableAllocationGuard() { release(); } private: bool m_disabled; DisableAllocationGuard(DisableAllocationGuard const&); DisableAllocationGuard& operator=(DisableAllocationGuard const&); }; struct RequireAllocationGuard { explicit RequireAllocationGuard(std::size_t RequireAtLeast = 1) : m_req_alloc(RequireAtLeast), m_new_count_on_init(globalMemCounter.new_called), m_outstanding_new_on_init(globalMemCounter.outstanding_new), m_exactly(false) { } void requireAtLeast(std::size_t N) { m_req_alloc = N; m_exactly = false; } void requireExactly(std::size_t N) { m_req_alloc = N; m_exactly = true; } ~RequireAllocationGuard() { assert(globalMemCounter.checkOutstandingNewEq(static_cast(m_outstanding_new_on_init))); std::size_t Expect = m_new_count_on_init + m_req_alloc; assert(globalMemCounter.checkNewCalledEq(static_cast(Expect)) || (!m_exactly && globalMemCounter.checkNewCalledGreaterThan(static_cast(Expect)))); } private: std::size_t m_req_alloc; const std::size_t m_new_count_on_init; const std::size_t m_outstanding_new_on_init; bool m_exactly; RequireAllocationGuard(RequireAllocationGuard const&); RequireAllocationGuard& operator=(RequireAllocationGuard const&); }; #endif /* COUNT_NEW_HPP */ Index: vendor/libc++/dist/test/support/experimental_any_helpers.h =================================================================== --- vendor/libc++/dist/test/support/experimental_any_helpers.h (revision 320379) +++ vendor/libc++/dist/test/support/experimental_any_helpers.h (revision 320380) @@ -1,326 +1,328 @@ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef EXPERIMENTAL_ANY_HELPERS_H #define EXPERIMENTAL_ANY_HELPERS_H #include #include #include #include #include "test_macros.h" #if !defined(TEST_HAS_NO_RTTI) #define RTTI_ASSERT(X) assert(X) #else #define RTTI_ASSERT(X) #endif template struct IsSmallObject : public std::integral_constant::value % std::alignment_of<_Tp>::value == 0 && std::is_nothrow_move_constructible<_Tp>::value > {}; // Return 'true' if 'Type' will be considered a small type by 'any' template bool isSmallType() { #if defined(_LIBCPP_VERSION) return std::experimental::__any_imp::_IsSmallObject::value; #else return IsSmallObject::value; #endif } // Assert that an object is empty. If the object used to contain an object // of type 'LastType' check that it can no longer be accessed. template void assertEmpty(std::experimental::any const& a) { assert(a.empty()); RTTI_ASSERT(a.type() == typeid(void)); assert(std::experimental::any_cast(&a) == nullptr); } // Assert that an 'any' object stores the specified 'Type' and 'value'. template +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void assertContains(std::experimental::any const& a, int value = 1) { assert(!a.empty()); RTTI_ASSERT(a.type() == typeid(Type)); assert(std::experimental::any_cast(a).value == value); } // Modify the value of a "test type" stored within an any to the specified // 'value'. template +_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void modifyValue(std::experimental::any& a, int value) { assert(!a.empty()); RTTI_ASSERT(a.type() == typeid(Type)); std::experimental::any_cast(a).value = value; } // A test type that will trigger the small object optimization within 'any'. template struct small_type { static int count; static int copied; static int moved; static int const_copied; static int non_const_copied; static void reset() { small_type::copied = 0; small_type::moved = 0; small_type::const_copied = 0; small_type::non_const_copied = 0; } int value; explicit small_type(int val) : value(val) { ++count; } small_type(small_type const & other) throw() { value = other.value; ++count; ++copied; ++const_copied; } small_type(small_type& other) throw() { value = other.value; ++count; ++copied; ++non_const_copied; } small_type(small_type && other) throw() { value = other.value; other.value = 0; ++count; ++moved; } ~small_type() { value = -1; --count; } private: small_type& operator=(small_type const&) = delete; small_type& operator=(small_type&&) = delete; }; template int small_type::count = 0; template int small_type::copied = 0; template int small_type::moved = 0; template int small_type::const_copied = 0; template int small_type::non_const_copied = 0; typedef small_type<> small; typedef small_type<1> small1; typedef small_type<2> small2; // A test type that will NOT trigger the small object optimization in any. template struct large_type { static int count; static int copied; static int moved; static int const_copied; static int non_const_copied; static void reset() { large_type::copied = 0; large_type::moved = 0; large_type::const_copied = 0; large_type::non_const_copied = 0; } int value; large_type(int val) : value(val) { ++count; data[0] = 0; } large_type(large_type const & other) { value = other.value; ++count; ++copied; ++const_copied; } large_type(large_type & other) { value = other.value; ++count; ++copied; ++non_const_copied; } large_type(large_type && other) { value = other.value; other.value = 0; ++count; ++moved; } ~large_type() { value = 0; --count; } private: large_type& operator=(large_type const&) = delete; large_type& operator=(large_type &&) = delete; int data[10]; }; template int large_type::count = 0; template int large_type::copied = 0; template int large_type::moved = 0; template int large_type::const_copied = 0; template int large_type::non_const_copied = 0; typedef large_type<> large; typedef large_type<1> large1; typedef large_type<2> large2; // The exception type thrown by 'small_throws_on_copy', 'large_throws_on_copy' // and 'throws_on_move'. struct my_any_exception {}; void throwMyAnyExpression() { #if !defined(TEST_HAS_NO_EXCEPTIONS) throw my_any_exception(); #else assert(false && "Exceptions are disabled"); #endif } // A test type that will trigger the small object optimization within 'any'. // this type throws if it is copied. struct small_throws_on_copy { static int count; int value; explicit small_throws_on_copy(int val = 0) : value(val) { ++count; } small_throws_on_copy(small_throws_on_copy const &) { throwMyAnyExpression(); } small_throws_on_copy(small_throws_on_copy && other) throw() { value = other.value; ++count; } ~small_throws_on_copy() { --count; } private: small_throws_on_copy& operator=(small_throws_on_copy const&) = delete; small_throws_on_copy& operator=(small_throws_on_copy &&) = delete; }; int small_throws_on_copy::count = 0; // A test type that will NOT trigger the small object optimization within 'any'. // this type throws if it is copied. struct large_throws_on_copy { static int count; int value = 0; explicit large_throws_on_copy(int val = 0) : value(val) { data[0] = 0; ++count; } large_throws_on_copy(large_throws_on_copy const &) { throwMyAnyExpression(); } large_throws_on_copy(large_throws_on_copy && other) throw() { value = other.value; ++count; } ~large_throws_on_copy() { --count; } private: large_throws_on_copy& operator=(large_throws_on_copy const&) = delete; large_throws_on_copy& operator=(large_throws_on_copy &&) = delete; int data[10]; }; int large_throws_on_copy::count = 0; // A test type that throws when it is moved. This object will NOT trigger // the small object optimization in 'any'. struct throws_on_move { static int count; int value; explicit throws_on_move(int val = 0) : value(val) { ++count; } throws_on_move(throws_on_move const & other) { value = other.value; ++count; } throws_on_move(throws_on_move &&) { throwMyAnyExpression(); } ~throws_on_move() { --count; } private: throws_on_move& operator=(throws_on_move const&) = delete; throws_on_move& operator=(throws_on_move &&) = delete; }; int throws_on_move::count = 0; #endif Index: vendor/libc++/dist/www/upcoming_meeting.html =================================================================== --- vendor/libc++/dist/www/upcoming_meeting.html (revision 320379) +++ vendor/libc++/dist/www/upcoming_meeting.html (revision 320380) @@ -1,129 +1,99 @@ libc++ Upcoming Meeting Status

libc++ Issaquah Status

This is a temporary page; please check the c++1z status here

-

This page shows the status of the papers and issues that are expected to be adopted in Issaquah.

+

This page shows the status of the papers and issues that are expected to be adopted in Toronto.

The groups that have contributed papers:

  • LWG - Library working group
  • CWG - Core Language Working group
  • SG1 - Study group #1 (Concurrency working group)

- +

Paper Status

Paper #GroupPaper NameMeetingStatusFirst released version

Library Working group Issues Status

- - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - -
Issue #Issue NameMeetingStatus
2260Missing requirement for Allocator::pointerKona
2768any_cast and move semanticsKona
2769Redundant const in the return type of any_cast(const any&)Kona
2781Contradictory requirements for std::function and std::reference_wrapperKona
2782scoped_allocator_adaptor constructors must be constrainedKona
2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKonaPatch Ready
2785quoted should work with basic_string_viewKonaWe do this already
2786Annex C should mention shared_ptr changes for array supportKonaNothing to do
2787§[file_status.cons] doesn't match class definitionKona
2789Equivalence of contained objectsKona
2794Missing requirements for allocator pointersKona
2795§[global.functions] provides incorrect example of ADL useKonaNothing to do
2804Unconditional constexpr default constructor for istream_iteratorKonaWe do this already
2812Range access is available with <string_view>KonaWe do this already
2824list::sort should say that the order of elements is unspecified if an exception is thrownKona
2826string_view iterators use old wordingKonaNothing to do
2834Resolution LWG 2223 is missing wording about end iteratorsKonaNothing to do
2835LWG 2536 seems to misspecify <tgmath.h>Kona
2837gcd and lcm should support a wider range of input valuesKonaWe do this already
2838is_literal_type specification needs a little cleanupKonaNothing to do
2842in_place_t check for optional::optional(U&&) should decay UKona
2850std::function move constructor does unnecessary workKona
2853Possible inconsistency in specification of erase in [vector.modifiers]Kona
2855std::throw_with_nested("string_literal")Kona
2444Inconsistent complexity for std::sort_heapToronto
2593Moved-from state of AllocatorsToronto
2597std::log misspecified for complex numbersToronto
2783stack::emplace() and queue::emplace() should return decltype(auto)Toronto
2932Constraints on parallel algorithm implementations are underspecifiedToronto
2937Is equivalent("existing_thing", "not_existing_thing") an error?Toronto
2940result_of specification also needs a little cleanupToronto
2942LWG 2873's resolution missed weak_ptr::owner_beforeToronto
2954Specialization of the convenience variable templates should be prohibitedToronto
2961Bad postcondition for set_default_resourceToronto
2966Incomplete resolution of US 74Toronto
2974Diagnose out of bounds tuple_element/variant_alternativeToronto
Priority 1 Bugs
2665remove_filename() post condition is incorrectKonaWe do this already
2806Base class of bad_optional_accessKonaWe do this already
2857{variant,optional,any}::emplace should return the constructed valueKona

Comments about the issues

    -
  • 2260 - Check our current allocators to make sure we do this
  • -
  • 2768 - Resolution is "apply 2769"
  • -
  • 2769 - This should be easy; trick will be devising tests.
  • -
  • 2781 -
  • -
  • 2782 - Looks straightforward.
  • -
  • 2784 - Patch Ready
  • -
  • 2785 - We do this already.
  • -
  • 2786 - Nothing to do; just moving words around
  • -
  • 2787 - Eric?
  • -
  • 2789 - I don't think there are any code changes required here
  • -
  • 2794 - I don't think there are any code changes required here - maybe a static_assert.
  • -
  • 2795 - Nothing to do; just moving words around
  • -
  • 2804 - We do this already.
  • -
  • 2812 - We do this already.
  • -
  • 2824 - Nothing do to here, but we should add some throwing sort tests.
  • -
  • 2826 - Nothing to do; just moving words around
  • -
  • 2834 - Nothing to do; just moving words around
  • -
  • 2835 - I'm pretty sure we already do this.
  • -
  • 2837 - Added some tests to ensure we do this already.
  • -
  • 2838 - Nothing to do; just moving words around
  • -
  • 2842 - This should be easy; trick will be devising tests.
  • -
  • 2850 - I think we already do this.
  • -
  • 2853 - I think that this will be mostly adding tests.
  • -
  • 2855 - This should be easy; trick will be devising tests.
  • -
  • -
  • 2665 - We do this already.
  • -
  • 2806 - We do this already.
  • -
  • 2857 - This is the subject of several NB comments.
  • +
  • 2444 -
  • +
  • 2593 -
  • +
  • 2597 - I think we do this already; probably needs tests
  • +
  • 2783 - should be easy to change; needs tests
  • +
  • 2932 - We're not doing the parallel algorithms yet.
  • +
  • 2937 - file system; Eric?
  • +
  • 2940 - We haven't implemented result_of yet, but I don't think that this will require any changes.
  • +
  • 2942 - all of our owner_before overloads are already noexcept; just need to update the tests.
  • +
  • 2954 - I don't think there's anything to do here.
  • +
  • 2961 - We haven't implemented the PMR stuff yet.
  • +
  • 2966 - Wording cleanup; no code or test changes needed.
  • +
  • 2974 - I have some code lying around that does this.
-

Last Updated: 7-Feb-2017

+

Last Updated: 25-Jun-2017