Index: vendor/libc++/dist/CMakeLists.txt =================================================================== --- vendor/libc++/dist/CMakeLists.txt (revision 317954) +++ vendor/libc++/dist/CMakeLists.txt (revision 317955) @@ -1,637 +1,646 @@ # 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 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") -set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) +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) # 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. -add_subdirectory(test) +# +# 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/appveyor.yml =================================================================== --- vendor/libc++/dist/appveyor.yml (revision 317954) +++ vendor/libc++/dist/appveyor.yml (revision 317955) @@ -1,97 +1,68 @@ version: '{build}' shallow_clone: true -os: - - Visual Studio 2015 - build: verbosity: detailed -branches: - only: - - master - configuration: - Debug environment: matrix: - - COMPILER: Clang-CL 4.0 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CLANG_VERSION: ToT + MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat + MSVC_SETUP_ARG: x86 + APPVEYOR_SAVE_CACHE_ON_ERROR: true + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + CLANG_VERSION: 4 + MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat + MSVC_SETUP_ARG: x86_amd64 + APPVEYOR_SAVE_CACHE_ON_ERROR: true install: ############################################################################ # All external dependencies are installed in C:\projects\deps ############################################################################ - - mkdir C:\projects\deps - - cd C:\projects\deps + - call "%APPVEYOR_BUILD_FOLDER%\\install-appveyor-reqs.cmd" - ############################################################################ - # Install Ninja - ############################################################################ - - set NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip" - - appveyor DownloadFile %NINJA_URL% -FileName ninja.zip - - 7z x ninja.zip -oC:\projects\deps\ninja > nul - - set PATH=C:\projects\deps\ninja;%PATH% - - ninja --version - - ############################################################################ - # Install a recent CMake - ############################################################################ - - set CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.zip" - - appveyor DownloadFile %CMAKE_URL% -FileName cmake.zip - - 7z x cmake.zip -oC:\projects\deps > nul - - move C:\projects\deps\cmake-* C:\projects\deps\cmake # Move to a version-agnostic directory - - set PATH=C:\projects\deps\cmake\bin;%PATH% - - cmake --version - - ############################################################################ - # Setup the path to Clang-cl - ############################################################################ - - set PATH="C:\Program Files\LLVM\bin";%PATH% - - clang-cl -v - - ############################################################################ - # Setup the cached copy of LLVM - ############################################################################ - - if exist llvm (git -C llvm pull --rebase=true --ff-only) - - if not exist llvm (git clone --depth=1 http://llvm.org/git/llvm.git) - - before_build: - - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 - - cd C:\projects\libcxx + - call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG% + - cd %APPVEYOR_BUILD_FOLDER% build_script: - md C:\projects\build-libcxx - cd C:\projects\build-libcxx - echo %configuration% ############################################################################# # Configuration Step ############################################################################# - cmake -G Ninja %extra_cmake_flags% -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe "-DCMAKE_BUILD_TYPE=%configuration%" "-DLLVM_PATH=C:\projects\deps\llvm" -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF - -DLLVM_LIT_ARGS="-sv --no-progress-bar --show-xfail --show-unsupported" - C:\projects\libcxx + -DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported" + %APPVEYOR_BUILD_FOLDER% ############################################################################# # Build Step ############################################################################# - ninja test_script: - ninja check-cxx on_failure: - appveyor PushArtifact CMakeFiles/CMakeOutput.log - appveyor PushArtifact CMakeFiles/CMakeError.log artifacts: - path: '_build/CMakeFiles/*.log' name: logs cache: - - C:\projects\deps\llvm + - C:\projects\deps\ninja + - C:\projects\deps\cmake + - C:\projects\deps\llvm-installer.exe Index: vendor/libc++/dist/docs/DesignDocs/AvailabilityMarkup.rst =================================================================== --- vendor/libc++/dist/docs/DesignDocs/AvailabilityMarkup.rst (nonexistent) +++ vendor/libc++/dist/docs/DesignDocs/AvailabilityMarkup.rst (revision 317955) @@ -0,0 +1,114 @@ +=================== +Availability Markup +=================== + +.. contents:: + :local: + +Overview +======== + +Libc++ is used as a system library on macOS and iOS (amongst others). In order +for users to be able to compile a binary that is intended to be deployed to an +older version of the platform, clang provides the +`availability attribute `_ +that can be placed on declarations to describe the lifecycle of a symbol in the +library. + +Design +====== + +When a new feature is introduced that requires dylib support, a macro should be +created in include/__config to mark this feature as unavailable for all the +systems. For example:: + + // Define availability macros. + #if defined(_LIBCPP_USE_AVAILABILITY_APPLE) + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) + #else if defined(_LIBCPP_USE_AVAILABILITY_SOME_OTHER_VENDOR) + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable)) + #else + #define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS + #endif + +When the library is updated by the platform vendor, the markup can be updated. +For example:: + + #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))) + +In the source code, the macro can be added on a class if the full class requires +type info from the library for example:: + + _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL + class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access + : public std::logic_error { + +or on a particular symbol: + + _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; + + +Testing +======= + +Some parameters can be passed to lit to run the test-suite and exercising the +availability. + +* The `platform` parameter controls the deployement target. For example lit can + be invoked with `--param=platform=macosx10.8`. Default is the current host. +* The `use_system_cxx_lib` parameter indicates to use another library than the + just built one. Invoking lit with `--param=use_system_cxx_lib=true` will run + the test-suite against the host system library. Alternatively a path to the + directory containing a specific prebuilt libc++ can be used, for example: + `--param=use_system_cxx_lib=/path/to/macOS/10.8/`. +* The `with_availability` boolean parameter enables the availability markup. + +Tests can be marked as XFAIL based on multiple features made available by lit: + + +* if either `use_system_cxx_lib` or `with_availability` is passed to lit, + assuming `--param=platform=macosx10.8` is passed as well the following + features will be available: + + - availability + - availability=x86_64 + - availability=macosx + - availability=x86_64-macosx + - availability=x86_64-apple-macosx10.8 + - availability=macosx10.8 + + This feature is used to XFAIL a test that *is* using a class of a method marked + as unavailable *and* that is expected to *fail* if deployed on an older system. + +* if `use_system_cxx_lib` is passed to lit, the following features will also + be available: + + - with_system_cxx_lib + - with_system_cxx_lib=x86_64 + - with_system_cxx_lib=macosx + - with_system_cxx_lib=x86_64-macosx + - with_system_cxx_lib=x86_64-apple-macosx10.8 + - with_system_cxx_lib=macosx10.8 + + This feature is used to XFAIL a test that is *not* using a class of a method + marked as unavailable *but* that is expected to fail if deployed on an older + system. For example if we know that it exhibits a but in the libc on a + particular system version. + +* if `with_availability` is passed to lit, the following features will also + be available: + + - availability_markup + - availability_markup=x86_64 + - availability_markup=macosx + - availability_markup=x86_64-macosx + - availability_markup=x86_64-apple-macosx10.8 + - availability_markup=macosx10.8 + + This feature is used to XFAIL a test that *is* using a class of a method + marked as unavailable *but* that is expected to *pass* if deployed on an older + system. For example if it is using a symbol in a statically evaluated context. Index: vendor/libc++/dist/docs/index.rst =================================================================== --- vendor/libc++/dist/docs/index.rst (revision 317954) +++ vendor/libc++/dist/docs/index.rst (revision 317955) @@ -1,187 +1,188 @@ .. _index: ============================= "libc++" C++ Standard Library ============================= Overview ======== libc++ is a new implementation of the C++ standard library, targeting C++11 and above. * Features and Goals * Correctness as defined by the C++11 standard. * Fast execution. * Minimal memory use. * Fast compile times. * ABI compatibility with gcc's libstdc++ for some low-level features such as exception objects, rtti and memory allocation. * Extensive unit tests. * Design and Implementation: * Extensive unit tests * Internal linker model can be dumped/read to textual format * Additional linking features can be plugged in as "passes" * OS specific and CPU specific code factored out Getting Started with libc++ --------------------------- .. toctree:: :maxdepth: 2 UsingLibcxx BuildingLibcxx TestingLibcxx Current Status -------------- After its initial introduction, many people have asked "why start a new library instead of contributing to an existing library?" (like Apache's libstdcxx, GNU's libstdc++, STLport, etc). There are many contributing reasons, but some of the major ones are: * From years of experience (including having implemented the standard library before), we've learned many things about implementing the standard containers which require ABI breakage and fundamental changes to how they are implemented. For example, it is generally accepted that building std::string using the "short string optimization" instead of using Copy On Write (COW) is a superior approach for multicore machines (particularly in C++11, which has rvalue references). Breaking ABI compatibility with old versions of the library was determined to be critical to achieving the performance goals of libc++. * Mainline libstdc++ has switched to GPL3, a license which the developers of libc++ cannot use. libstdc++ 4.2 (the last GPL2 version) could be independently extended to support C++11, but this would be a fork of the codebase (which is often seen as worse for a project than starting a new independent one). Another problem with libstdc++ is that it is tightly integrated with G++ development, tending to be tied fairly closely to the matching version of G++. * STLport and the Apache libstdcxx library are two other popular candidates, but both lack C++11 support. Our experience (and the experience of libstdc++ developers) is that adding support for C++11 (in particular rvalue references and move-only types) requires changes to almost every class and function, essentially amounting to a rewrite. Faced with a rewrite, we decided to start from scratch and evaluate every design decision from first principles based on experience. Further, both projects are apparently abandoned: STLport 5.2.1 was released in Oct'08, and STDCXX 4.2.1 in May'08. Platform and Compiler Support ----------------------------- libc++ is known to work on the following platforms, using gcc-4.2 and clang (lack of C++11 language support disables some functionality). Note that functionality provided by ```` is only functional with clang and GCC. ============ ==================== ============ ======================== OS Arch Compilers ABI Library ============ ==================== ============ ======================== Mac OS X i386, x86_64 Clang, GCC libc++abi FreeBSD 10+ i386, x86_64, ARM Clang, GCC libcxxrt, libc++abi Linux i386, x86_64 Clang, GCC libc++abi ============ ==================== ============ ======================== The following minimum compiler versions are strongly recommended. * Clang 3.5 and above * GCC 4.7 and above. Anything older *may* work. C++ Dialect Support --------------------- * C++11 - Complete * `C++14 - Complete `__ * `C++1z - In Progress `__ * `Post C++14 Technical Specifications - In Progress `__ Notes and Known Issues ---------------------- This list contains known issues with libc++ * Building libc++ with ``-fno-rtti`` is not supported. However linking against it with ``-fno-rtti`` is supported. * On OS X v10.8 and older the CMake option ``-DLIBCXX_LIBCPPABI_VERSION=""`` must be used during configuration. A full list of currently open libc++ bugs can be `found here`__. .. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 Design Documents ---------------- .. toctree:: :maxdepth: 1 + DesignDocs/AvailabilityMarkup DesignDocs/DebugMode DesignDocs/CapturingConfigInfo DesignDocs/ABIVersioning DesignDocs/VisibilityMacros DesignDocs/ThreadingSupportAPI * ` design `_ * ` design `_ * `Notes by Marshall Clow`__ .. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/ Build Bots and Test Coverage ---------------------------- * `LLVM Buildbot Builders `_ * `Apple Jenkins Builders `_ -* `EricWF's Nightly Builders `_ +* `Windows Appveyor Builders `_ * `Code Coverage Results `_ Getting Involved ================ First please review our `Developer's Policy `__ and `Getting started with LLVM `__. **Bug Reports** If you think you've found a bug in libc++, please report it using the `LLVM Bugzilla`_. If you're not sure, you can post a message to the `cfe-dev mailing list`_ or on IRC. Please include "libc++" in your subject. **Patches** If you want to contribute a patch to libc++, the best place for that is `Phabricator `_. Please include [libcxx] in the subject and add `cfe-commits` as a subscriber. Also make sure you are subscribed to the `cfe-commits mailing list `_. **Discussion and Questions** Send discussions and questions to the `cfe-dev mailing list `_. Please include [libcxx] in the subject. Quick Links =========== * `LLVM Homepage `_ * `libc++abi Homepage `_ * `LLVM Bugzilla `_ * `cfe-commits Mailing List`_ * `cfe-dev Mailing List`_ * `Browse libc++ -- SVN `_ * `Browse libc++ -- ViewVC `_ Index: vendor/libc++/dist/include/__config =================================================================== --- vendor/libc++/dist/include/__config (revision 317954) +++ vendor/libc++/dist/include/__config (revision 317955) @@ -1,1116 +1,1196 @@ // -*- 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 #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)) #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 1 # define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_BIG_ENDIAN 0 # define _LIBCPP_SHORT_WCHAR 1 // 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__) #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)) +#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_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_EXTERNAL) # if defined(__FreeBSD__) || \ defined(__Fuchsia__) || \ defined(__NetBSD__) || \ defined(__linux__) || \ defined(__APPLE__) || \ defined(__CloudABI__) || \ defined(__sun__) # 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 #endif // __cplusplus + +// 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_UNCAUGHT_EXCEPTIONS \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) +#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) +#define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ + __attribute__((availability(ios,strict,introduced=6.0))) +#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ + __attribute__((availability(macosx,strict,introduced=10.9))) \ + __attribute__((availability(ios,strict,introduced=7.0))) +#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ + __attribute__((availability(macosx,strict,introduced=10.9))) \ + __attribute__((availability(ios,strict,introduced=7.0))) +#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ + __attribute__((availability(macosx,strict,introduced=10.9))) \ + __attribute__((availability(ios,strict,introduced=7.0))) +#else +#define _LIBCPP_AVAILABILITY_SHARED_MUTEX +#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH +#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS +#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE +#define _LIBCPP_AVAILABILITY_FUTURE_ERROR +#define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE +#define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY +#define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR +#endif + +// Define availability that depends on _LIBCPP_NO_EXCEPTIONS. +#ifdef _LIBCPP_NO_EXCEPTIONS +#define _LIBCPP_AVAILABILITY_DYNARRAY +#define _LIBCPP_AVAILABILITY_FUTURE +#else +#define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH +#define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR +#endif + +// Availability of stream API in the dylib got dropped and re-added. The +// extern template should effectively be available at: +// availability(macosx,introduced=10.9) +// availability(ios,introduced=7.0) +#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \ + ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1090) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ + __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ <= 70000)) +#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE +#endif #endif // _LIBCPP_CONFIG Index: vendor/libc++/dist/include/__locale =================================================================== --- vendor/libc++/dist/include/__locale (revision 317954) +++ vendor/libc++/dist/include/__locale (revision 317955) @@ -1,1481 +1,1482 @@ // -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP___LOCALE #define _LIBCPP___LOCALE #include <__config> #include #include #include #include #include #include #include #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # include #elif defined(_AIX) # include #elif defined(__ANDROID__) // Android gained the locale aware functions in L (API level 21) # include # if __ANDROID_API__ <= 20 # include # endif #elif defined(__sun__) # include # include #elif defined(_NEWLIB_VERSION) # include #elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) # include #elif defined(__Fuchsia__) # include #elif defined(_LIBCPP_HAS_MUSL_LIBC) # include #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS locale; template _LIBCPP_INLINE_VISIBILITY bool has_facet(const locale&) _NOEXCEPT; template _LIBCPP_INLINE_VISIBILITY const _Facet& use_facet(const locale&); class _LIBCPP_TYPE_VIS locale { public: // types: class _LIBCPP_TYPE_VIS facet; class _LIBCPP_TYPE_VIS id; typedef int category; + _LIBCPP_AVAILABILITY_LOCALE_CATEGORY static const category // values assigned here are for exposition only none = 0, collate = LC_COLLATE_MASK, ctype = LC_CTYPE_MASK, monetary = LC_MONETARY_MASK, numeric = LC_NUMERIC_MASK, time = LC_TIME_MASK, messages = LC_MESSAGES_MASK, all = collate | ctype | monetary | numeric | time | messages; // construct/copy/destroy: locale() _NOEXCEPT; locale(const locale&) _NOEXCEPT; explicit locale(const char*); explicit locale(const string&); locale(const locale&, const char*, category); locale(const locale&, const string&, category); template _LIBCPP_INLINE_VISIBILITY locale(const locale&, _Facet*); locale(const locale&, const locale&, category); ~locale(); const locale& operator=(const locale&) _NOEXCEPT; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS locale combine(const locale&) const; // locale operations: string name() const; bool operator==(const locale&) const; bool operator!=(const locale& __y) const {return !(*this == __y);} template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool operator()(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&) const; // global locale objects: static locale global(const locale&); static const locale& classic(); private: class __imp; __imp* __locale_; void __install_ctor(const locale&, facet*, long); static locale& __global(); bool has_facet(id&) const; const facet* use_facet(id&) const; template friend bool has_facet(const locale&) _NOEXCEPT; template friend const _Facet& use_facet(const locale&); }; class _LIBCPP_TYPE_VIS locale::facet : public __shared_count { protected: _LIBCPP_INLINE_VISIBILITY explicit facet(size_t __refs = 0) : __shared_count(static_cast(__refs)-1) {} virtual ~facet(); // facet(const facet&) = delete; // effectively done in __shared_count // void operator=(const facet&) = delete; private: virtual void __on_zero_shared() _NOEXCEPT; }; class _LIBCPP_TYPE_VIS locale::id { once_flag __flag_; int32_t __id_; static int32_t __next_id; public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} private: void __init(); void operator=(const id&); // = delete; id(const id&); // = delete; public: // only needed for tests long __get(); friend class locale; friend class locale::__imp; }; template inline _LIBCPP_INLINE_VISIBILITY locale::locale(const locale& __other, _Facet* __f) { __install_ctor(__other, __f, __f ? __f->id.__get() : 0); } template locale locale::combine(const locale& __other) const { if (!_VSTD::has_facet<_Facet>(__other)) __throw_runtime_error("locale::combine: locale missing facet"); return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); } template inline _LIBCPP_INLINE_VISIBILITY bool has_facet(const locale& __l) _NOEXCEPT { return __l.has_facet(_Facet::id); } template inline _LIBCPP_INLINE_VISIBILITY const _Facet& use_facet(const locale& __l) { return static_cast(*__l.use_facet(_Facet::id)); } // template class collate; template class _LIBCPP_TEMPLATE_VIS collate : public locale::facet { public: typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_INLINE_VISIBILITY explicit collate(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_INLINE_VISIBILITY int compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const { return do_compare(__lo1, __hi1, __lo2, __hi2); } _LIBCPP_INLINE_VISIBILITY string_type transform(const char_type* __lo, const char_type* __hi) const { return do_transform(__lo, __hi); } _LIBCPP_INLINE_VISIBILITY long hash(const char_type* __lo, const char_type* __hi) const { return do_hash(__lo, __hi); } static locale::id id; protected: ~collate(); virtual int do_compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const; virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const {return string_type(__lo, __hi);} virtual long do_hash(const char_type* __lo, const char_type* __hi) const; }; template locale::id collate<_CharT>::id; template collate<_CharT>::~collate() { } template int collate<_CharT>::do_compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const { for (; __lo2 != __hi2; ++__lo1, ++__lo2) { if (__lo1 == __hi1 || *__lo1 < *__lo2) return -1; if (*__lo2 < *__lo1) return 1; } return __lo1 != __hi1; } template long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const { size_t __h = 0; const size_t __sr = __CHAR_BIT__ * sizeof(size_t) - 8; const size_t __mask = size_t(0xF) << (__sr + 4); for(const char_type* __p = __lo; __p != __hi; ++__p) { __h = (__h << 4) + static_cast(*__p); size_t __g = __h & __mask; __h ^= __g | (__g >> __sr); } return static_cast(__h); } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate) // template class collate_byname; template class _LIBCPP_TEMPLATE_VIS collate_byname; template <> class _LIBCPP_TYPE_VIS collate_byname : public collate { locale_t __l; public: typedef char char_type; typedef basic_string string_type; explicit collate_byname(const char* __n, size_t __refs = 0); explicit collate_byname(const string& __n, size_t __refs = 0); protected: ~collate_byname(); virtual int do_compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const; virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; }; template <> class _LIBCPP_TYPE_VIS collate_byname : public collate { locale_t __l; public: typedef wchar_t char_type; typedef basic_string string_type; explicit collate_byname(const char* __n, size_t __refs = 0); explicit collate_byname(const string& __n, size_t __refs = 0); protected: ~collate_byname(); virtual int do_compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const; virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; }; template bool locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y) const { return _VSTD::use_facet<_VSTD::collate<_CharT> >(*this).compare( __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0; } // template class ctype class _LIBCPP_TYPE_VIS ctype_base { public: #if defined(__GLIBC__) typedef unsigned short mask; static const mask space = _ISspace; static const mask print = _ISprint; static const mask cntrl = _IScntrl; static const mask upper = _ISupper; static const mask lower = _ISlower; static const mask alpha = _ISalpha; static const mask digit = _ISdigit; static const mask punct = _ISpunct; static const mask xdigit = _ISxdigit; static const mask blank = _ISblank; #elif defined(_LIBCPP_MSVCRT) typedef unsigned short mask; static const mask space = _SPACE; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; static const mask cntrl = _CONTROL; static const mask upper = _UPPER; static const mask lower = _LOWER; static const mask alpha = _ALPHA; static const mask digit = _DIGIT; static const mask punct = _PUNCT; static const mask xdigit = _HEX; static const mask blank = _BLANK; # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) # ifdef __APPLE__ typedef __uint32_t mask; # elif defined(__FreeBSD__) typedef unsigned long mask; # elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) typedef unsigned short mask; # endif static const mask space = _CTYPE_S; static const mask print = _CTYPE_R; static const mask cntrl = _CTYPE_C; static const mask upper = _CTYPE_U; static const mask lower = _CTYPE_L; static const mask alpha = _CTYPE_A; static const mask digit = _CTYPE_D; static const mask punct = _CTYPE_P; static const mask xdigit = _CTYPE_X; # if defined(__NetBSD__) static const mask blank = _CTYPE_BL; # else static const mask blank = _CTYPE_B; # endif #elif defined(__sun__) || defined(_AIX) typedef unsigned int mask; static const mask space = _ISSPACE; static const mask print = _ISPRINT; static const mask cntrl = _ISCNTRL; static const mask upper = _ISUPPER; static const mask lower = _ISLOWER; static const mask alpha = _ISALPHA; static const mask digit = _ISDIGIT; static const mask punct = _ISPUNCT; static const mask xdigit = _ISXDIGIT; static const mask blank = _ISBLANK; #elif defined(_NEWLIB_VERSION) // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. typedef char mask; static const mask space = _S; static const mask print = _P | _U | _L | _N | _B; static const mask cntrl = _C; static const mask upper = _U; static const mask lower = _L; static const mask alpha = _U | _L; static const mask digit = _N; static const mask punct = _P; static const mask xdigit = _X | _N; static const mask blank = _B; # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT #else typedef unsigned long mask; static const mask space = 1<<0; static const mask print = 1<<1; static const mask cntrl = 1<<2; static const mask upper = 1<<3; static const mask lower = 1<<4; static const mask alpha = 1<<5; static const mask digit = 1<<6; static const mask punct = 1<<7; static const mask xdigit = 1<<8; static const mask blank = 1<<9; #endif static const mask alnum = alpha | digit; static const mask graph = alnum | punct; _LIBCPP_ALWAYS_INLINE ctype_base() {} }; template class _LIBCPP_TEMPLATE_VIS ctype; template <> class _LIBCPP_TYPE_VIS ctype : public locale::facet, public ctype_base { public: typedef wchar_t char_type; _LIBCPP_ALWAYS_INLINE explicit ctype(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { return do_is(__m, __c); } _LIBCPP_ALWAYS_INLINE const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const { return do_is(__low, __high, __vec); } _LIBCPP_ALWAYS_INLINE const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const { return do_scan_is(__m, __low, __high); } _LIBCPP_ALWAYS_INLINE const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const { return do_scan_not(__m, __low, __high); } _LIBCPP_ALWAYS_INLINE char_type toupper(char_type __c) const { return do_toupper(__c); } _LIBCPP_ALWAYS_INLINE const char_type* toupper(char_type* __low, const char_type* __high) const { return do_toupper(__low, __high); } _LIBCPP_ALWAYS_INLINE char_type tolower(char_type __c) const { return do_tolower(__c); } _LIBCPP_ALWAYS_INLINE const char_type* tolower(char_type* __low, const char_type* __high) const { return do_tolower(__low, __high); } _LIBCPP_ALWAYS_INLINE char_type widen(char __c) const { return do_widen(__c); } _LIBCPP_ALWAYS_INLINE const char* widen(const char* __low, const char* __high, char_type* __to) const { return do_widen(__low, __high, __to); } _LIBCPP_ALWAYS_INLINE char narrow(char_type __c, char __dfault) const { return do_narrow(__c, __dfault); } _LIBCPP_ALWAYS_INLINE const char_type* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const { return do_narrow(__low, __high, __dfault, __to); } static locale::id id; protected: ~ctype(); virtual bool do_is(mask __m, char_type __c) const; virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; virtual char_type do_toupper(char_type) const; virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; virtual char_type do_tolower(char_type) const; virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; virtual char_type do_widen(char) const; virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; virtual char do_narrow(char_type, char __dfault) const; virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; }; template <> class _LIBCPP_TYPE_VIS ctype : public locale::facet, public ctype_base { const mask* __tab_; bool __del_; public: typedef char char_type; explicit ctype(const mask* __tab = 0, bool __del = false, size_t __refs = 0); _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { return isascii(__c) ? (__tab_[static_cast(__c)] & __m) !=0 : false; } _LIBCPP_ALWAYS_INLINE const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const { for (; __low != __high; ++__low, ++__vec) *__vec = isascii(*__low) ? __tab_[static_cast(*__low)] : 0; return __low; } _LIBCPP_ALWAYS_INLINE const char_type* scan_is (mask __m, const char_type* __low, const char_type* __high) const { for (; __low != __high; ++__low) if (isascii(*__low) && (__tab_[static_cast(*__low)] & __m)) break; return __low; } _LIBCPP_ALWAYS_INLINE const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const { for (; __low != __high; ++__low) if (!(isascii(*__low) && (__tab_[static_cast(*__low)] & __m))) break; return __low; } _LIBCPP_ALWAYS_INLINE char_type toupper(char_type __c) const { return do_toupper(__c); } _LIBCPP_ALWAYS_INLINE const char_type* toupper(char_type* __low, const char_type* __high) const { return do_toupper(__low, __high); } _LIBCPP_ALWAYS_INLINE char_type tolower(char_type __c) const { return do_tolower(__c); } _LIBCPP_ALWAYS_INLINE const char_type* tolower(char_type* __low, const char_type* __high) const { return do_tolower(__low, __high); } _LIBCPP_ALWAYS_INLINE char_type widen(char __c) const { return do_widen(__c); } _LIBCPP_ALWAYS_INLINE const char* widen(const char* __low, const char* __high, char_type* __to) const { return do_widen(__low, __high, __to); } _LIBCPP_ALWAYS_INLINE char narrow(char_type __c, char __dfault) const { return do_narrow(__c, __dfault); } _LIBCPP_ALWAYS_INLINE const char* narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const { return do_narrow(__low, __high, __dfault, __to); } static locale::id id; #ifdef _CACHED_RUNES static const size_t table_size = _CACHED_RUNES; #else static const size_t table_size = 256; // FIXME: Don't hardcode this. #endif _LIBCPP_ALWAYS_INLINE const mask* table() const _NOEXCEPT {return __tab_;} static const mask* classic_table() _NOEXCEPT; #if defined(__GLIBC__) || defined(__EMSCRIPTEN__) static const int* __classic_upper_table() _NOEXCEPT; static const int* __classic_lower_table() _NOEXCEPT; #endif #if defined(__NetBSD__) static const short* __classic_upper_table() _NOEXCEPT; static const short* __classic_lower_table() _NOEXCEPT; #endif protected: ~ctype(); virtual char_type do_toupper(char_type __c) const; virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; virtual char_type do_tolower(char_type __c) const; virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; virtual char_type do_widen(char __c) const; virtual const char* do_widen(const char* __low, const char* __high, char_type* __to) const; virtual char do_narrow(char_type __c, char __dfault) const; virtual const char* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const; }; // template class ctype_byname; template class _LIBCPP_TEMPLATE_VIS ctype_byname; template <> class _LIBCPP_TYPE_VIS ctype_byname : public ctype { locale_t __l; public: explicit ctype_byname(const char*, size_t = 0); explicit ctype_byname(const string&, size_t = 0); protected: ~ctype_byname(); virtual char_type do_toupper(char_type) const; virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; virtual char_type do_tolower(char_type) const; virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; }; template <> class _LIBCPP_TYPE_VIS ctype_byname : public ctype { locale_t __l; public: explicit ctype_byname(const char*, size_t = 0); explicit ctype_byname(const string&, size_t = 0); protected: ~ctype_byname(); virtual bool do_is(mask __m, char_type __c) const; virtual const char_type* do_is(const char_type* __low, const char_type* __high, mask* __vec) const; virtual const char_type* do_scan_is(mask __m, const char_type* __low, const char_type* __high) const; virtual const char_type* do_scan_not(mask __m, const char_type* __low, const char_type* __high) const; virtual char_type do_toupper(char_type) const; virtual const char_type* do_toupper(char_type* __low, const char_type* __high) const; virtual char_type do_tolower(char_type) const; virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; virtual char_type do_widen(char) const; virtual const char* do_widen(const char* __low, const char* __high, char_type* __dest) const; virtual char do_narrow(char_type, char __dfault) const; virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; }; template inline _LIBCPP_INLINE_VISIBILITY bool isspace(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::space, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isprint(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::print, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool iscntrl(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::cntrl, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isupper(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::upper, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool islower(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::lower, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isalpha(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::alpha, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isdigit(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::digit, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool ispunct(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::punct, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isxdigit(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::xdigit, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isalnum(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::alnum, __c); } template inline _LIBCPP_INLINE_VISIBILITY bool isgraph(_CharT __c, const locale& __loc) { return use_facet >(__loc).is(ctype_base::graph, __c); } template inline _LIBCPP_INLINE_VISIBILITY _CharT toupper(_CharT __c, const locale& __loc) { return use_facet >(__loc).toupper(__c); } template inline _LIBCPP_INLINE_VISIBILITY _CharT tolower(_CharT __c, const locale& __loc) { return use_facet >(__loc).tolower(__c); } // codecvt_base class _LIBCPP_TYPE_VIS codecvt_base { public: _LIBCPP_ALWAYS_INLINE codecvt_base() {} enum result {ok, partial, error, noconv}; }; // template class codecvt; template class _LIBCPP_TEMPLATE_VIS codecvt; // template <> class codecvt template <> class _LIBCPP_TYPE_VIS codecvt : public locale::facet, public codecvt_base { public: typedef char intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_ALWAYS_INLINE explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE result out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_unshift(__st, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const { return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE int encoding() const _NOEXCEPT { return do_encoding(); } _LIBCPP_ALWAYS_INLINE bool always_noconv() const _NOEXCEPT { return do_always_noconv(); } _LIBCPP_ALWAYS_INLINE int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const { return do_length(__st, __frm, __end, __mx); } _LIBCPP_ALWAYS_INLINE int max_length() const _NOEXCEPT { return do_max_length(); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE explicit codecvt(const char*, size_t __refs = 0) : locale::facet(__refs) {} ~codecvt(); virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual int do_encoding() const _NOEXCEPT; virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const; virtual int do_max_length() const _NOEXCEPT; }; // template <> class codecvt template <> class _LIBCPP_TYPE_VIS codecvt : public locale::facet, public codecvt_base { locale_t __l; public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; explicit codecvt(size_t __refs = 0); _LIBCPP_ALWAYS_INLINE result out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_unshift(__st, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const { return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE int encoding() const _NOEXCEPT { return do_encoding(); } _LIBCPP_ALWAYS_INLINE bool always_noconv() const _NOEXCEPT { return do_always_noconv(); } _LIBCPP_ALWAYS_INLINE int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const { return do_length(__st, __frm, __end, __mx); } _LIBCPP_ALWAYS_INLINE int max_length() const _NOEXCEPT { return do_max_length(); } static locale::id id; protected: explicit codecvt(const char*, size_t __refs = 0); ~codecvt(); virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual int do_encoding() const _NOEXCEPT; virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; virtual int do_max_length() const _NOEXCEPT; }; // template <> class codecvt template <> class _LIBCPP_TYPE_VIS codecvt : public locale::facet, public codecvt_base { public: typedef char16_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_ALWAYS_INLINE explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE result out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_unshift(__st, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const { return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE int encoding() const _NOEXCEPT { return do_encoding(); } _LIBCPP_ALWAYS_INLINE bool always_noconv() const _NOEXCEPT { return do_always_noconv(); } _LIBCPP_ALWAYS_INLINE int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const { return do_length(__st, __frm, __end, __mx); } _LIBCPP_ALWAYS_INLINE int max_length() const _NOEXCEPT { return do_max_length(); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE explicit codecvt(const char*, size_t __refs = 0) : locale::facet(__refs) {} ~codecvt(); virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual int do_encoding() const _NOEXCEPT; virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; virtual int do_max_length() const _NOEXCEPT; }; // template <> class codecvt template <> class _LIBCPP_TYPE_VIS codecvt : public locale::facet, public codecvt_base { public: typedef char32_t intern_type; typedef char extern_type; typedef mbstate_t state_type; _LIBCPP_ALWAYS_INLINE explicit codecvt(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE result out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const { return do_unshift(__st, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE result in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const { return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); } _LIBCPP_ALWAYS_INLINE int encoding() const _NOEXCEPT { return do_encoding(); } _LIBCPP_ALWAYS_INLINE bool always_noconv() const _NOEXCEPT { return do_always_noconv(); } _LIBCPP_ALWAYS_INLINE int length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const { return do_length(__st, __frm, __end, __mx); } _LIBCPP_ALWAYS_INLINE int max_length() const _NOEXCEPT { return do_max_length(); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE explicit codecvt(const char*, size_t __refs = 0) : locale::facet(__refs) {} ~codecvt(); virtual result do_out(state_type& __st, const intern_type* __frm, const intern_type* __frm_end, const intern_type*& __frm_nxt, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual result do_in(state_type& __st, const extern_type* __frm, const extern_type* __frm_end, const extern_type*& __frm_nxt, intern_type* __to, intern_type* __to_end, intern_type*& __to_nxt) const; virtual result do_unshift(state_type& __st, extern_type* __to, extern_type* __to_end, extern_type*& __to_nxt) const; virtual int do_encoding() const _NOEXCEPT; virtual bool do_always_noconv() const _NOEXCEPT; virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; virtual int do_max_length() const _NOEXCEPT; }; // template class codecvt_byname template class _LIBCPP_TEMPLATE_VIS codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { public: _LIBCPP_ALWAYS_INLINE explicit codecvt_byname(const char* __nm, size_t __refs = 0) : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {} _LIBCPP_ALWAYS_INLINE explicit codecvt_byname(const string& __nm, size_t __refs = 0) : codecvt<_InternT, _ExternT, _StateT>(__nm.c_str(), __refs) {} protected: ~codecvt_byname(); }; template codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() { } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname) _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); template struct __narrow_to_utf8 { template _OutputIterator operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const; }; template <> struct __narrow_to_utf8<8> { template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const { for (; __wb < __we; ++__wb, ++__s) *__s = *__wb; return __s; } }; template <> struct __narrow_to_utf8<16> : public codecvt { _LIBCPP_ALWAYS_INLINE __narrow_to_utf8() : codecvt(1) {} ~__narrow_to_utf8(); template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const { result __r = ok; mbstate_t __mb; while (__wb < __we && __r != error) { const int __sz = 32; char __buf[__sz]; char* __bn; const char16_t* __wn = (const char16_t*)__wb; __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf+__sz, __bn); if (__r == codecvt_base::error || __wn == (const char16_t*)__wb) __throw_runtime_error("locale not supported"); for (const char* __p = __buf; __p < __bn; ++__p, ++__s) *__s = *__p; __wb = (const _CharT*)__wn; } return __s; } }; template <> struct __narrow_to_utf8<32> : public codecvt { _LIBCPP_ALWAYS_INLINE __narrow_to_utf8() : codecvt(1) {} ~__narrow_to_utf8(); template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const _CharT* __wb, const _CharT* __we) const { result __r = ok; mbstate_t __mb; while (__wb < __we && __r != error) { const int __sz = 32; char __buf[__sz]; char* __bn; const char32_t* __wn = (const char32_t*)__wb; __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf+__sz, __bn); if (__r == codecvt_base::error || __wn == (const char32_t*)__wb) __throw_runtime_error("locale not supported"); for (const char* __p = __buf; __p < __bn; ++__p, ++__s) *__s = *__p; __wb = (const _CharT*)__wn; } return __s; } }; template struct __widen_from_utf8 { template _OutputIterator operator()(_OutputIterator __s, const char* __nb, const char* __ne) const; }; template <> struct __widen_from_utf8<8> { template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const char* __nb, const char* __ne) const { for (; __nb < __ne; ++__nb, ++__s) *__s = *__nb; return __s; } }; template <> struct __widen_from_utf8<16> : public codecvt { _LIBCPP_ALWAYS_INLINE __widen_from_utf8() : codecvt(1) {} ~__widen_from_utf8(); template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const char* __nb, const char* __ne) const { result __r = ok; mbstate_t __mb; while (__nb < __ne && __r != error) { const int __sz = 32; char16_t __buf[__sz]; char16_t* __bn; const char* __nn = __nb; __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, __buf, __buf+__sz, __bn); if (__r == codecvt_base::error || __nn == __nb) __throw_runtime_error("locale not supported"); for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s) *__s = (wchar_t)*__p; __nb = __nn; } return __s; } }; template <> struct __widen_from_utf8<32> : public codecvt { _LIBCPP_ALWAYS_INLINE __widen_from_utf8() : codecvt(1) {} ~__widen_from_utf8(); template _LIBCPP_ALWAYS_INLINE _OutputIterator operator()(_OutputIterator __s, const char* __nb, const char* __ne) const { result __r = ok; mbstate_t __mb; while (__nb < __ne && __r != error) { const int __sz = 32; char32_t __buf[__sz]; char32_t* __bn; const char* __nn = __nb; __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb+__sz : __ne, __nn, __buf, __buf+__sz, __bn); if (__r == codecvt_base::error || __nn == __nb) __throw_runtime_error("locale not supported"); for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s) *__s = (wchar_t)*__p; __nb = __nn; } return __s; } }; // template class numpunct template class _LIBCPP_TEMPLATE_VIS numpunct; template <> class _LIBCPP_TYPE_VIS numpunct : public locale::facet { public: typedef char char_type; typedef basic_string string_type; explicit numpunct(size_t __refs = 0); _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();} _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();} _LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();} _LIBCPP_ALWAYS_INLINE string_type truename() const {return do_truename();} _LIBCPP_ALWAYS_INLINE string_type falsename() const {return do_falsename();} static locale::id id; protected: ~numpunct(); virtual char_type do_decimal_point() const; virtual char_type do_thousands_sep() const; virtual string do_grouping() const; virtual string_type do_truename() const; virtual string_type do_falsename() const; char_type __decimal_point_; char_type __thousands_sep_; string __grouping_; }; template <> class _LIBCPP_TYPE_VIS numpunct : public locale::facet { public: typedef wchar_t char_type; typedef basic_string string_type; explicit numpunct(size_t __refs = 0); _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();} _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();} _LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();} _LIBCPP_ALWAYS_INLINE string_type truename() const {return do_truename();} _LIBCPP_ALWAYS_INLINE string_type falsename() const {return do_falsename();} static locale::id id; protected: ~numpunct(); virtual char_type do_decimal_point() const; virtual char_type do_thousands_sep() const; virtual string do_grouping() const; virtual string_type do_truename() const; virtual string_type do_falsename() const; char_type __decimal_point_; char_type __thousands_sep_; string __grouping_; }; // template class numpunct_byname template class _LIBCPP_TEMPLATE_VIS numpunct_byname; template <> class _LIBCPP_TYPE_VIS numpunct_byname : public numpunct { public: typedef char char_type; typedef basic_string string_type; explicit numpunct_byname(const char* __nm, size_t __refs = 0); explicit numpunct_byname(const string& __nm, size_t __refs = 0); protected: ~numpunct_byname(); private: void __init(const char*); }; template <> class _LIBCPP_TYPE_VIS numpunct_byname : public numpunct { public: typedef wchar_t char_type; typedef basic_string string_type; explicit numpunct_byname(const char* __nm, size_t __refs = 0); explicit numpunct_byname(const string& __nm, size_t __refs = 0); protected: ~numpunct_byname(); private: void __init(const char*); }; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___LOCALE Index: vendor/libc++/dist/include/__threading_support =================================================================== --- vendor/libc++/dist/include/__threading_support (revision 317954) +++ vendor/libc++/dist/include/__threading_support (revision 317955) @@ -1,630 +1,633 @@ // -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_THREADING_SUPPORT #define _LIBCPP_THREADING_SUPPORT #include <__config> #include #include #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) # include <__external_threading> #elif !defined(_LIBCPP_HAS_NO_THREADS) #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # include # include #elif defined(_LIBCPP_HAS_THREAD_API_WIN32) #include #include #include #endif #if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS #else #define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY #endif #if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis) #define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis)) #else #define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS #endif _LIBCPP_BEGIN_NAMESPACE_STD #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) // Mutex typedef pthread_mutex_t __libcpp_mutex_t; #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER typedef pthread_mutex_t __libcpp_recursive_mutex_t; // Condition Variable typedef pthread_cond_t __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER // Execute once typedef pthread_once_t __libcpp_exec_once_flag; #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT // Thread id typedef pthread_t __libcpp_thread_id; // Thread #define _LIBCPP_NULL_THREAD 0U typedef pthread_t __libcpp_thread_t; // Thrad Local Storage typedef pthread_key_t __libcpp_tls_key; #define _LIBCPP_TLS_DESTRUCTOR_CC #else // Mutex typedef SRWLOCK __libcpp_mutex_t; #define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT typedef CRITICAL_SECTION __libcpp_recursive_mutex_t; // Condition Variable typedef CONDITION_VARIABLE __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT // Execute Once typedef INIT_ONCE __libcpp_exec_once_flag; #define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT // Thread ID typedef DWORD __libcpp_thread_id; // Thread #define _LIBCPP_NULL_THREAD 0U typedef HANDLE __libcpp_thread_t; // Thread Local Storage typedef DWORD __libcpp_tls_key; #define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI #endif // Mutex _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t *__m); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_mutex_destroy(__libcpp_mutex_t *__m); // Condition variable _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m); _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); // Execute once _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_execute_once(__libcpp_exec_once_flag *flag, void (*init_routine)(void)); // Thread id _LIBCPP_THREAD_ABI_VISIBILITY bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); _LIBCPP_THREAD_ABI_VISIBILITY bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); // Thread _LIBCPP_THREAD_ABI_VISIBILITY bool __libcpp_thread_isnull(const __libcpp_thread_t *__t); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), void *__arg); _LIBCPP_THREAD_ABI_VISIBILITY __libcpp_thread_id __libcpp_thread_get_current_id(); _LIBCPP_THREAD_ABI_VISIBILITY __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_thread_join(__libcpp_thread_t *__t); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_thread_detach(__libcpp_thread_t *__t); _LIBCPP_THREAD_ABI_VISIBILITY void __libcpp_thread_yield(); _LIBCPP_THREAD_ABI_VISIBILITY void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns); // Thread local storage _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)); _LIBCPP_THREAD_ABI_VISIBILITY void *__libcpp_tls_get(__libcpp_tls_key __key); _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); #if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL) #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) { pthread_mutexattr_t attr; int __ec = pthread_mutexattr_init(&attr); if (__ec) return __ec; __ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); if (__ec) { pthread_mutexattr_destroy(&attr); return __ec; } __ec = pthread_mutex_init(__m, &attr); if (__ec) { pthread_mutexattr_destroy(&attr); return __ec; } __ec = pthread_mutexattr_destroy(&attr); if (__ec) { pthread_mutex_destroy(__m); return __ec; } return 0; } int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m) { return pthread_mutex_lock(__m); } bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m) { return pthread_mutex_trylock(__m) == 0; } int __libcpp_recursive_mutex_unlock(__libcpp_mutex_t *__m) { return pthread_mutex_unlock(__m); } int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m) { return pthread_mutex_destroy(__m); } int __libcpp_mutex_lock(__libcpp_mutex_t *__m) { return pthread_mutex_lock(__m); } bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m) { return pthread_mutex_trylock(__m) == 0; } int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) { return pthread_mutex_unlock(__m); } int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) { return pthread_mutex_destroy(__m); } // Condition Variable int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) { return pthread_cond_signal(__cv); } int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) { return pthread_cond_broadcast(__cv); } int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) { return pthread_cond_wait(__cv, __m); } int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts) { return pthread_cond_timedwait(__cv, __m, __ts); } int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) { return pthread_cond_destroy(__cv); } // Execute once int __libcpp_execute_once(__libcpp_exec_once_flag *flag, void (*init_routine)(void)) { return pthread_once(flag, init_routine); } // Thread id // Returns non-zero if the thread ids are equal, otherwise 0 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) { return pthread_equal(t1, t2) != 0; } // Returns non-zero if t1 < t2, otherwise 0 bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) { return t1 < t2; } // Thread bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) { return *__t == 0; } int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), void *__arg) { return pthread_create(__t, 0, __func, __arg); } __libcpp_thread_id __libcpp_thread_get_current_id() { return pthread_self(); } __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) { return *__t; } int __libcpp_thread_join(__libcpp_thread_t *__t) { return pthread_join(*__t, 0); } int __libcpp_thread_detach(__libcpp_thread_t *__t) { return pthread_detach(*__t); } void __libcpp_thread_yield() { sched_yield(); } void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { using namespace chrono; seconds __s = duration_cast(__ns); timespec __ts; typedef decltype(__ts.tv_sec) ts_sec; _LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits::max(); if (__s.count() < __ts_sec_max) { __ts.tv_sec = static_cast(__s.count()); __ts.tv_nsec = static_cast((__ns - __s).count()); } else { __ts.tv_sec = __ts_sec_max; __ts.tv_nsec = 999999999; // (10^9 - 1) } while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR); } // Thread local storage int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *)) { return pthread_key_create(__key, __at_exit); } void *__libcpp_tls_get(__libcpp_tls_key __key) { return pthread_getspecific(__key); } int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) { return pthread_setspecific(__key, __p); } #elif defined(_LIBCPP_HAS_THREAD_API_WIN32) // Mutex int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) { InitializeCriticalSection(__m); return 0; } int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m) { EnterCriticalSection(__m); return 0; } bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m) { return TryEnterCriticalSection(__m) != 0; } int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m) { LeaveCriticalSection(__m); return 0; } int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m) { DeleteCriticalSection(__m); return 0; } int __libcpp_mutex_lock(__libcpp_mutex_t *__m) { AcquireSRWLockExclusive(__m); return 0; } bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m) { return TryAcquireSRWLockExclusive(__m) != 0; } int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) { ReleaseSRWLockExclusive(__m); return 0; } int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) { static_cast(__m); return 0; } // Condition Variable int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) { WakeConditionVariable(__cv); return 0; } int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) { WakeAllConditionVariable(__cv); return 0; } int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) { SleepConditionVariableSRW(__cv, __m, INFINITE, 0); return 0; } int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, timespec *__ts) { using namespace _VSTD::chrono; auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec); auto abstime = system_clock::time_point(duration_cast(duration)); auto timeout_ms = duration_cast(abstime - system_clock::now()); if (!SleepConditionVariableSRW(__cv, __m, timeout_ms.count() > 0 ? timeout_ms.count() : 0, 0)) - return GetLastError(); + { + auto __ec = GetLastError(); + return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec; + } return 0; } int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) { static_cast(__cv); return 0; } // Execute Once static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter, PVOID *__context) { static_cast(__init_once); static_cast(__context); void (*init_routine)(void) = reinterpret_cast(__parameter); init_routine(); return TRUE; } int __libcpp_execute_once(__libcpp_exec_once_flag *__flag, void (*__init_routine)(void)) { if (!InitOnceExecuteOnce(__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast(__init_routine), NULL)) return GetLastError(); return 0; } // Thread ID bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs) { return __lhs == __rhs; } bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs) { return __lhs < __rhs; } // Thread struct __libcpp_beginthreadex_thunk_data { void *(*__func)(void *); void *__arg; }; static inline _LIBCPP_ALWAYS_INLINE unsigned WINAPI __libcpp_beginthreadex_thunk(void *__raw_data) { auto *__data = static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data); auto *__func = __data->__func; void *__arg = __data->__arg; delete __data; return static_cast(reinterpret_cast(__func(__arg))); } bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) { return *__t == 0; } int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *), void *__arg) { auto *__data = new __libcpp_beginthreadex_thunk_data; __data->__func = __func; __data->__arg = __arg; *__t = reinterpret_cast(_beginthreadex(nullptr, 0, __libcpp_beginthreadex_thunk, __data, 0, nullptr)); if (*__t) return 0; return GetLastError(); } __libcpp_thread_id __libcpp_thread_get_current_id() { return GetCurrentThreadId(); } __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) { return GetThreadId(*__t); } int __libcpp_thread_join(__libcpp_thread_t *__t) { if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED) return GetLastError(); if (!CloseHandle(*__t)) return GetLastError(); return 0; } int __libcpp_thread_detach(__libcpp_thread_t *__t) { if (!CloseHandle(*__t)) return GetLastError(); return 0; } void __libcpp_thread_yield() { SwitchToThread(); } void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) { using namespace chrono; // round-up to the nearest milisecond milliseconds __ms = duration_cast(__ns + chrono::nanoseconds(999999)); // FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx) Sleep(__ms.count()); } // Thread Local Storage int __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)) { *__key = FlsAlloc(__at_exit); if (*__key == FLS_OUT_OF_INDEXES) return GetLastError(); return 0; } void *__libcpp_tls_get(__libcpp_tls_key __key) { return FlsGetValue(__key); } int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) { if (!FlsSetValue(__key, __p)) return GetLastError(); return 0; } #endif // _LIBCPP_HAS_THREAD_API_PTHREAD #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS #endif // _LIBCPP_THREADING_SUPPORT Index: vendor/libc++/dist/include/exception =================================================================== --- vendor/libc++/dist/include/exception (revision 317954) +++ vendor/libc++/dist/include/exception (revision 317955) @@ -1,286 +1,337 @@ // -*- C++ -*- //===-------------------------- exception ---------------------------------===// // // 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_EXCEPTION #define _LIBCPP_EXCEPTION /* exception synopsis namespace std { class exception { public: exception() noexcept; exception(const exception&) noexcept; exception& operator=(const exception&) noexcept; virtual ~exception() noexcept; virtual const char* what() const noexcept; }; class bad_exception : public exception { public: bad_exception() noexcept; bad_exception(const bad_exception&) noexcept; bad_exception& operator=(const bad_exception&) noexcept; virtual ~bad_exception() noexcept; virtual const char* what() const noexcept; }; typedef void (*unexpected_handler)(); unexpected_handler set_unexpected(unexpected_handler f ) noexcept; unexpected_handler get_unexpected() noexcept; [[noreturn]] void unexpected(); typedef void (*terminate_handler)(); terminate_handler set_terminate(terminate_handler f ) noexcept; terminate_handler get_terminate() noexcept; [[noreturn]] void terminate() noexcept; bool uncaught_exception() noexcept; int uncaught_exceptions() noexcept; // C++17 typedef unspecified exception_ptr; exception_ptr current_exception() noexcept; void rethrow_exception [[noreturn]] (exception_ptr p); template exception_ptr make_exception_ptr(E e) noexcept; class nested_exception { public: nested_exception() noexcept; nested_exception(const nested_exception&) noexcept = default; nested_exception& operator=(const nested_exception&) noexcept = default; virtual ~nested_exception() = default; // access functions [[noreturn]] void rethrow_nested() const; exception_ptr nested_ptr() const noexcept; }; template [[noreturn]] void throw_with_nested(T&& t); template void rethrow_if_nested(const E& e); } // std */ #include <__config> #include #include #include #if defined(_LIBCPP_ABI_MICROSOFT) #include #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif namespace std // purposefully not using versioning namespace { #if !defined(_LIBCPP_ABI_MICROSOFT) class _LIBCPP_EXCEPTION_ABI exception { public: _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {} virtual ~exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; class _LIBCPP_EXCEPTION_ABI bad_exception : public exception { public: _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {} virtual ~bad_exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; }; #endif // !_LIBCPP_ABI_MICROSOFT #if _LIBCPP_STD_VER <= 14 \ || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \ || defined(_LIBCPP_BUILDING_LIBRARY) typedef void (*unexpected_handler)(); _LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; _LIBCPP_FUNC_VIS unexpected_handler get_unexpected() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void unexpected(); #endif typedef void (*terminate_handler)(); _LIBCPP_FUNC_VIS terminate_handler set_terminate(terminate_handler) _NOEXCEPT; _LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT; _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT; -_LIBCPP_FUNC_VIS int uncaught_exceptions() _NOEXCEPT; +_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS int uncaught_exceptions() _NOEXCEPT; class _LIBCPP_TYPE_VIS exception_ptr; _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); +#ifndef _LIBCPP_ABI_MICROSOFT + class _LIBCPP_TYPE_VIS exception_ptr { void* __ptr_; public: _LIBCPP_INLINE_VISIBILITY exception_ptr() _NOEXCEPT : __ptr_() {} _LIBCPP_INLINE_VISIBILITY exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} + exception_ptr(const exception_ptr&) _NOEXCEPT; exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; ~exception_ptr() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_EXPLICIT - operator bool() const _NOEXCEPT {return __ptr_ != nullptr;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT + {return __ptr_ != nullptr;} friend _LIBCPP_INLINE_VISIBILITY bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return __x.__ptr_ == __y.__ptr_;} + friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return !(__x == __y);} friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); }; template exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { #ifndef _LIBCPP_NO_EXCEPTIONS try { throw __e; } catch (...) { return current_exception(); } #else ((void)__e); _VSTD::abort(); #endif } +#else // _LIBCPP_ABI_MICROSOFT + +class _LIBCPP_TYPE_VIS exception_ptr +{ +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-private-field" +#endif + void* __ptr1_; + void* __ptr2_; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif +public: + exception_ptr() _NOEXCEPT; + exception_ptr(nullptr_t) _NOEXCEPT; + exception_ptr(const exception_ptr& __other) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT; + exception_ptr& operator=(nullptr_t) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; + _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT; +}; + +_LIBCPP_FUNC_VIS +bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT; + +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT + {return !(__x == __y);} + +_LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT; + +_LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr); +_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; +_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p); + +// This is a built-in template function which automagically extracts the required +// information. +template void *__GetExceptionInfo(_E); + +template +exception_ptr +make_exception_ptr(_Ep __e) _NOEXCEPT +{ + return __copy_exception_ptr(_VSTD::addressof(__e), __GetExceptionInfo(__e)); +} + +#endif // _LIBCPP_ABI_MICROSOFT // nested_exception class _LIBCPP_EXCEPTION_ABI nested_exception { exception_ptr __ptr_; public: nested_exception() _NOEXCEPT; // nested_exception(const nested_exception&) noexcept = default; // nested_exception& operator=(const nested_exception&) noexcept = default; virtual ~nested_exception() _NOEXCEPT; // access functions _LIBCPP_NORETURN void rethrow_nested() const; _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const _NOEXCEPT {return __ptr_;} }; template struct __nested : public _Tp, public nested_exception { _LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {} }; #ifndef _LIBCPP_NO_EXCEPTIONS template struct __throw_with_nested; template struct __throw_with_nested<_Tp, _Up, true> { _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void #ifndef _LIBCPP_CXX03_LANG __do_throw(_Tp&& __t) #else __do_throw (_Tp& __t) #endif // _LIBCPP_CXX03_LANG { throw __nested<_Up>(_VSTD::forward<_Tp>(__t)); } }; template struct __throw_with_nested<_Tp, _Up, false> { _LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void #ifndef _LIBCPP_CXX03_LANG __do_throw(_Tp&& __t) #else __do_throw (_Tp& __t) #endif // _LIBCPP_CXX03_LANG { throw _VSTD::forward<_Tp>(__t); } }; #endif template _LIBCPP_NORETURN void #ifndef _LIBCPP_CXX03_LANG throw_with_nested(_Tp&& __t) #else throw_with_nested (_Tp& __t) #endif // _LIBCPP_CXX03_LANG { #ifndef _LIBCPP_NO_EXCEPTIONS typedef typename decay<_Tp>::type _Up; static_assert( is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible"); __throw_with_nested<_Tp, _Up, is_class<_Up>::value && !is_base_of::value && !__libcpp_is_final<_Up>::value>:: __do_throw(_VSTD::forward<_Tp>(__t)); #else ((void)__t); // FIXME: Make this abort #endif } template struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT( is_polymorphic<_From>::value && (!is_base_of<_To, _From>::value || is_convertible::value)) {}; template inline _LIBCPP_INLINE_VISIBILITY void rethrow_if_nested(const _Ep& __e, typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) { const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) __nep->rethrow_nested(); } template inline _LIBCPP_INLINE_VISIBILITY void rethrow_if_nested(const _Ep&, typename enable_if::value>::type* = 0) { } } // std #endif // _LIBCPP_EXCEPTION Index: vendor/libc++/dist/include/experimental/dynarray =================================================================== --- vendor/libc++/dist/include/experimental/dynarray (revision 317954) +++ vendor/libc++/dist/include/experimental/dynarray (revision 317955) @@ -1,299 +1,299 @@ // -*- C++ -*- //===-------------------------- dynarray ----------------------------------===// // // 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_DYNARRAY #define _LIBCPP_DYNARRAY /* dynarray synopsis namespace std { namespace experimental { template< typename T > class dynarray { // types: typedef T value_type; typedef T& reference; typedef const T& const_reference; typedef T* pointer; typedef const T* const_pointer; typedef implementation-defined iterator; typedef implementation-defined const_iterator; typedef reverse_iterator reverse_iterator; typedef reverse_iterator const_reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; public: // construct/copy/destroy: explicit dynarray(size_type c); dynarray(size_type c, const T& v); dynarray(const dynarray& d); dynarray(initializer_list); template dynarray(allocator_arg_t, const Alloc& a, size_type c, const Alloc& alloc); template dynarray(allocator_arg_t, const Alloc& a, size_type c, const T& v, const Alloc& alloc); template dynarray(allocator_arg_t, const Alloc& a, const dynarray& d, const Alloc& alloc); template dynarray(allocator_arg_t, const Alloc& a, initializer_list, const Alloc& alloc); dynarray& operator=(const dynarray&) = delete; ~dynarray(); // iterators: iterator begin() noexcept; const_iterator begin() const noexcept; const_iterator cbegin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; const_iterator cend() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; const_reverse_iterator crbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_reverse_iterator crend() const noexcept; // capacity: size_type size() const noexcept; size_type max_size() const noexcept; bool empty() const noexcept; // element access: reference operator[](size_type n); const_reference operator[](size_type n) const; reference front(); const_reference front() const; reference back(); const_reference back() const; const_reference at(size_type n) const; reference at(size_type n); // data access: T* data() noexcept; const T* data() const noexcept; // mutating member functions: void fill(const T& v); }; }} // std::experimental */ #include <__config> #if _LIBCPP_STD_VER > 11 #include <__functional_base> #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif namespace std { namespace experimental { inline namespace __array_extensions_v1 { template -struct _LIBCPP_TEMPLATE_VIS dynarray +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_DYNARRAY dynarray { public: // types: typedef dynarray __self; typedef _Tp value_type; typedef value_type& reference; typedef const value_type& const_reference; typedef value_type* iterator; typedef const value_type* const_iterator; typedef value_type* pointer; typedef const value_type* const_pointer; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; private: size_t __size_; value_type * __base_; _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {} static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) { if ( numeric_limits::max() / sizeof (value_type) <= count ) __throw_bad_array_length(); return static_cast (_VSTD::__allocate (sizeof(value_type) * count)); } static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept { _VSTD::__libcpp_deallocate (static_cast (__ptr)); } public: _LIBCPP_INLINE_VISIBILITY explicit dynarray(size_type __c); _LIBCPP_INLINE_VISIBILITY dynarray(size_type __c, const value_type& __v); _LIBCPP_INLINE_VISIBILITY dynarray(const dynarray& __d); _LIBCPP_INLINE_VISIBILITY dynarray(initializer_list); // We're not implementing these right now. // Updated with the resolution of LWG issue #2255 // template // dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c); // template // dynarray(allocator_arg_t, const _Alloc& __alloc, size_type __c, const value_type& __v); // template // dynarray(allocator_arg_t, const _Alloc& __alloc, const dynarray& __d); // template // dynarray(allocator_arg_t, const _Alloc& __alloc, initializer_list); dynarray& operator=(const dynarray&) = delete; _LIBCPP_INLINE_VISIBILITY ~dynarray(); // iterators: inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); } inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); } inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); } inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); } inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); } inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); } inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); } inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } // capacity: inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; } inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; } inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; } // element access: inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; } inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; } inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; } inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; } inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; } inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; } inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const; inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n); // data access: inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; } inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; } // mutating member functions: inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); } }; template inline dynarray<_Tp>::dynarray(size_type __c) : dynarray () { __base_ = __allocate (__c); value_type *__data = data (); for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) ::new (__data) value_type; } template inline dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () { __base_ = __allocate (__c); value_type *__data = data (); for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) ::new (__data) value_type (__v); } template inline dynarray<_Tp>::dynarray(initializer_list __il) : dynarray () { size_t sz = __il.size(); __base_ = __allocate (sz); value_type *__data = data (); auto src = __il.begin(); for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) ::new (__data) value_type (*src); } template inline dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () { size_t sz = __d.size(); __base_ = __allocate (sz); value_type *__data = data (); auto src = __d.begin(); for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) ::new (__data) value_type (*src); } template inline dynarray<_Tp>::~dynarray() { value_type *__data = data () + __size_; for ( size_t i = 0; i < __size_; ++i ) (--__data)->value_type::~value_type(); __deallocate_value( __base_ ); } template inline _LIBCPP_INLINE_VISIBILITY typename dynarray<_Tp>::reference dynarray<_Tp>::at(size_type __n) { if (__n >= __size_) __throw_out_of_range("dynarray::at"); return data()[__n]; } template inline _LIBCPP_INLINE_VISIBILITY typename dynarray<_Tp>::const_reference dynarray<_Tp>::at(size_type __n) const { if (__n >= __size_) __throw_out_of_range("dynarray::at"); return data()[__n]; } }}} _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : true_type {}; _LIBCPP_END_NAMESPACE_STD #endif // if _LIBCPP_STD_VER > 11 #endif // _LIBCPP_DYNARRAY Index: vendor/libc++/dist/include/experimental/optional =================================================================== --- vendor/libc++/dist/include/experimental/optional (revision 317954) +++ vendor/libc++/dist/include/experimental/optional (revision 317955) @@ -1,913 +1,916 @@ // -*- C++ -*- //===-------------------------- optional ----------------------------------===// // // 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_EXPERIMENTAL_OPTIONAL #define _LIBCPP_EXPERIMENTAL_OPTIONAL /* optional synopsis // C++1y namespace std { namespace experimental { inline namespace fundamentals_v1 { // 5.3, optional for object types template class optional; // 5.4, In-place construction struct in_place_t{}; constexpr in_place_t in_place{}; // 5.5, No-value state indicator struct nullopt_t{see below}; constexpr nullopt_t nullopt(unspecified); // 5.6, Class bad_optional_access class bad_optional_access; // 5.7, Relational operators template constexpr bool operator==(const optional&, const optional&); template constexpr bool operator!=(const optional&, const optional&); template constexpr bool operator<(const optional&, const optional&); template constexpr bool operator>(const optional&, const optional&); template constexpr bool operator<=(const optional&, const optional&); template constexpr bool operator>=(const optional&, const optional&); // 5.8, Comparison with nullopt template constexpr bool operator==(const optional&, nullopt_t) noexcept; template constexpr bool operator==(nullopt_t, const optional&) noexcept; template constexpr bool operator!=(const optional&, nullopt_t) noexcept; template constexpr bool operator!=(nullopt_t, const optional&) noexcept; template constexpr bool operator<(const optional&, nullopt_t) noexcept; template constexpr bool operator<(nullopt_t, const optional&) noexcept; template constexpr bool operator<=(const optional&, nullopt_t) noexcept; template constexpr bool operator<=(nullopt_t, const optional&) noexcept; template constexpr bool operator>(const optional&, nullopt_t) noexcept; template constexpr bool operator>(nullopt_t, const optional&) noexcept; template constexpr bool operator>=(const optional&, nullopt_t) noexcept; template constexpr bool operator>=(nullopt_t, const optional&) noexcept; // 5.9, Comparison with T template constexpr bool operator==(const optional&, const T&); template constexpr bool operator==(const T&, const optional&); template constexpr bool operator!=(const optional&, const T&); template constexpr bool operator!=(const T&, const optional&); template constexpr bool operator<(const optional&, const T&); template constexpr bool operator<(const T&, const optional&); template constexpr bool operator<=(const optional&, const T&); template constexpr bool operator<=(const T&, const optional&); template constexpr bool operator>(const optional&, const T&); template constexpr bool operator>(const T&, const optional&); template constexpr bool operator>=(const optional&, const T&); template constexpr bool operator>=(const T&, const optional&); // 5.10, Specialized algorithms template void swap(optional&, optional&) noexcept(see below); template constexpr optional make_optional(T&&); template class optional { public: typedef T value_type; // 5.3.1, Constructors constexpr optional() noexcept; constexpr optional(nullopt_t) noexcept; optional(const optional&); optional(optional&&) noexcept(see below); constexpr optional(const T&); constexpr optional(T&&); template constexpr explicit optional(in_place_t, Args&&...); template constexpr explicit optional(in_place_t, initializer_list, Args&&...); // 5.3.2, Destructor ~optional(); // 5.3.3, Assignment optional& operator=(nullopt_t) noexcept; optional& operator=(const optional&); optional& operator=(optional&&) noexcept(see below); template optional& operator=(U&&); template void emplace(Args&&...); template void emplace(initializer_list, Args&&...); // 5.3.4, Swap void swap(optional&) noexcept(see below); // 5.3.5, Observers constexpr T const* operator ->() const; constexpr T* operator ->(); constexpr T const& operator *() const &; constexpr T& operator *() &; constexpr T&& operator *() &&; constexpr const T&& operator *() const &&; constexpr explicit operator bool() const noexcept; constexpr T const& value() const &; constexpr T& value() &; constexpr T&& value() &&; constexpr const T&& value() const &&; template constexpr T value_or(U&&) const &; template constexpr T value_or(U&&) &&; private: T* val; // exposition only }; } // namespace fundamentals_v1 } // namespace experimental // 5.11, Hash support template struct hash; template struct hash>; } // namespace std */ #include #include #include _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL -class _LIBCPP_EXCEPTION_ABI bad_optional_access +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error { public: bad_optional_access() : std::logic_error("Bad optional Access") {} // Get the key function ~bad_optional_access() into the dylib virtual ~bad_optional_access() _NOEXCEPT; }; _LIBCPP_END_NAMESPACE_EXPERIMENTAL #if _LIBCPP_STD_VER > 11 #include #include #include #include <__functional_base> #include <__undef_min_max> #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_LFTS struct in_place_t {}; constexpr in_place_t in_place{}; struct nullopt_t { explicit constexpr nullopt_t(int) noexcept {} }; constexpr nullopt_t nullopt{0}; template ::value> class __optional_storage { protected: typedef _Tp value_type; union { char __null_state_; value_type __val_; }; bool __engaged_ = false; _LIBCPP_INLINE_VISIBILITY ~__optional_storage() { if (__engaged_) __val_.~value_type(); } _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage() noexcept : __null_state_('\0') {} _LIBCPP_INLINE_VISIBILITY __optional_storage(const __optional_storage& __x) : __engaged_(__x.__engaged_) { if (__engaged_) ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_); } _LIBCPP_INLINE_VISIBILITY __optional_storage(__optional_storage&& __x) noexcept(is_nothrow_move_constructible::value) : __engaged_(__x.__engaged_) { if (__engaged_) ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); } _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage(const value_type& __v) : __val_(__v), __engaged_(true) {} _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage(value_type&& __v) : __val_(_VSTD::move(__v)), __engaged_(true) {} template _LIBCPP_INLINE_VISIBILITY constexpr explicit __optional_storage(in_place_t, _Args&&... __args) : __val_(_VSTD::forward<_Args>(__args)...), __engaged_(true) {} }; template class __optional_storage<_Tp, true> { protected: typedef _Tp value_type; union { char __null_state_; value_type __val_; }; bool __engaged_ = false; _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage() noexcept : __null_state_('\0') {} _LIBCPP_INLINE_VISIBILITY __optional_storage(const __optional_storage& __x) : __engaged_(__x.__engaged_) { if (__engaged_) ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_); } _LIBCPP_INLINE_VISIBILITY __optional_storage(__optional_storage&& __x) noexcept(is_nothrow_move_constructible::value) : __engaged_(__x.__engaged_) { if (__engaged_) ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); } _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage(const value_type& __v) : __val_(__v), __engaged_(true) {} _LIBCPP_INLINE_VISIBILITY constexpr __optional_storage(value_type&& __v) : __val_(_VSTD::move(__v)), __engaged_(true) {} template _LIBCPP_INLINE_VISIBILITY constexpr explicit __optional_storage(in_place_t, _Args&&... __args) : __val_(_VSTD::forward<_Args>(__args)...), __engaged_(true) {} }; template class optional : private __optional_storage<_Tp> { typedef __optional_storage<_Tp> __base; public: typedef _Tp value_type; static_assert(!is_reference::value, "Instantiation of optional with a reference type is ill-formed."); static_assert(!is_same::type, in_place_t>::value, "Instantiation of optional with a in_place_t type is ill-formed."); static_assert(!is_same::type, nullopt_t>::value, "Instantiation of optional with a nullopt_t type is ill-formed."); static_assert(is_object::value, "Instantiation of optional with a non-object type is undefined behavior."); static_assert(is_nothrow_destructible::value, "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior."); _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default; _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default; _LIBCPP_INLINE_VISIBILITY ~optional() = default; _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v) : __base(__v) {} _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v) : __base(_VSTD::move(__v)) {} template ::value >::type > _LIBCPP_INLINE_VISIBILITY constexpr explicit optional(in_place_t, _Args&&... __args) : __base(in_place, _VSTD::forward<_Args>(__args)...) {} template &, _Args...>::value >::type > _LIBCPP_INLINE_VISIBILITY constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} _LIBCPP_INLINE_VISIBILITY optional& operator=(nullopt_t) noexcept { if (this->__engaged_) { this->__val_.~value_type(); this->__engaged_ = false; } return *this; } _LIBCPP_INLINE_VISIBILITY optional& operator=(const optional& __opt) { if (this->__engaged_ == __opt.__engaged_) { if (this->__engaged_) this->__val_ = __opt.__val_; } else { if (this->__engaged_) this->__val_.~value_type(); else ::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_); this->__engaged_ = __opt.__engaged_; } return *this; } _LIBCPP_INLINE_VISIBILITY optional& operator=(optional&& __opt) noexcept(is_nothrow_move_assignable::value && is_nothrow_move_constructible::value) { if (this->__engaged_ == __opt.__engaged_) { if (this->__engaged_) this->__val_ = _VSTD::move(__opt.__val_); } else { if (this->__engaged_) this->__val_.~value_type(); else ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); this->__engaged_ = __opt.__engaged_; } return *this; } template ::type, value_type>::value && is_constructible::value && is_assignable::value >::type > _LIBCPP_INLINE_VISIBILITY optional& operator=(_Up&& __v) { if (this->__engaged_) this->__val_ = _VSTD::forward<_Up>(__v); else { ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); this->__engaged_ = true; } return *this; } template ::value >::type > _LIBCPP_INLINE_VISIBILITY void emplace(_Args&&... __args) { *this = nullopt; ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); this->__engaged_ = true; } template &, _Args...>::value >::type > _LIBCPP_INLINE_VISIBILITY void emplace(initializer_list<_Up> __il, _Args&&... __args) { *this = nullopt; ::new((void*)_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); this->__engaged_ = true; } _LIBCPP_INLINE_VISIBILITY void swap(optional& __opt) noexcept(is_nothrow_move_constructible::value && __is_nothrow_swappable::value) { using _VSTD::swap; if (this->__engaged_ == __opt.__engaged_) { if (this->__engaged_) swap(this->__val_, __opt.__val_); } else { if (this->__engaged_) { ::new((void*)_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); this->__val_.~value_type(); } else { ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); __opt.__val_.~value_type(); } swap(this->__engaged_, __opt.__engaged_); } } _LIBCPP_INLINE_VISIBILITY constexpr value_type const* operator->() const { _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF return __builtin_addressof(this->__val_); #else return __operator_arrow(__has_operator_addressof{}); #endif } _LIBCPP_INLINE_VISIBILITY value_type* operator->() { _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); return _VSTD::addressof(this->__val_); } _LIBCPP_INLINE_VISIBILITY constexpr const value_type& operator*() const { _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); return this->__val_; } _LIBCPP_INLINE_VISIBILITY value_type& operator*() { _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); return this->__val_; } _LIBCPP_INLINE_VISIBILITY constexpr explicit operator bool() const noexcept {return this->__engaged_;} _LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY +#ifndef _LIBCPP_NO_EXCEPTIONS +_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +#endif constexpr void __throw_bad_optional_access() const { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_optional_access(); #else _VSTD::abort(); #endif } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS constexpr value_type const& value() const { if (!this->__engaged_) __throw_bad_optional_access(); return this->__val_; } - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS value_type& value() { if (!this->__engaged_) __throw_bad_optional_access(); return this->__val_; } template _LIBCPP_INLINE_VISIBILITY constexpr value_type value_or(_Up&& __v) const& { static_assert(is_copy_constructible::value, "optional::value_or: T must be copy constructible"); static_assert(is_convertible<_Up, value_type>::value, "optional::value_or: U must be convertible to T"); return this->__engaged_ ? this->__val_ : static_cast(_VSTD::forward<_Up>(__v)); } template _LIBCPP_INLINE_VISIBILITY value_type value_or(_Up&& __v) && { static_assert(is_move_constructible::value, "optional::value_or: T must be move constructible"); static_assert(is_convertible<_Up, value_type>::value, "optional::value_or: U must be convertible to T"); return this->__engaged_ ? _VSTD::move(this->__val_) : static_cast(_VSTD::forward<_Up>(__v)); } private: _LIBCPP_INLINE_VISIBILITY value_type const* __operator_arrow(true_type) const { return _VSTD::addressof(this->__val_); } _LIBCPP_INLINE_VISIBILITY constexpr value_type const* __operator_arrow(false_type) const { return &this->__val_; } }; // Comparisons between optionals template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) { if (static_cast(__x) != static_cast(__y)) return false; if (!static_cast(__x)) return true; return *__x == *__y; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y) { return !(__x == __y); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) { if (!static_cast(__y)) return false; if (!static_cast(__x)) return true; return *__x < *__y; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(const optional<_Tp>& __x, const optional<_Tp>& __y) { return __y < __x; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y) { return !(__y < __x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y) { return !(__x < __y); } // Comparisons with nullopt template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept { return !static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept { return !static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(const optional<_Tp>& __x, nullopt_t) noexcept { return static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(nullopt_t, const optional<_Tp>& __x) noexcept { return static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(const optional<_Tp>&, nullopt_t) noexcept { return false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(nullopt_t, const optional<_Tp>& __x) noexcept { return static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(const optional<_Tp>& __x, nullopt_t) noexcept { return !static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(nullopt_t, const optional<_Tp>&) noexcept { return true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(const optional<_Tp>& __x, nullopt_t) noexcept { return static_cast(__x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(nullopt_t, const optional<_Tp>&) noexcept { return false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(const optional<_Tp>&, nullopt_t) noexcept { return true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(nullopt_t, const optional<_Tp>& __x) noexcept { return !static_cast(__x); } // Comparisons with T template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(const optional<_Tp>& __x, const _Tp& __v) { return static_cast(__x) ? *__x == __v : false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator==(const _Tp& __v, const optional<_Tp>& __x) { return static_cast(__x) ? *__x == __v : false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(const optional<_Tp>& __x, const _Tp& __v) { return static_cast(__x) ? !(*__x == __v) : true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator!=(const _Tp& __v, const optional<_Tp>& __x) { return static_cast(__x) ? !(*__x == __v) : true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(const optional<_Tp>& __x, const _Tp& __v) { return static_cast(__x) ? less<_Tp>{}(*__x, __v) : true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<(const _Tp& __v, const optional<_Tp>& __x) { return static_cast(__x) ? less<_Tp>{}(__v, *__x) : false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(const optional<_Tp>& __x, const _Tp& __v) { return !(__x > __v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator<=(const _Tp& __v, const optional<_Tp>& __x) { return !(__v > __x); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(const optional<_Tp>& __x, const _Tp& __v) { return static_cast(__x) ? __v < __x : false; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>(const _Tp& __v, const optional<_Tp>& __x) { return static_cast(__x) ? __x < __v : true; } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(const optional<_Tp>& __x, const _Tp& __v) { return !(__x < __v); } template inline _LIBCPP_INLINE_VISIBILITY constexpr bool operator>=(const _Tp& __v, const optional<_Tp>& __x) { return !(__v < __x); } template inline _LIBCPP_INLINE_VISIBILITY void swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } template inline _LIBCPP_INLINE_VISIBILITY constexpr optional::type> make_optional(_Tp&& __v) { return optional::type>(_VSTD::forward<_Tp>(__v)); } _LIBCPP_END_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS hash > { typedef std::experimental::optional<_Tp> argument_type; typedef size_t result_type; _LIBCPP_INLINE_VISIBILITY result_type operator()(const argument_type& __opt) const _NOEXCEPT { return static_cast(__opt) ? hash<_Tp>()(*__opt) : 0; } }; _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER > 11 #endif // _LIBCPP_EXPERIMENTAL_OPTIONAL Index: vendor/libc++/dist/include/functional =================================================================== --- vendor/libc++/dist/include/functional (revision 317954) +++ vendor/libc++/dist/include/functional (revision 317955) @@ -1,2424 +1,2424 @@ // -*- C++ -*- //===------------------------ functional ----------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_FUNCTIONAL #define _LIBCPP_FUNCTIONAL /* functional synopsis namespace std { template struct unary_function { typedef Arg argument_type; typedef Result result_type; }; template struct binary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Result result_type; }; template class reference_wrapper : public unary_function // if wrapping a unary functor : public binary_function // if wraping a binary functor { public: // types typedef T type; typedef see below result_type; // Not always defined // construct/copy/destroy reference_wrapper(T&) noexcept; reference_wrapper(T&&) = delete; // do not bind to temps reference_wrapper(const reference_wrapper& x) noexcept; // assignment reference_wrapper& operator=(const reference_wrapper& x) noexcept; // access operator T& () const noexcept; T& get() const noexcept; // invoke template typename result_of::type operator() (ArgTypes&&...) const; }; template reference_wrapper ref(T& t) noexcept; template void ref(const T&& t) = delete; template reference_wrapper ref(reference_wrappert) noexcept; template reference_wrapper cref(const T& t) noexcept; template void cref(const T&& t) = delete; template reference_wrapper cref(reference_wrapper t) noexcept; template // in C++14 struct plus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct minus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct multiplies : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct divides : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct modulus : binary_function { T operator()(const T& x, const T& y) const; }; template // in C++14 struct negate : unary_function { T operator()(const T& x) const; }; template // in C++14 struct equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct not_equal_to : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct greater : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct less : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct greater_equal : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct less_equal : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_and : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_or : binary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct logical_not : unary_function { bool operator()(const T& x) const; }; template // in C++14 struct bit_and : unary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct bit_or : unary_function { bool operator()(const T& x, const T& y) const; }; template // in C++14 struct bit_xor : unary_function { bool operator()(const T& x, const T& y) const; }; template // C++14 struct bit_xor : unary_function { bool operator()(const T& x) const; }; template class unary_negate : public unary_function { public: explicit unary_negate(const Predicate& pred); bool operator()(const typename Predicate::argument_type& x) const; }; template unary_negate not1(const Predicate& pred); template class binary_negate : public binary_function { public: explicit binary_negate(const Predicate& pred); bool operator()(const typename Predicate::first_argument_type& x, const typename Predicate::second_argument_type& y) const; }; template binary_negate not2(const Predicate& pred); template unspecified not_fn(F&& f); // C++17 template struct is_bind_expression; template struct is_placeholder; // See C++14 20.9.9, Function object binders template constexpr bool is_bind_expression_v = is_bind_expression::value; // C++17 template constexpr int is_placeholder_v = is_placeholder::value; // C++17 template unspecified bind(Fn&&, BoundArgs&&...); template unspecified bind(Fn&&, BoundArgs&&...); namespace placeholders { // M is the implementation-defined number of placeholders extern unspecified _1; extern unspecified _2; . . . extern unspecified _Mp; } template class binder1st // deprecated in C++11, removed in C++17 : public unary_function { protected: Operation op; typename Operation::first_argument_type value; public: binder1st(const Operation& x, const typename Operation::first_argument_type y); typename Operation::result_type operator()( typename Operation::second_argument_type& x) const; typename Operation::result_type operator()(const typename Operation::second_argument_type& x) const; }; template binder1st bind1st(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 template class binder2nd // deprecated in C++11, removed in C++17 : public unary_function { protected: Operation op; typename Operation::second_argument_type value; public: binder2nd(const Operation& x, const typename Operation::second_argument_type y); typename Operation::result_type operator()( typename Operation::first_argument_type& x) const; typename Operation::result_type operator()(const typename Operation::first_argument_type& x) const; }; template binder2nd bind2nd(const Operation& op, const T& x); // deprecated in C++11, removed in C++17 template // deprecated in C++11, removed in C++17 class pointer_to_unary_function : public unary_function { public: explicit pointer_to_unary_function(Result (*f)(Arg)); Result operator()(Arg x) const; }; template pointer_to_unary_function ptr_fun(Result (*f)(Arg)); // deprecated in C++11, removed in C++17 template // deprecated in C++11, removed in C++17 class pointer_to_binary_function : public binary_function { public: explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); Result operator()(Arg1 x, Arg2 y) const; }; template pointer_to_binary_function ptr_fun(Result (*f)(Arg1,Arg2)); // deprecated in C++11, removed in C++17 template // deprecated in C++11, removed in C++17 class mem_fun_t : public unary_function { public: explicit mem_fun_t(S (T::*p)()); S operator()(T* p) const; }; template class mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; }; template mem_fun_t mem_fun(S (T::*f)()); // deprecated in C++11, removed in C++17 template mem_fun1_t mem_fun(S (T::*f)(A)); // deprecated in C++11, removed in C++17 template class mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun_ref_t(S (T::*p)()); S operator()(T& p) const; }; template class mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit mem_fun1_ref_t(S (T::*p)(A)); S operator()(T& p, A x) const; }; template mem_fun_ref_t mem_fun_ref(S (T::*f)()); // deprecated in C++11, removed in C++17 template mem_fun1_ref_t mem_fun_ref(S (T::*f)(A)); // deprecated in C++11, removed in C++17 template class const_mem_fun_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun_t(S (T::*p)() const); S operator()(const T* p) const; }; template class const_mem_fun1_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; }; template const_mem_fun_t mem_fun(S (T::*f)() const); // deprecated in C++11, removed in C++17 template const_mem_fun1_t mem_fun(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 template class const_mem_fun_ref_t : public unary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun_ref_t(S (T::*p)() const); S operator()(const T& p) const; }; template class const_mem_fun1_ref_t : public binary_function // deprecated in C++11, removed in C++17 { public: explicit const_mem_fun1_ref_t(S (T::*p)(A) const); S operator()(const T& p, A x) const; }; template const_mem_fun_ref_t mem_fun_ref(S (T::*f)() const); // deprecated in C++11, removed in C++17 template const_mem_fun1_ref_t mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 template unspecified mem_fn(R T::*); class bad_function_call : public exception { }; template class function; // undefined template class function : public unary_function // iff sizeof...(ArgTypes) == 1 and // ArgTypes contains T1 : public binary_function // iff sizeof...(ArgTypes) == 2 and // ArgTypes contains T1 and T2 { public: typedef R result_type; // construct/copy/destroy: function() noexcept; function(nullptr_t) noexcept; function(const function&); function(function&&) noexcept; template function(F); template function(allocator_arg_t, const Alloc&) noexcept; // removed in C++17 template function(allocator_arg_t, const Alloc&, nullptr_t) noexcept; // removed in C++17 template function(allocator_arg_t, const Alloc&, const function&); // removed in C++17 template function(allocator_arg_t, const Alloc&, function&&); // removed in C++17 template function(allocator_arg_t, const Alloc&, F); // removed in C++17 function& operator=(const function&); function& operator=(function&&) noexcept; function& operator=(nullptr_t) noexcept; template function& operator=(F&&); template function& operator=(reference_wrapper) noexcept; ~function(); // function modifiers: void swap(function&) noexcept; template void assign(F&&, const Alloc&); // Removed in C++17 // function capacity: explicit operator bool() const noexcept; // function invocation: R operator()(ArgTypes...) const; // function target access: const std::type_info& target_type() const noexcept; template T* target() noexcept; template const T* target() const noexcept; }; // Null pointer comparisons: template bool operator==(const function&, nullptr_t) noexcept; template bool operator==(nullptr_t, const function&) noexcept; template bool operator!=(const function&, nullptr_t) noexcept; template bool operator!=(nullptr_t, const function&) noexcept; // specialized algorithms: template void swap(function&, function&) noexcept; template struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template struct hash; template <> struct hash; // C++17 } // std POLICY: For non-variadic implementations, the number of arguments is limited to 3. It is hoped that the need for non-variadic implementations will be minimal. */ #include <__config> #include #include #include #include #include #include #include <__functional_base> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS plus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS plus { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS minus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS minus { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS multiplies { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS divides : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS divides { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS modulus : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS modulus { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS negate : unary_function<_Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return -__x;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS negate { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) -> decltype (- _VSTD::forward<_Tp>(__x)) { return - _VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS equal_to { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS not_equal_to { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS greater { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif // less in <__functional_base> #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS greater_equal { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS less_equal : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS less_equal { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS logical_and : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS logical_and { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS logical_or : binary_function<_Tp, _Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS logical_or { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS logical_not : unary_function<_Tp, bool> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const {return !__x;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS logical_not { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) -> decltype (!_VSTD::forward<_Tp>(__x)) { return !_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS bit_and { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS bit_or { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template #else template #endif struct _LIBCPP_TEMPLATE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; #if _LIBCPP_STD_VER > 11 template <> struct _LIBCPP_TEMPLATE_VIS bit_xor { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TEMPLATE_VIS bit_not : unary_function<_Tp, _Tp> { _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return ~__x;} }; template <> struct _LIBCPP_TEMPLATE_VIS bit_not { template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) -> decltype (~_VSTD::forward<_Tp>(__x)) { return ~_VSTD::forward<_Tp>(__x); } typedef void is_transparent; }; #endif template class _LIBCPP_TEMPLATE_VIS unary_negate : public unary_function { _Predicate __pred_; public: _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) : __pred_(__pred) {} _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const {return !__pred_(__x);} }; template inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} template class _LIBCPP_TEMPLATE_VIS binary_negate : public binary_function { _Predicate __pred_; public: _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 binary_negate(const _Predicate& __pred) : __pred_(__pred) {} _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {return !__pred_(__x, __y);} }; template inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) template class _LIBCPP_TEMPLATE_VIS binder1st : public unary_function { protected: __Operation op; typename __Operation::first_argument_type value; public: _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, const typename __Operation::first_argument_type __y) : op(__x), value(__y) {} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (typename __Operation::second_argument_type& __x) const {return op(value, __x);} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (const typename __Operation::second_argument_type& __x) const {return op(value, __x);} }; template inline _LIBCPP_INLINE_VISIBILITY binder1st<__Operation> bind1st(const __Operation& __op, const _Tp& __x) {return binder1st<__Operation>(__op, __x);} template class _LIBCPP_TEMPLATE_VIS binder2nd : public unary_function { protected: __Operation op; typename __Operation::second_argument_type value; public: _LIBCPP_INLINE_VISIBILITY binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) : op(__x), value(__y) {} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() ( typename __Operation::first_argument_type& __x) const {return op(__x, value);} _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() (const typename __Operation::first_argument_type& __x) const {return op(__x, value);} }; template inline _LIBCPP_INLINE_VISIBILITY binder2nd<__Operation> bind2nd(const __Operation& __op, const _Tp& __x) {return binder2nd<__Operation>(__op, __x);} template class _LIBCPP_TEMPLATE_VIS pointer_to_unary_function : public unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); public: _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const {return __f_(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY pointer_to_unary_function<_Arg,_Result> ptr_fun(_Result (*__f)(_Arg)) {return pointer_to_unary_function<_Arg,_Result>(__f);} template class _LIBCPP_TEMPLATE_VIS pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); public: _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const {return __f_(__x, __y);} }; template inline _LIBCPP_INLINE_VISIBILITY pointer_to_binary_function<_Arg1,_Arg2,_Result> ptr_fun(_Result (*__f)(_Arg1,_Arg2)) {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} template class _LIBCPP_TEMPLATE_VIS mem_fun_t : public unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const {return (__p->*__p_)();} }; template class _LIBCPP_TEMPLATE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const {return (__p->*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)()) {return mem_fun_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TEMPLATE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const {return (__p.*__p_)();} }; template class _LIBCPP_TEMPLATE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const {return (__p.*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)()) {return mem_fun_ref_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TEMPLATE_VIS const_mem_fun_t : public unary_function { _Sp (_Tp::*__p_)() const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const {return (__p->*__p_)();} }; template class _LIBCPP_TEMPLATE_VIS const_mem_fun1_t : public binary_function { _Sp (_Tp::*__p_)(_Ap) const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const {return (__p->*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_t<_Sp,_Tp> mem_fun(_Sp (_Tp::*__f)() const) {return const_mem_fun_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_t<_Sp,_Tp,_Ap> mem_fun(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template class _LIBCPP_TEMPLATE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const {return (__p.*__p_)();} }; template class _LIBCPP_TEMPLATE_VIS const_mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; public: _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const {return (__p.*__p_)(__x);} }; template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun_ref_t<_Sp,_Tp> mem_fun_ref(_Sp (_Tp::*__f)() const) {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} template inline _LIBCPP_INLINE_VISIBILITY const_mem_fun1_ref_t<_Sp,_Tp,_Ap> mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} #endif //////////////////////////////////////////////////////////////////////////////// // MEMFUN //============================================================================== template class __mem_fn : public __weak_result_type<_Tp> { public: // types typedef _Tp type; private: type __f_; public: _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} #ifndef _LIBCPP_CXX03_LANG // invoke template _LIBCPP_INLINE_VISIBILITY typename __invoke_return::type operator() (_ArgTypes&&... __args) const { return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); } #else template _LIBCPP_INLINE_VISIBILITY typename __invoke_return0::type operator() (_A0& __a0) const { return __invoke(__f_, __a0); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return0::type operator() (_A0 const& __a0) const { return __invoke(__f_, __a0); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return1::type operator() (_A0& __a0, _A1& __a1) const { return __invoke(__f_, __a0, __a1); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return1::type operator() (_A0 const& __a0, _A1& __a1) const { return __invoke(__f_, __a0, __a1); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return1::type operator() (_A0& __a0, _A1 const& __a1) const { return __invoke(__f_, __a0, __a1); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return1::type operator() (_A0 const& __a0, _A1 const& __a1) const { return __invoke(__f_, __a0, __a1); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } template _LIBCPP_INLINE_VISIBILITY typename __invoke_return2::type operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { return __invoke(__f_, __a0, __a1, __a2); } #endif }; template inline _LIBCPP_INLINE_VISIBILITY __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::* __pm) _NOEXCEPT { return __mem_fn<_Rp _Tp::*>(__pm); } //////////////////////////////////////////////////////////////////////////////// // FUNCTION //============================================================================== // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call : public exception { #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION public: virtual ~bad_function_call() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; #endif }; _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE void __throw_bad_function_call() { #ifndef _LIBCPP_NO_EXCEPTIONS throw bad_function_call(); #else _VSTD::abort(); #endif } template class _LIBCPP_TEMPLATE_VIS function; // undefined namespace __function { template struct __maybe_derive_from_unary_function { }; template struct __maybe_derive_from_unary_function<_Rp(_A1)> : public unary_function<_A1, _Rp> { }; template struct __maybe_derive_from_binary_function { }; template struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public binary_function<_A1, _A2, _Rp> { }; template _LIBCPP_INLINE_VISIBILITY bool __not_null(_Fp const&) { return true; } template _LIBCPP_INLINE_VISIBILITY bool __not_null(_Fp* __ptr) { return __ptr; } template _LIBCPP_INLINE_VISIBILITY bool __not_null(_Ret _Class::*__ptr) { return __ptr; } template _LIBCPP_INLINE_VISIBILITY bool __not_null(function<_Fp> const& __f) { return !!__f; } } // namespace __function #ifndef _LIBCPP_CXX03_LANG namespace __function { template class __base; template class __base<_Rp(_ArgTypes...)> { __base(const __base&); __base& operator=(const __base&); public: _LIBCPP_INLINE_VISIBILITY __base() {} _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} virtual __base* __clone() const = 0; virtual void __clone(__base*) const = 0; virtual void destroy() _NOEXCEPT = 0; virtual void destroy_deallocate() _NOEXCEPT = 0; virtual _Rp operator()(_ArgTypes&& ...) = 0; #ifndef _LIBCPP_NO_RTTI virtual const void* target(const type_info&) const _NOEXCEPT = 0; virtual const std::type_info& target_type() const _NOEXCEPT = 0; #endif // _LIBCPP_NO_RTTI }; template class __func; template class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> { __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp&& __f) : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), _VSTD::forward_as_tuple()) {} _LIBCPP_INLINE_VISIBILITY explicit __func(const _Fp& __f, const _Alloc& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), _VSTD::forward_as_tuple(__a)) {} _LIBCPP_INLINE_VISIBILITY explicit __func(const _Fp& __f, _Alloc&& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), _VSTD::forward_as_tuple(_VSTD::move(__a))) {} _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp&& __f, _Alloc&& __a) : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), _VSTD::forward_as_tuple(_VSTD::move(__a))) {} virtual __base<_Rp(_ArgTypes...)>* __clone() const; virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; virtual void destroy() _NOEXCEPT; virtual void destroy_deallocate() _NOEXCEPT; virtual _Rp operator()(_ArgTypes&& ... __arg); #ifndef _LIBCPP_NO_RTTI virtual const void* target(const type_info&) const _NOEXCEPT; virtual const std::type_info& target_type() const _NOEXCEPT; #endif // _LIBCPP_NO_RTTI }; template __base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const { typedef allocator_traits<_Alloc> __alloc_traits; typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) __func(__f_.first(), _Alloc(__a)); return __hold.release(); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const { ::new (__p) __func(__f_.first(), __f_.second()); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT { __f_.~__compressed_pair<_Fp, _Alloc>(); } template void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT { typedef allocator_traits<_Alloc> __alloc_traits; typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(this, 1); } template _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { typedef __invoke_void_return_wrapper<_Rp> _Invoker; return _Invoker::__call(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI template const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { if (__ti == typeid(_Fp)) return &__f_.first(); return (const void*)0; } template const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { return typeid(_Fp); } #endif // _LIBCPP_NO_RTTI } // __function template class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { typedef __function::__base<_Rp(_ArgTypes...)> __base; typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; _LIBCPP_NO_CFI static __base *__as_base(void *p) { return reinterpret_cast<__base*>(p); } template ::value && __invokable<_Fp&, _ArgTypes...>::value> struct __callable; template struct __callable<_Fp, true> { static const bool value = is_same::value || is_convertible::type, _Rp>::value; }; template struct __callable<_Fp, false> { static const bool value = false; }; public: typedef _Rp result_type; // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY function() _NOEXCEPT : __f_(0) {} _LIBCPP_INLINE_VISIBILITY function(nullptr_t) _NOEXCEPT : __f_(0) {} function(const function&); function(function&&) _NOEXCEPT; template::value && !is_same<_Fp, function>::value >::type> function(_Fp); #if _LIBCPP_STD_VER <= 14 template _LIBCPP_INLINE_VISIBILITY function(allocator_arg_t, const _Alloc&) _NOEXCEPT : __f_(0) {} template _LIBCPP_INLINE_VISIBILITY function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT : __f_(0) {} template function(allocator_arg_t, const _Alloc&, const function&); template function(allocator_arg_t, const _Alloc&, function&&); template::value>::type> function(allocator_arg_t, const _Alloc& __a, _Fp __f); #endif function& operator=(const function&); function& operator=(function&&) _NOEXCEPT; function& operator=(nullptr_t) _NOEXCEPT; template typename enable_if < __callable::type>::value && !is_same::type, function>::value, function& >::type operator=(_Fp&&); ~function(); // function modifiers: void swap(function&) _NOEXCEPT; #if _LIBCPP_STD_VER <= 14 template _LIBCPP_INLINE_VISIBILITY void assign(_Fp&& __f, const _Alloc& __a) {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} #endif // function capacity: _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;} // deleted overloads close possible hole in the type system template bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; template bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; public: // function invocation: _Rp operator()(_ArgTypes...) const; #ifndef _LIBCPP_NO_RTTI // function target access: const std::type_info& target_type() const _NOEXCEPT; template _Tp* target() _NOEXCEPT; template const _Tp* target() const _NOEXCEPT; #endif // _LIBCPP_NO_RTTI }; template function<_Rp(_ArgTypes...)>::function(const function& __f) { if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) { __f_ = __as_base(&__buf_); __f.__f_->__clone(__f_); } else __f_ = __f.__f_->__clone(); } #if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, const function& __f) { if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) { __f_ = __as_base(&__buf_); __f.__f_->__clone(__f_); } else __f_ = __f.__f_->__clone(); } #endif template function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT { if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) { __f_ = __as_base(&__buf_); __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } } #if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, function&& __f) { if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) { __f_ = __as_base(&__buf_); __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } } #endif template template function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(0) { if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) { __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f)); } else { typedef allocator<_FF> _Ap; _Ap __a; typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::move(__f), allocator<_Fp>(__a)); __f_ = __hold.release(); } } } #if _LIBCPP_STD_VER <= 14 template template function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f) : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; _Ap __a(__a0); if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value) { __f_ = ::new((void*)&__buf_) _FF(_VSTD::move(__f), _Alloc(__a)); } else { typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::move(__f), _Alloc(__a)); __f_ = __hold.release(); } } } #endif template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(const function& __f) { function(__f).swap(*this); return *this; } template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT { if ((void *)__f_ == &__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = 0; if (__f.__f_ == 0) __f_ = 0; else if ((void *)__f.__f_ == &__f.__buf_) { __f_ = __as_base(&__buf_); __f.__f_->__clone(__f_); } else { __f_ = __f.__f_; __f.__f_ = 0; } return *this; } template function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT { if ((void *)__f_ == &__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = 0; return *this; } template template typename enable_if < function<_Rp(_ArgTypes...)>::template __callable::type>::value && !is_same::type, function<_Rp(_ArgTypes...)>>::value, function<_Rp(_ArgTypes...)>& >::type function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) { function(_VSTD::forward<_Fp>(__f)).swap(*this); return *this; } template function<_Rp(_ArgTypes...)>::~function() { if ((void *)__f_ == &__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); } template void function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT { if (_VSTD::addressof(__f) == this) return; if ((void *)__f_ == &__buf_ && (void *)__f.__f_ == &__f.__buf_) { typename aligned_storage::type __tempbuf; __base* __t = __as_base(&__tempbuf); __f_->__clone(__t); __f_->destroy(); __f_ = 0; __f.__f_->__clone(__as_base(&__buf_)); __f.__f_->destroy(); __f.__f_ = 0; __f_ = __as_base(&__buf_); __t->__clone(__as_base(&__f.__buf_)); __t->destroy(); __f.__f_ = __as_base(&__f.__buf_); } else if ((void *)__f_ == &__buf_) { __f_->__clone(__as_base(&__f.__buf_)); __f_->destroy(); __f_ = __f.__f_; __f.__f_ = __as_base(&__f.__buf_); } else if ((void *)__f.__f_ == &__f.__buf_) { __f.__f_->__clone(__as_base(&__buf_)); __f.__f_->destroy(); __f.__f_ = __f_; __f_ = __as_base(&__buf_); } else _VSTD::swap(__f_, __f.__f_); } template _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { if (__f_ == 0) __throw_bad_function_call(); return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); } #ifndef _LIBCPP_NO_RTTI template const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { if (__f_ == 0) return typeid(void); return __f_->target_type(); } template template _Tp* function<_Rp(_ArgTypes...)>::target() _NOEXCEPT { if (__f_ == 0) return (_Tp*)0; return (_Tp*)__f_->target(typeid(_Tp)); } template template const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT { if (__f_ == 0) return (const _Tp*)0; return (const _Tp*)__f_->target(typeid(_Tp)); } #endif // _LIBCPP_NO_RTTI template inline _LIBCPP_INLINE_VISIBILITY bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} template inline _LIBCPP_INLINE_VISIBILITY bool operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} template inline _LIBCPP_INLINE_VISIBILITY void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} #else // _LIBCPP_CXX03_LANG #include <__functional_03> #endif //////////////////////////////////////////////////////////////////////////////// // BIND //============================================================================== template struct __is_bind_expression : public false_type {}; template struct _LIBCPP_TEMPLATE_VIS is_bind_expression : public __is_bind_expression::type> {}; #if _LIBCPP_STD_VER > 14 template constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; #endif template struct __is_placeholder : public integral_constant {}; template struct _LIBCPP_TEMPLATE_VIS is_placeholder : public __is_placeholder::type> {}; #if _LIBCPP_STD_VER > 14 template constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; #endif namespace placeholders { template struct __ph {}; #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND) _LIBCPP_FUNC_VIS extern const __ph<1> _1; _LIBCPP_FUNC_VIS extern const __ph<2> _2; _LIBCPP_FUNC_VIS extern const __ph<3> _3; _LIBCPP_FUNC_VIS extern const __ph<4> _4; _LIBCPP_FUNC_VIS extern const __ph<5> _5; _LIBCPP_FUNC_VIS extern const __ph<6> _6; _LIBCPP_FUNC_VIS extern const __ph<7> _7; _LIBCPP_FUNC_VIS extern const __ph<8> _8; _LIBCPP_FUNC_VIS extern const __ph<9> _9; _LIBCPP_FUNC_VIS extern const __ph<10> _10; #else constexpr __ph<1> _1{}; constexpr __ph<2> _2{}; constexpr __ph<3> _3{}; constexpr __ph<4> _4{}; constexpr __ph<5> _5{}; constexpr __ph<6> _6{}; constexpr __ph<7> _7{}; constexpr __ph<8> _8{}; constexpr __ph<9> _9{}; constexpr __ph<10> _10{}; #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND) } // placeholders template struct __is_placeholder > : public integral_constant {}; #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) { return __t.get(); } template inline _LIBCPP_INLINE_VISIBILITY typename __invoke_of<_Ti&, _Uj...>::type __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); } template inline _LIBCPP_INLINE_VISIBILITY typename __lazy_enable_if < is_bind_expression<_Ti>::value, __invoke_of<_Ti&, _Uj...> >::type __mu(_Ti& __ti, tuple<_Uj...>& __uj) { typedef typename __make_tuple_indices::type __indices; return __mu_expand(__ti, __uj, __indices()); } template struct __mu_return2 {}; template struct __mu_return2 { typedef typename tuple_element::value - 1, _Uj>::type type; }; template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < 0 < is_placeholder<_Ti>::value, typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type >::type __mu(_Ti&, _Uj& __uj) { const size_t _Indx = is_placeholder<_Ti>::value - 1; return _VSTD::forward::type>(_VSTD::get<_Indx>(__uj)); } template inline _LIBCPP_INLINE_VISIBILITY typename enable_if < !is_bind_expression<_Ti>::value && is_placeholder<_Ti>::value == 0 && !__is_reference_wrapper<_Ti>::value, _Ti& >::type __mu(_Ti& __ti, _Uj&) { return __ti; } template struct ____mu_return; template struct ____mu_return_invokable // false { typedef __nat type; }; template struct ____mu_return_invokable { typedef typename __invoke_of<_Ti&, _Uj...>::type type; }; template struct ____mu_return<_Ti, false, true, false, tuple<_Uj...> > : public ____mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> { }; template struct ____mu_return<_Ti, false, false, true, _TupleUj> { typedef typename tuple_element::value - 1, _TupleUj>::type&& type; }; template struct ____mu_return<_Ti, true, false, false, _TupleUj> { typedef typename _Ti::type& type; }; template struct ____mu_return<_Ti, false, false, false, _TupleUj> { typedef _Ti& type; }; template struct __mu_return : public ____mu_return<_Ti, __is_reference_wrapper<_Ti>::value, is_bind_expression<_Ti>::value, 0 < is_placeholder<_Ti>::value && is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, _TupleUj> { }; template struct __is_valid_bind_return { static const bool value = false; }; template struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> { static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; }; template struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> { static const bool value = __invokable<_Fp, typename __mu_return::type...>::value; }; template ::value> struct __bind_return; template struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> { typedef typename __invoke_of < _Fp&, typename __mu_return < _BoundArgs, _TupleUj >::type... >::type type; }; template struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { typedef typename __invoke_of < _Fp&, typename __mu_return < const _BoundArgs, _TupleUj >::type... >::type type; }; template inline _LIBCPP_INLINE_VISIBILITY typename __bind_return<_Fp, _BoundArgs, _Args>::type __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _Args&& __args) { - return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); + return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...); } template class __bind : public __weak_result_type::type> { protected: typedef typename decay<_Fp>::type _Fd; typedef tuple::type...> _Td; private: _Fd __f_; _Td __bound_args_; typedef typename __make_tuple_indices::type __indices; public: template ::value && !is_same::type, __bind>::value >::type> _LIBCPP_INLINE_VISIBILITY explicit __bind(_Gp&& __f, _BA&& ...__bound_args) : __f_(_VSTD::forward<_Gp>(__f)), __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} template _LIBCPP_INLINE_VISIBILITY typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type operator()(_Args&& ...__args) { - return __apply_functor(__f_, __bound_args_, __indices(), + return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); } template _LIBCPP_INLINE_VISIBILITY typename __bind_return >::type operator()(_Args&& ...__args) const { - return __apply_functor(__f_, __bound_args_, __indices(), + return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); } }; template struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; template class __bind_r : public __bind<_Fp, _BoundArgs...> { typedef __bind<_Fp, _BoundArgs...> base; typedef typename base::_Fd _Fd; typedef typename base::_Td _Td; public: typedef _Rp result_type; template ::value && !is_same::type, __bind_r>::value >::type> _LIBCPP_INLINE_VISIBILITY explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) : base(_VSTD::forward<_Gp>(__f), _VSTD::forward<_BA>(__bound_args)...) {} template _LIBCPP_INLINE_VISIBILITY typename enable_if < is_convertible >::type, result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) { typedef __invoke_void_return_wrapper<_Rp> _Invoker; return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } template _LIBCPP_INLINE_VISIBILITY typename enable_if < is_convertible >::type, result_type>::value || is_void<_Rp>::value, result_type >::type operator()(_Args&& ...__args) const { typedef __invoke_void_return_wrapper<_Rp> _Invoker; return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); } }; template struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; template inline _LIBCPP_INLINE_VISIBILITY __bind<_Fp, _BoundArgs...> bind(_Fp&& __f, _BoundArgs&&... __bound_args) { typedef __bind<_Fp, _BoundArgs...> type; return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); } template inline _LIBCPP_INLINE_VISIBILITY __bind_r<_Rp, _Fp, _BoundArgs...> bind(_Fp&& __f, _BoundArgs&&... __bound_args) { typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); } #endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER > 14 #define __cpp_lib_invoke 201411 template result_of_t<_Fn&&(_Args&&...)> invoke(_Fn&& __f, _Args&&... __args) noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...))) { return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); } template class _LIBCPP_TEMPLATE_VIS __not_fn_imp { _DecayFunc __fd; public: __not_fn_imp() = delete; template _LIBCPP_INLINE_VISIBILITY auto operator()(_Args&& ...__args) & noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } template _LIBCPP_INLINE_VISIBILITY auto operator()(_Args&& ...__args) && noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } template _LIBCPP_INLINE_VISIBILITY auto operator()(_Args&& ...__args) const& noexcept(noexcept(!_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...))) -> decltype( !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...)) { return !_VSTD::invoke(__fd, _VSTD::forward<_Args>(__args)...); } template _LIBCPP_INLINE_VISIBILITY auto operator()(_Args&& ...__args) const&& noexcept(noexcept(!_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...))) -> decltype( !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...)) { return !_VSTD::invoke(_VSTD::move(__fd), _VSTD::forward<_Args>(__args)...); } private: template , __not_fn_imp>::value>> _LIBCPP_INLINE_VISIBILITY explicit __not_fn_imp(_RawFunc&& __rf) : __fd(_VSTD::forward<_RawFunc>(__rf)) {} template friend inline _LIBCPP_INLINE_VISIBILITY __not_fn_imp> not_fn(_RawFunc&&); }; template inline _LIBCPP_INLINE_VISIBILITY __not_fn_imp> not_fn(_RawFunc&& __fn) { return __not_fn_imp>(_VSTD::forward<_RawFunc>(__fn)); } #endif // struct hash in _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FUNCTIONAL Index: vendor/libc++/dist/include/future =================================================================== --- vendor/libc++/dist/include/future (revision 317954) +++ vendor/libc++/dist/include/future (revision 317955) @@ -1,2613 +1,2617 @@ // -*- C++ -*- //===--------------------------- future -----------------------------------===// // // 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_FUTURE #define _LIBCPP_FUTURE /* future synopsis namespace std { enum class future_errc { future_already_retrieved = 1, promise_already_satisfied, no_state, broken_promise }; enum class launch { async = 1, deferred = 2, any = async | deferred }; enum class future_status { ready, timeout, deferred }; template <> struct is_error_code_enum : public true_type { }; error_code make_error_code(future_errc e) noexcept; error_condition make_error_condition(future_errc e) noexcept; const error_category& future_category() noexcept; class future_error : public logic_error { public: future_error(error_code ec); // exposition only explicit future_error(future_errc); // C++17 const error_code& code() const noexcept; const char* what() const noexcept; }; template class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(const R& r); void set_value(R&& r); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(const R& r); void set_value_at_thread_exit(R&& r); void set_exception_at_thread_exit(exception_ptr p); }; template class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(R& r); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(R&); void set_exception_at_thread_exit(exception_ptr p); }; template <> class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise& rhs) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise& rhs) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(); void set_exception_at_thread_exit(exception_ptr p); }; template void swap(promise& x, promise& y) noexcept; template struct uses_allocator, Alloc> : public true_type {}; template class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value R get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value R& get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template <> class future { public: future() noexcept; future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value void get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value const R& get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value R& get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template <> class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs); shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs); shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value void get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; template future::type(typename decay::type...)>::type> async(F&& f, Args&&... args); template future::type(typename decay::type...)>::type> async(launch policy, F&& f, Args&&... args); template class packaged_task; // undefined template class packaged_task { public: typedef R result_type; // extension // construction and destruction packaged_task() noexcept; template explicit packaged_task(F&& f); template packaged_task(allocator_arg_t, const Allocator& a, F&& f); ~packaged_task(); // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support packaged_task(packaged_task&& other) noexcept; packaged_task& operator=(packaged_task&& other) noexcept; void swap(packaged_task& other) noexcept; bool valid() const noexcept; // result retrieval future get_future(); // execution void operator()(ArgTypes... ); void make_ready_at_thread_exit(ArgTypes...); void reset(); }; template void swap(packaged_task&) noexcept; template struct uses_allocator, Alloc>; } // std */ #include <__config> #include #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #ifdef _LIBCPP_HAS_NO_THREADS #error is not supported on this single threaded system #else // !_LIBCPP_HAS_NO_THREADS _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc _LIBCPP_DECLARE_STRONG_ENUM(future_errc) { future_already_retrieved = 1, promise_already_satisfied, no_state, broken_promise }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type {}; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public true_type { }; #endif //enum class launch _LIBCPP_DECLARE_STRONG_ENUM(launch) { async = 1, deferred = 2, any = async | deferred }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) #ifndef _LIBCPP_HAS_NO_STRONG_ENUMS #ifdef _LIBCXX_UNDERLYING_TYPE typedef underlying_type::type __launch_underlying_type; #else typedef int __launch_underlying_type; #endif inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator&(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator|(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) | static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator^(launch __x, launch __y) { return static_cast(static_cast<__launch_underlying_type>(__x) ^ static_cast<__launch_underlying_type>(__y)); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR launch operator~(launch __x) { return static_cast(~static_cast<__launch_underlying_type>(__x) & 3); } inline _LIBCPP_INLINE_VISIBILITY launch& operator&=(launch& __x, launch __y) { __x = __x & __y; return __x; } inline _LIBCPP_INLINE_VISIBILITY launch& operator|=(launch& __x, launch __y) { __x = __x | __y; return __x; } inline _LIBCPP_INLINE_VISIBILITY launch& operator^=(launch& __x, launch __y) { __x = __x ^ __y; return __x; } #endif // !_LIBCPP_HAS_NO_STRONG_ENUMS //enum class future_status _LIBCPP_DECLARE_STRONG_ENUM(future_status) { ready, timeout, deferred }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_status) _LIBCPP_FUNC_VIS const error_category& future_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code make_error_code(future_errc __e) _NOEXCEPT { return error_code(static_cast(__e), future_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition make_error_condition(future_errc __e) _NOEXCEPT { return error_condition(static_cast(__e), future_category()); } -class _LIBCPP_EXCEPTION_ABI future_error +class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error : public logic_error { error_code __ec_; public: future_error(error_code __ec); #if _LIBCPP_STD_VERS > 14 explicit future_error(future_errc _Ev) : logic_error(), __ec_(make_error_code(_Ev)) {} #endif _LIBCPP_INLINE_VISIBILITY const error_code& code() const _NOEXCEPT {return __ec_;} virtual ~future_error() _NOEXCEPT; }; _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +#ifndef _LIBCPP_NO_EXCEPTIONS +_LIBCPP_AVAILABILITY_FUTURE_ERROR +#endif void __throw_future_error(future_errc _Ev) { #ifndef _LIBCPP_NO_EXCEPTIONS throw future_error(make_error_code(_Ev)); #else ((void)_Ev); _VSTD::abort(); #endif } -class _LIBCPP_TYPE_VIS __assoc_sub_state +class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state : public __shared_count { protected: exception_ptr __exception_; mutable mutex __mut_; mutable condition_variable __cv_; unsigned __state_; virtual void __on_zero_shared() _NOEXCEPT; void __sub_wait(unique_lock& __lk); public: enum { __constructed = 1, __future_attached = 2, ready = 4, deferred = 8 }; _LIBCPP_INLINE_VISIBILITY __assoc_sub_state() : __state_(0) {} _LIBCPP_INLINE_VISIBILITY bool __has_value() const {return (__state_ & __constructed) || (__exception_ != nullptr);} _LIBCPP_INLINE_VISIBILITY void __set_future_attached() { lock_guard __lk(__mut_); __state_ |= __future_attached; } _LIBCPP_INLINE_VISIBILITY bool __has_future_attached() const {return (__state_ & __future_attached) != 0;} _LIBCPP_INLINE_VISIBILITY void __set_deferred() {__state_ |= deferred;} void __make_ready(); _LIBCPP_INLINE_VISIBILITY bool __is_ready() const {return (__state_ & ready) != 0;} void set_value(); void set_value_at_thread_exit(); void set_exception(exception_ptr __p); void set_exception_at_thread_exit(exception_ptr __p); void copy(); void wait(); template future_status _LIBCPP_INLINE_VISIBILITY wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const; virtual void __execute(); }; template future_status __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const { unique_lock __lk(__mut_); if (__state_ & deferred) return future_status::deferred; while (!(__state_ & ready) && _Clock::now() < __abs_time) __cv_.wait_until(__lk, __abs_time); if (__state_ & ready) return future_status::ready; return future_status::timeout; } template inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { return wait_until(chrono::steady_clock::now() + __rel_time); } template -class __assoc_state +class _LIBCPP_AVAILABILITY_FUTURE __assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; typedef typename aligned_storage::value>::type _Up; protected: _Up __value_; virtual void __on_zero_shared() _NOEXCEPT; public: template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value(_Arg&& __arg); #else void set_value(_Arg& __arg); #endif template #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value_at_thread_exit(_Arg&& __arg); #else void set_value_at_thread_exit(_Arg& __arg); #endif _Rp move(); typename add_lvalue_reference<_Rp>::type copy(); }; template void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(&__value_)->~_Rp(); delete this; } template template +_LIBCPP_AVAILABILITY_FUTURE void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __assoc_state<_Rp>::set_value(_Arg&& __arg) #else __assoc_state<_Rp>::set_value(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); } template template void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) #else __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); } template _Rp __assoc_state<_Rp>::move() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return _VSTD::move(*reinterpret_cast<_Rp*>(&__value_)); } template typename add_lvalue_reference<_Rp>::type __assoc_state<_Rp>::copy() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return *reinterpret_cast<_Rp*>(&__value_); } template -class __assoc_state<_Rp&> +class _LIBCPP_AVAILABILITY_FUTURE __assoc_state<_Rp&> : public __assoc_sub_state { typedef __assoc_sub_state base; typedef _Rp* _Up; protected: _Up __value_; virtual void __on_zero_shared() _NOEXCEPT; public: void set_value(_Rp& __arg); void set_value_at_thread_exit(_Rp& __arg); _Rp& copy(); }; template void __assoc_state<_Rp&>::__on_zero_shared() _NOEXCEPT { delete this; } template void __assoc_state<_Rp&>::set_value(_Rp& __arg) { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); } template void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { unique_lock __lk(this->__mut_); if (this->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); } template _Rp& __assoc_state<_Rp&>::copy() { unique_lock __lk(this->__mut_); this->__sub_wait(__lk); if (this->__exception_ != nullptr) rethrow_exception(this->__exception_); return *__value_; } template -class __assoc_state_alloc +class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template -class __assoc_state_alloc<_Rp&, _Alloc> +class _LIBCPP_AVAILABILITY_FUTURE __assoc_state_alloc<_Rp&, _Alloc> : public __assoc_state<_Rp&> { typedef __assoc_state<_Rp&> base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_state_alloc<_Rp&, _Alloc>::__on_zero_shared() _NOEXCEPT { typedef typename __allocator_traits_rebind<_Alloc, __assoc_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template -class __assoc_sub_state_alloc +class _LIBCPP_AVAILABILITY_FUTURE __assoc_sub_state_alloc : public __assoc_sub_state { typedef __assoc_sub_state base; _Alloc __alloc_; virtual void __on_zero_shared() _NOEXCEPT; public: _LIBCPP_INLINE_VISIBILITY explicit __assoc_sub_state_alloc(const _Alloc& __a) : __alloc_(__a) {} }; template void __assoc_sub_state_alloc<_Alloc>::__on_zero_shared() _NOEXCEPT { typedef typename __allocator_traits_rebind<_Alloc, __assoc_sub_state_alloc>::type _Al; typedef allocator_traits<_Al> _ATraits; typedef pointer_traits _PTraits; _Al __a(__alloc_); this->~__assoc_sub_state_alloc(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template -class __deferred_assoc_state +class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Fp __func_; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { this->__set_deferred(); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __deferred_assoc_state<_Rp, _Fp>::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->set_value(__func_()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template -class __deferred_assoc_state +class _LIBCPP_AVAILABILITY_FUTURE __deferred_assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; _Fp __func_; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { this->__set_deferred(); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __deferred_assoc_state::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __func_(); this->set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template -class __async_assoc_state +class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state : public __assoc_state<_Rp> { typedef __assoc_state<_Rp> base; _Fp __func_; virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __async_assoc_state<_Rp, _Fp>::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->set_value(__func_()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void __async_assoc_state<_Rp, _Fp>::__on_zero_shared() _NOEXCEPT { this->wait(); base::__on_zero_shared(); } template -class __async_assoc_state +class _LIBCPP_AVAILABILITY_FUTURE __async_assoc_state : public __assoc_sub_state { typedef __assoc_sub_state base; _Fp __func_; virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif virtual void __execute(); }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void __async_assoc_state::__execute() { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __func_(); this->set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void __async_assoc_state::__on_zero_shared() _NOEXCEPT { this->wait(); base::__on_zero_shared(); } template class _LIBCPP_TEMPLATE_VIS promise; template class _LIBCPP_TEMPLATE_VIS shared_future; // future template class _LIBCPP_TEMPLATE_VIS future; template future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_deferred_assoc_state(_Fp&& __f); #else __make_deferred_assoc_state(_Fp __f); #endif template future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_async_assoc_state(_Fp&& __f); #else __make_async_assoc_state(_Fp __f); #endif template -class _LIBCPP_TEMPLATE_VIS future +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future { __assoc_state<_Rp>* __state_; explicit future(__assoc_state<_Rp>* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future<_Rp> share() _NOEXCEPT; // retrieving the value _Rp get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template future<_Rp>::future(__assoc_state<_Rp>* __state) : __state_(__state) { if (__state_->__has_future_attached()) __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } struct __release_shared_count { void operator()(__shared_count* p) {p->__release_shared();} }; template future<_Rp>::~future() { if (__state_) __state_->__release_shared(); } template _Rp future<_Rp>::get() { unique_ptr<__shared_count, __release_shared_count> __(__state_); __assoc_state<_Rp>* __s = __state_; __state_ = nullptr; return __s->move(); } template -class _LIBCPP_TEMPLATE_VIS future<_Rp&> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE future<_Rp&> { __assoc_state<_Rp&>* __state_; explicit future(__assoc_state<_Rp&>* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future<_Rp&> share() _NOEXCEPT; // retrieving the value _Rp& get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template future<_Rp&>::future(__assoc_state<_Rp&>* __state) : __state_(__state) { if (__state_->__has_future_attached()) __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } template future<_Rp&>::~future() { if (__state_) __state_->__release_shared(); } template _Rp& future<_Rp&>::get() { unique_ptr<__shared_count, __release_shared_count> __(__state_); __assoc_state<_Rp&>* __s = __state_; __state_ = nullptr; return __s->copy(); } template <> -class _LIBCPP_TYPE_VIS future +class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE future { __assoc_sub_state* __state_; explicit future(__assoc_sub_state* __state); template friend class promise; template friend class shared_future; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend future<_R1> __make_deferred_assoc_state(_Fp&& __f); template friend future<_R1> __make_async_assoc_state(_Fp&& __f); #else template friend future<_R1> __make_deferred_assoc_state(_Fp __f); template friend future<_R1> __make_async_assoc_state(_Fp __f); #endif public: _LIBCPP_INLINE_VISIBILITY future() _NOEXCEPT : __state_(nullptr) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY future(future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} future(const future&) = delete; future& operator=(const future&) = delete; _LIBCPP_INLINE_VISIBILITY future& operator=(future&& __rhs) _NOEXCEPT { future(std::move(__rhs)).swap(*this); return *this; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: future(const future&); future& operator=(const future&); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); _LIBCPP_INLINE_VISIBILITY shared_future share() _NOEXCEPT; // retrieving the value void get(); _LIBCPP_INLINE_VISIBILITY void swap(future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template inline _LIBCPP_INLINE_VISIBILITY void swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } // promise template class packaged_task; template -class _LIBCPP_TEMPLATE_VIS promise +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise { __assoc_state<_Rp>* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template promise(allocator_arg_t, const _Alloc& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future<_Rp> get_future(); // setting the result void set_value(const _Rp& __r); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value(_Rp&& __r); #endif void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(const _Rp& __r); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES void set_value_at_thread_exit(_Rp&& __r); #endif void set_exception_at_thread_exit(exception_ptr __p); }; template promise<_Rp>::promise() : __state_(new __assoc_state<_Rp>) { } template template promise<_Rp>::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_state_alloc<_Rp, _Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template promise<_Rp>::~promise() { if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); __state_->__release_shared(); } } template future<_Rp> promise<_Rp>::get_future() { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); return future<_Rp>(__state_); } template void promise<_Rp>::set_value(const _Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(__r); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_value(_Rp&& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(_VSTD::move(__r)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_exception(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } template void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(_VSTD::move(__r)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } // promise template -class _LIBCPP_TEMPLATE_VIS promise<_Rp&> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE promise<_Rp&> { __assoc_state<_Rp&>* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template promise(allocator_arg_t, const _Allocator& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future<_Rp&> get_future(); // setting the result void set_value(_Rp& __r); void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(_Rp&); void set_exception_at_thread_exit(exception_ptr __p); }; template promise<_Rp&>::promise() : __state_(new __assoc_state<_Rp&>) { } template template promise<_Rp&>::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_state_alloc<_Rp&, _Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template promise<_Rp&>::~promise() { if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); __state_->__release_shared(); } } template future<_Rp&> promise<_Rp&>::get_future() { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); return future<_Rp&>(__state_); } template void promise<_Rp&>::set_value(_Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value(__r); } template void promise<_Rp&>::set_exception(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } template void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } template void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { _LIBCPP_ASSERT( __p != nullptr, "promise::set_exception_at_thread_exit: received nullptr" ); if (__state_ == nullptr) __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } // promise template <> -class _LIBCPP_TYPE_VIS promise +class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE promise { __assoc_sub_state* __state_; _LIBCPP_INLINE_VISIBILITY explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {} template friend class packaged_task; public: promise(); template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS promise(allocator_arg_t, const _Allocator& __a); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} promise(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~promise(); // assignment #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY promise& operator=(promise&& __rhs) _NOEXCEPT { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise& __rhs) = delete; #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES private: promise& operator=(const promise& __rhs); public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY void swap(promise& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // retrieving the result future get_future(); // setting the result void set_value(); void set_exception(exception_ptr __p); // setting the result with deferred notification void set_value_at_thread_exit(); void set_exception_at_thread_exit(exception_ptr __p); }; template promise::promise(allocator_arg_t, const _Alloc& __a0) { typedef __assoc_sub_state_alloc<_Alloc> _State; typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2; typedef __allocator_destructor<_A2> _D2; _A2 __a(__a0); unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1)); ::new(static_cast(_VSTD::addressof(*__hold.get()))) _State(__a0); __state_ = _VSTD::addressof(*__hold.release()); } template inline _LIBCPP_INLINE_VISIBILITY void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : public true_type {}; #ifndef _LIBCPP_HAS_NO_VARIADICS // packaged_task template class __packaged_task_base; template -class __packaged_task_base<_Rp(_ArgTypes...)> +class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_base<_Rp(_ArgTypes...)> { __packaged_task_base(const __packaged_task_base&); __packaged_task_base& operator=(const __packaged_task_base&); public: _LIBCPP_INLINE_VISIBILITY __packaged_task_base() {} _LIBCPP_INLINE_VISIBILITY virtual ~__packaged_task_base() {} virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0; virtual void destroy() = 0; virtual void destroy_deallocate() = 0; virtual _Rp operator()(_ArgTypes&& ...) = 0; }; template class __packaged_task_func; template -class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> +class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> { __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY explicit __packaged_task_func(const _Fp& __f) : __f_(__f) {} _LIBCPP_INLINE_VISIBILITY explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f)) {} _LIBCPP_INLINE_VISIBILITY __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} _LIBCPP_INLINE_VISIBILITY __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __f_(_VSTD::move(__f), __a) {} virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT; virtual void destroy(); virtual void destroy_deallocate(); virtual _Rp operator()(_ArgTypes&& ... __args); }; template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to( __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT { ::new (__p) __packaged_task_func(_VSTD::move(__f_.first()), _VSTD::move(__f_.second())); } template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() { __f_.~__compressed_pair<_Fp, _Alloc>(); } template void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() { typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap; typedef allocator_traits<_Ap> _ATraits; typedef pointer_traits _PTraits; _Ap __a(__f_.second()); __f_.~__compressed_pair<_Fp, _Alloc>(); __a.deallocate(_PTraits::pointer_to(*this), 1); } template _Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) { return __invoke(__f_.first(), _VSTD::forward<_ArgTypes>(__arg)...); } template class __packaged_task_function; template -class __packaged_task_function<_Rp(_ArgTypes...)> +class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_function<_Rp(_ArgTypes...)> { typedef __packaged_task_base<_Rp(_ArgTypes...)> __base; typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; public: typedef _Rp result_type; // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY __packaged_task_function() _NOEXCEPT : __f_(nullptr) {} template __packaged_task_function(_Fp&& __f); template __packaged_task_function(allocator_arg_t, const _Alloc& __a, _Fp&& __f); __packaged_task_function(__packaged_task_function&&) _NOEXCEPT; __packaged_task_function& operator=(__packaged_task_function&&) _NOEXCEPT; __packaged_task_function(const __packaged_task_function&) = delete; __packaged_task_function& operator=(const __packaged_task_function&) = delete; ~__packaged_task_function(); void swap(__packaged_task_function&) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _Rp operator()(_ArgTypes...) const; }; template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(__packaged_task_function&& __f) _NOEXCEPT { if (__f.__f_ == nullptr) __f_ = nullptr; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__move_to(__f_); } else { __f_ = __f.__f_; __f.__f_ = nullptr; } } template template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function(_Fp&& __f) : __f_(nullptr) { typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, allocator<_FR>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::forward<_Fp>(__f)); } else { typedef allocator<_FF> _Ap; _Ap __a; typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (__hold.get()) _FF(_VSTD::forward<_Fp>(__f), allocator<_FR>(__a)); __f_ = __hold.release(); } } template template __packaged_task_function<_Rp(_ArgTypes...)>::__packaged_task_function( allocator_arg_t, const _Alloc& __a0, _Fp&& __f) : __f_(nullptr) { typedef typename remove_reference::type>::type _FR; typedef __packaged_task_func<_FR, _Alloc, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) { __f_ = (__base*)&__buf_; ::new (__f_) _FF(_VSTD::forward<_Fp>(__f)); } else { typedef typename __allocator_traits_rebind<_Alloc, _FF>::type _Ap; _Ap __a(__a0); typedef __allocator_destructor<_Ap> _Dp; unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); ::new (static_cast(_VSTD::addressof(*__hold.get()))) _FF(_VSTD::forward<_Fp>(__f), _Alloc(__a)); __f_ = _VSTD::addressof(*__hold.release()); } } template __packaged_task_function<_Rp(_ArgTypes...)>& __packaged_task_function<_Rp(_ArgTypes...)>::operator=(__packaged_task_function&& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); __f_ = nullptr; if (__f.__f_ == nullptr) __f_ = nullptr; else if (__f.__f_ == (__base*)&__f.__buf_) { __f_ = (__base*)&__buf_; __f.__f_->__move_to(__f_); } else { __f_ = __f.__f_; __f.__f_ = nullptr; } return *this; } template __packaged_task_function<_Rp(_ArgTypes...)>::~__packaged_task_function() { if (__f_ == (__base*)&__buf_) __f_->destroy(); else if (__f_) __f_->destroy_deallocate(); } template void __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) _NOEXCEPT { if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) { typename aligned_storage::type __tempbuf; __base* __t = (__base*)&__tempbuf; __f_->__move_to(__t); __f_->destroy(); __f_ = nullptr; __f.__f_->__move_to((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = nullptr; __f_ = (__base*)&__buf_; __t->__move_to((__base*)&__f.__buf_); __t->destroy(); __f.__f_ = (__base*)&__f.__buf_; } else if (__f_ == (__base*)&__buf_) { __f_->__move_to((__base*)&__f.__buf_); __f_->destroy(); __f_ = __f.__f_; __f.__f_ = (__base*)&__f.__buf_; } else if (__f.__f_ == (__base*)&__f.__buf_) { __f.__f_->__move_to((__base*)&__buf_); __f.__f_->destroy(); __f.__f_ = __f_; __f_ = (__base*)&__buf_; } else _VSTD::swap(__f_, __f.__f_); } template inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...); } template -class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task<_Rp(_ArgTypes...)> { public: typedef _Rp result_type; // extension private: __packaged_task_function __f_; promise __p_; public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support _LIBCPP_INLINE_VISIBILITY packaged_task(packaged_task&& __other) _NOEXCEPT : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {} _LIBCPP_INLINE_VISIBILITY packaged_task& operator=(packaged_task&& __other) _NOEXCEPT { __f_ = _VSTD::move(__other.__f_); __p_ = _VSTD::move(__other.__p_); return *this; } _LIBCPP_INLINE_VISIBILITY void swap(packaged_task& __other) _NOEXCEPT { __f_.swap(__other.__f_); __p_.swap(__other.__p_); } _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;} // result retrieval _LIBCPP_INLINE_VISIBILITY future get_future() {return __p_.get_future();} // execution void operator()(_ArgTypes... __args); void make_ready_at_thread_exit(_ArgTypes... __args); void reset(); }; template void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __p_.set_value(__f_(_VSTD::forward<_ArgTypes>(__args)...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __p_.set_value_at_thread_exit(__f_(_VSTD::forward<_ArgTypes>(__args)...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task<_Rp(_ArgTypes...)>::reset() { if (!valid()) __throw_future_error(future_errc::no_state); __p_ = promise(); } template -class _LIBCPP_TEMPLATE_VIS packaged_task +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FUTURE packaged_task { public: typedef void result_type; // extension private: __packaged_task_function __f_; promise __p_; public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} template ::type, packaged_task >::value >::type > _LIBCPP_INLINE_VISIBILITY packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), __p_(allocator_arg, __a) {} // ~packaged_task() = default; // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support _LIBCPP_INLINE_VISIBILITY packaged_task(packaged_task&& __other) _NOEXCEPT : __f_(_VSTD::move(__other.__f_)), __p_(_VSTD::move(__other.__p_)) {} _LIBCPP_INLINE_VISIBILITY packaged_task& operator=(packaged_task&& __other) _NOEXCEPT { __f_ = _VSTD::move(__other.__f_); __p_ = _VSTD::move(__other.__p_); return *this; } _LIBCPP_INLINE_VISIBILITY void swap(packaged_task& __other) _NOEXCEPT { __f_.swap(__other.__f_); __p_.swap(__other.__p_); } _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __p_.__state_ != nullptr;} // result retrieval _LIBCPP_INLINE_VISIBILITY future get_future() {return __p_.get_future();} // execution void operator()(_ArgTypes... __args); void make_ready_at_thread_exit(_ArgTypes... __args); void reset(); }; template void packaged_task::operator()(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __f_(_VSTD::forward<_ArgTypes>(__args)...); __p_.set_value(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task::make_ready_at_thread_exit(_ArgTypes... __args) { if (__p_.__state_ == nullptr) __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS __f_(_VSTD::forward<_ArgTypes>(__args)...); __p_.set_value_at_thread_exit(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } #endif // _LIBCPP_NO_EXCEPTIONS } template void packaged_task::reset() { if (!valid()) __throw_future_error(future_errc::no_state); __p_ = promise(); } template inline _LIBCPP_INLINE_VISIBILITY void swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT { __x.swap(__y); } template struct _LIBCPP_TEMPLATE_VIS uses_allocator, _Alloc> : public true_type {}; template future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_deferred_assoc_state(_Fp&& __f) #else __make_deferred_assoc_state(_Fp __f) #endif { unique_ptr<__deferred_assoc_state<_Rp, _Fp>, __release_shared_count> __h(new __deferred_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f))); return future<_Rp>(__h.get()); } template future<_Rp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __make_async_assoc_state(_Fp&& __f) #else __make_async_assoc_state(_Fp __f) #endif { unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h(new __async_assoc_state<_Rp, _Fp>(_VSTD::forward<_Fp>(__f))); _VSTD::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach(); return future<_Rp>(__h.get()); } template class __async_func { tuple<_Fp, _Args...> __f_; public: typedef typename __invoke_of<_Fp, _Args...>::type _Rp; _LIBCPP_INLINE_VISIBILITY explicit __async_func(_Fp&& __f, _Args&&... __args) : __f_(_VSTD::move(__f), _VSTD::move(__args)...) {} _LIBCPP_INLINE_VISIBILITY __async_func(__async_func&& __f) : __f_(_VSTD::move(__f.__f_)) {} _Rp operator()() { typedef typename __make_tuple_indices<1+sizeof...(_Args), 1>::type _Index; return __execute(_Index()); } private: template _Rp __execute(__tuple_indices<_Indices...>) { return __invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...); } }; inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value ) { return (int(__policy) & int(__value)) != 0; } template future::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif if (__does_policy_contain(__policy, launch::async)) return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); #ifndef _LIBCPP_NO_EXCEPTIONS } catch ( ... ) { if (__policy == launch::async) throw ; } #endif if (__does_policy_contain(__policy, launch::deferred)) return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); return future<_Rp>{}; } template inline _LIBCPP_INLINE_VISIBILITY future::type, typename decay<_Args>::type...>::type> async(_Fp&& __f, _Args&&... __args) { return _VSTD::async(launch::any, _VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...); } #endif // _LIBCPP_HAS_NO_VARIADICS // shared_future template class _LIBCPP_TEMPLATE_VIS shared_future { __assoc_state<_Rp>* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future<_Rp>&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY const _Rp& get() const {return __state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template shared_future<_Rp>::~shared_future() { if (__state_) __state_->__release_shared(); } template shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT { if (__rhs.__state_) __rhs.__state_->__add_shared(); if (__state_) __state_->__release_shared(); __state_ = __rhs.__state_; return *this; } template class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&> { __assoc_state<_Rp&>* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future<_Rp&>&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY _Rp& get() const {return __state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template shared_future<_Rp&>::~shared_future() { if (__state_) __state_->__release_shared(); } template shared_future<_Rp&>& shared_future<_Rp&>::operator=(const shared_future& __rhs) { if (__rhs.__state_) __rhs.__state_->__add_shared(); if (__state_) __state_->__release_shared(); __state_ = __rhs.__state_; return *this; } template <> -class _LIBCPP_TYPE_VIS shared_future +class _LIBCPP_TYPE_VIS _LIBCPP_AVAILABILITY_FUTURE shared_future { __assoc_sub_state* __state_; public: _LIBCPP_INLINE_VISIBILITY shared_future() _NOEXCEPT : __state_(nullptr) {} _LIBCPP_INLINE_VISIBILITY shared_future(const shared_future& __rhs) : __state_(__rhs.__state_) {if (__state_) __state_->__add_shared();} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future(future&& __f) _NOEXCEPT : __state_(__f.__state_) {__f.__state_ = nullptr;} _LIBCPP_INLINE_VISIBILITY shared_future(shared_future&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) {__rhs.__state_ = nullptr;} #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~shared_future(); shared_future& operator=(const shared_future& __rhs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY shared_future& operator=(shared_future&& __rhs) _NOEXCEPT { shared_future(std::move(__rhs)).swap(*this); return *this; } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES // retrieving the value _LIBCPP_INLINE_VISIBILITY void get() const {__state_->copy();} _LIBCPP_INLINE_VISIBILITY void swap(shared_future& __rhs) _NOEXCEPT {_VSTD::swap(__state_, __rhs.__state_);} // functions to check state _LIBCPP_INLINE_VISIBILITY bool valid() const _NOEXCEPT {return __state_ != nullptr;} _LIBCPP_INLINE_VISIBILITY void wait() const {__state_->wait();} template _LIBCPP_INLINE_VISIBILITY future_status wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {return __state_->wait_for(__rel_time);} template _LIBCPP_INLINE_VISIBILITY future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {return __state_->wait_until(__abs_time);} }; template inline _LIBCPP_INLINE_VISIBILITY void swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT { __x.swap(__y); } template inline shared_future<_Rp> future<_Rp>::share() _NOEXCEPT { return shared_future<_Rp>(_VSTD::move(*this)); } template inline shared_future<_Rp&> future<_Rp&>::share() _NOEXCEPT { return shared_future<_Rp&>(_VSTD::move(*this)); } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES inline shared_future future::share() _NOEXCEPT { return shared_future(_VSTD::move(*this)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_END_NAMESPACE_STD #endif // !_LIBCPP_HAS_NO_THREADS #endif // _LIBCPP_FUTURE Index: vendor/libc++/dist/include/istream =================================================================== --- vendor/libc++/dist/include/istream (revision 317954) +++ vendor/libc++/dist/include/istream (revision 317955) @@ -1,1684 +1,1686 @@ // -*- C++ -*- //===--------------------------- istream ----------------------------------===// // // 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_ISTREAM #define _LIBCPP_ISTREAM /* istream synopsis template > class basic_istream : virtual public basic_ios { public: // types (inherited from basic_ios (27.5.4)): typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // 27.7.1.1.1 Constructor/destructor: explicit basic_istream(basic_streambuf* sb); basic_istream(basic_istream&& rhs); virtual ~basic_istream(); // 27.7.1.1.2 Assign/swap: basic_istream& operator=(basic_istream&& rhs); void swap(basic_istream& rhs); // 27.7.1.1.3 Prefix/suffix: class sentry; // 27.7.1.2 Formatted input: basic_istream& operator>>(basic_istream& (*pf)(basic_istream&)); basic_istream& operator>>(basic_ios& (*pf)(basic_ios&)); basic_istream& operator>>(ios_base& (*pf)(ios_base&)); basic_istream& operator>>(basic_streambuf* sb); basic_istream& operator>>(bool& n); basic_istream& operator>>(short& n); basic_istream& operator>>(unsigned short& n); basic_istream& operator>>(int& n); basic_istream& operator>>(unsigned int& n); basic_istream& operator>>(long& n); basic_istream& operator>>(unsigned long& n); basic_istream& operator>>(long long& n); basic_istream& operator>>(unsigned long long& n); basic_istream& operator>>(float& f); basic_istream& operator>>(double& f); basic_istream& operator>>(long double& f); basic_istream& operator>>(void*& p); // 27.7.1.3 Unformatted input: streamsize gcount() const; int_type get(); basic_istream& get(char_type& c); basic_istream& get(char_type* s, streamsize n); basic_istream& get(char_type* s, streamsize n, char_type delim); basic_istream& get(basic_streambuf& sb); basic_istream& get(basic_streambuf& sb, char_type delim); basic_istream& getline(char_type* s, streamsize n); basic_istream& getline(char_type* s, streamsize n, char_type delim); basic_istream& ignore(streamsize n = 1, int_type delim = traits_type::eof()); int_type peek(); basic_istream& read (char_type* s, streamsize n); streamsize readsome(char_type* s, streamsize n); basic_istream& putback(char_type c); basic_istream& unget(); int sync(); pos_type tellg(); basic_istream& seekg(pos_type); basic_istream& seekg(off_type, ios_base::seekdir); protected: basic_istream(const basic_istream& rhs) = delete; basic_istream(basic_istream&& rhs); // 27.7.2.1.2 Assign/swap: basic_istream& operator=(const basic_istream& rhs) = delete; basic_istream& operator=(basic_istream&& rhs); void swap(basic_istream& rhs); }; // 27.7.1.2.3 character extraction templates: template basic_istream& operator>>(basic_istream&, charT&); template basic_istream& operator>>(basic_istream&, unsigned char&); template basic_istream& operator>>(basic_istream&, signed char&); template basic_istream& operator>>(basic_istream&, charT*); template basic_istream& operator>>(basic_istream&, unsigned char*); template basic_istream& operator>>(basic_istream&, signed char*); template void swap(basic_istream& x, basic_istream& y); typedef basic_istream istream; typedef basic_istream wistream; template > class basic_iostream : public basic_istream, public basic_ostream { public: // types: typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // constructor/destructor explicit basic_iostream(basic_streambuf* sb); basic_iostream(basic_iostream&& rhs); virtual ~basic_iostream(); // assign/swap basic_iostream& operator=(basic_iostream&& rhs); void swap(basic_iostream& rhs); }; template void swap(basic_iostream& x, basic_iostream& y); typedef basic_iostream iostream; typedef basic_iostream wiostream; template basic_istream& ws(basic_istream& is); template basic_istream& operator>>(basic_istream&& is, T& x); } // std */ #include <__config> #include #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template class _LIBCPP_TEMPLATE_VIS basic_istream : virtual public basic_ios<_CharT, _Traits> { streamsize __gc_; public: // types (inherited from basic_ios (27.5.4)): typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // 27.7.1.1.1 Constructor/destructor: inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY explicit basic_istream(basic_streambuf* __sb) : __gc_(0) { this->init(__sb); } virtual ~basic_istream(); protected: #ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY basic_istream(basic_istream&& __rhs); // 27.7.1.1.2 Assign/swap: inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator=(basic_istream&& __rhs); #endif inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY void swap(basic_istream& __rhs) { _VSTD::swap(__gc_, __rhs.__gc_); basic_ios::swap(__rhs); } #ifndef _LIBCPP_CXX03_LANG basic_istream (const basic_istream& __rhs) = delete; basic_istream& operator=(const basic_istream& __rhs) = delete; #endif public: // 27.7.1.1.3 Prefix/suffix: class _LIBCPP_TEMPLATE_VIS sentry; // 27.7.1.2 Formatted input: inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) { return __pf(*this); } inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& operator>>(basic_ios& (*__pf)(basic_ios&)) { __pf(*this); return *this; } inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& operator>>(ios_base& (*__pf)(ios_base&)) { __pf(*this); return *this; } basic_istream& operator>>(basic_streambuf* __sb); basic_istream& operator>>(bool& __n); basic_istream& operator>>(short& __n); basic_istream& operator>>(unsigned short& __n); basic_istream& operator>>(int& __n); basic_istream& operator>>(unsigned int& __n); basic_istream& operator>>(long& __n); basic_istream& operator>>(unsigned long& __n); basic_istream& operator>>(long long& __n); basic_istream& operator>>(unsigned long long& __n); basic_istream& operator>>(float& __f); basic_istream& operator>>(double& __f); basic_istream& operator>>(long double& __f); basic_istream& operator>>(void*& __p); // 27.7.1.3 Unformatted input: _LIBCPP_INLINE_VISIBILITY streamsize gcount() const {return __gc_;} int_type get(); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& get(char_type& __c) { int_type __ch = get(); if (__ch != traits_type::eof()) __c = traits_type::to_char_type(__ch); return *this; } inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& get(char_type* __s, streamsize __n) { return get(__s, __n, this->widen('\n')); } basic_istream& get(char_type* __s, streamsize __n, char_type __dlm); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& get(basic_streambuf& __sb) { return get(__sb, this->widen('\n')); } basic_istream& get(basic_streambuf& __sb, char_type __dlm); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY basic_istream& getline(char_type* __s, streamsize __n) { return getline(__s, __n, this->widen('\n')); } basic_istream& getline(char_type* __s, streamsize __n, char_type __dlm); basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); int_type peek(); basic_istream& read (char_type* __s, streamsize __n); streamsize readsome(char_type* __s, streamsize __n); basic_istream& putback(char_type __c); basic_istream& unget(); int sync(); pos_type tellg(); basic_istream& seekg(pos_type __pos); basic_istream& seekg(off_type __off, ios_base::seekdir __dir); }; template class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry { bool __ok_; sentry(const sentry&); // = delete; sentry& operator=(const sentry&); // = delete; public: explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); // ~sentry() = default; _LIBCPP_INLINE_VISIBILITY _LIBCPP_EXPLICIT operator bool() const {return __ok_;} }; template basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws) : __ok_(false) { if (__is.good()) { if (__is.tie()) __is.tie()->flush(); if (!__noskipws && (__is.flags() & ios_base::skipws)) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); _Ip __i(__is); _Ip __eof; for (; __i != __eof; ++__i) if (!__ct.is(__ct.space, *__i)) break; if (__i == __eof) __is.setstate(ios_base::failbit | ios_base::eofbit); } __ok_ = __is.good(); } else __is.setstate(ios_base::failbit); } #ifndef _LIBCPP_CXX03_LANG template basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) : __gc_(__rhs.__gc_) { __rhs.__gc_ = 0; this->move(__rhs); } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) { swap(__rhs); return *this; } #endif // _LIBCPP_CXX03_LANG template basic_istream<_CharT, _Traits>::~basic_istream() { } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned int& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(unsigned long long& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(float& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(double& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(long double& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(bool& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(void*& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __n); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(short& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; __n = numeric_limits::min(); } else if (__temp > numeric_limits::max()) { __err |= ios_base::failbit; __n = numeric_limits::max(); } else __n = static_cast(__temp); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(int& __n) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this); if (__s) { typedef istreambuf_iterator _Ip; typedef num_get _Fp; ios_base::iostate __err = ios_base::goodbit; long __temp; use_facet<_Fp>(this->getloc()).get(_Ip(*this), _Ip(), *this, __err, __temp); if (__temp < numeric_limits::min()) { __err |= ios_base::failbit; __n = numeric_limits::min(); } else if (__temp > numeric_limits::max()) { __err |= ios_base::failbit; __n = numeric_limits::max(); } else __n = static_cast(__temp); this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { streamsize __n = __is.width(); if (__n <= 0) __n = numeric_limits::max() / sizeof(_CharT) - 1; streamsize __c = 0; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); ios_base::iostate __err = ios_base::goodbit; while (__c < __n-1) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (__ct.is(__ct.space, __ch)) break; *__s++ = __ch; ++__c; __is.rdbuf()->sbumpc(); } *__s = _CharT(); __is.width(0); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char* __s) { return __is >> (char*)__s; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char* __s) { return __is >> (char*)__s; } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) __is.setstate(ios_base::eofbit | ios_base::failbit); else __c = _Traits::to_char_type(__i); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char& __c) { return __is >> (char&)__c; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char& __c) { return __is >> (char&)__c; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_streambuf* __sb) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this, true); if (__s) { if (__sb) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS ios_base::iostate __err = ios_base::goodbit; while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } if (traits_type::eq_int_type( __sb->sputc(traits_type::to_char_type(__i)), traits_type::eof())) break; ++__gc_; this->rdbuf()->sbumpc(); } if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { if (__gc_ == 0) this->__set_failbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS } else this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::get() { __gc_ = 0; int_type __r = traits_type::eof(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __s(*this, true); if (__s) { __r = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__r, traits_type::eof())) this->setstate(ios_base::failbit | ios_base::eofbit); else __gc_ = 1; } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { if (__n > 0) { ios_base::iostate __err = ios_base::goodbit; while (__gc_ < __n-1) { int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) break; *__s++ = __ch; ++__gc_; this->rdbuf()->sbumpc(); } *__s = char_type(); if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } else this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(basic_streambuf& __sb, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) break; if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof())) break; ++__gc_; this->rdbuf()->sbumpc(); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { } #endif // _LIBCPP_NO_EXCEPTIONS if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } char_type __ch = traits_type::to_char_type(__i); if (traits_type::eq(__ch, __dlm)) { this->rdbuf()->sbumpc(); ++__gc_; break; } if (__gc_ >= __n-1) { __err |= ios_base::failbit; break; } *__s++ = __ch; this->rdbuf()->sbumpc(); ++__gc_; } if (__n > 0) *__s = char_type(); if (__gc_ == 0) __err |= ios_base::failbit; this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { ios_base::iostate __err = ios_base::goodbit; if (__n == numeric_limits::max()) { while (true) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } ++__gc_; if (traits_type::eq_int_type(__i, __dlm)) break; } } else { while (__gc_ < __n) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { __err |= ios_base::eofbit; break; } ++__gc_; if (traits_type::eq_int_type(__i, __dlm)) break; } } this->setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>::peek() { __gc_ = 0; int_type __r = traits_type::eof(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { __r = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__r, traits_type::eof())) this->setstate(ios_base::eofbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { __gc_ = this->rdbuf()->sgetn(__s, __n); if (__gc_ != __n) this->setstate(ios_base::failbit | ios_base::eofbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { streamsize __c = this->rdbuf()->in_avail(); switch (__c) { case -1: this->setstate(ios_base::eofbit); break; case 0: break; default: read(__s, _VSTD::min(__c, __n)); break; } } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __gc_; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_type __c) { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof()) this->setstate(ios_base::badbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { __gc_ = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof()) this->setstate(ios_base::badbit); } else this->setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template int basic_istream<_CharT, _Traits>::sync() { int __r = 0; #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) { if (this->rdbuf() == 0) return -1; if (this->rdbuf()->pubsync() == -1) { this->setstate(ios_base::badbit); return -1; } } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>::tellg() { pos_type __r(-1); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __r; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type __pos) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return *this; } template basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _Traits>& __is) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { const ctype<_CharT>& __ct = use_facet >(__is.getloc()); while (true) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __is.setstate(ios_base::eofbit); break; } if (!__ct.is(__ct.space, _Traits::to_char_type(__i))) break; __is.rdbuf()->sbumpc(); } } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x) { __is >> _VSTD::forward<_Tp>(__x); return __is; } #endif // _LIBCPP_CXX03_LANG template class _LIBCPP_TEMPLATE_VIS basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { public: // types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // constructor/destructor inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY explicit basic_iostream(basic_streambuf* __sb) : basic_istream<_CharT, _Traits>(__sb) {} virtual ~basic_iostream(); protected: #ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY basic_iostream(basic_iostream&& __rhs); // assign/swap inline _LIBCPP_INLINE_VISIBILITY basic_iostream& operator=(basic_iostream&& __rhs); #endif inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY void swap(basic_iostream& __rhs) { basic_istream::swap(__rhs); } public: }; #ifndef _LIBCPP_CXX03_LANG template basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) { } template basic_iostream<_CharT, _Traits>& basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) { swap(__rhs); return *this; } #endif // _LIBCPP_CXX03_LANG template basic_iostream<_CharT, _Traits>::~basic_iostream() { } template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { __str.clear(); streamsize __n = __is.width(); if (__n <= 0) __n = __str.max_size(); if (__n <= 0) __n = numeric_limits::max(); streamsize __c = 0; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); ios_base::iostate __err = ios_base::goodbit; while (__c < __n) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (__ct.is(__ct.space, __ch)) break; __str.push_back(__ch); ++__c; __is.rdbuf()->sbumpc(); } __is.width(0); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } else __is.setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { __str.clear(); ios_base::iostate __err = ios_base::goodbit; streamsize __extr = 0; while (true) { typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } ++__extr; _CharT __ch = _Traits::to_char_type(__i); if (_Traits::eq(__ch, __dlm)) break; __str.push_back(__ch); if (__str.size() == __str.max_size()) { __err |= ios_base::failbit; break; } } if (__extr == 0) __err |= ios_base::failbit; __is.setstate(__err); } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { return getline(__is, __str, __is.widen('\n')); } #ifndef _LIBCPP_CXX03_LANG template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) { return getline(__is, __str, __dlm); } template inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str) { return getline(__is, __str, __is.widen('\n')); } #endif // _LIBCPP_CXX03_LANG template basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { basic_string<_CharT, _Traits> __str; const ctype<_CharT>& __ct = use_facet >(__is.getloc()); size_t __c = 0; ios_base::iostate __err = ios_base::goodbit; _CharT __zero = __ct.widen('0'); _CharT __one = __ct.widen('1'); while (__c < _Size) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); if (_Traits::eq_int_type(__i, _Traits::eof())) { __err |= ios_base::eofbit; break; } _CharT __ch = _Traits::to_char_type(__i); if (!_Traits::eq(__ch, __zero) && !_Traits::eq(__ch, __one)) break; __str.push_back(__ch); ++__c; __is.rdbuf()->sbumpc(); } __x = bitset<_Size>(__str); if (__c == 0) __err |= ios_base::failbit; __is.setstate(__err); } else __is.setstate(ios_base::failbit); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } #endif // _LIBCPP_NO_EXCEPTIONS return __is; } +#ifndef _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream) +#endif _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ISTREAM Index: vendor/libc++/dist/include/locale =================================================================== --- vendor/libc++/dist/include/locale (revision 317954) +++ vendor/libc++/dist/include/locale (revision 317955) @@ -1,4260 +1,4280 @@ // -*- C++ -*- //===-------------------------- locale ------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_LOCALE #define _LIBCPP_LOCALE /* locale synopsis namespace std { class locale { public: // types: class facet; class id; typedef int category; static const category // values assigned here are for exposition only none = 0x000, collate = 0x010, ctype = 0x020, monetary = 0x040, numeric = 0x080, time = 0x100, messages = 0x200, all = collate | ctype | monetary | numeric | time | messages; // construct/copy/destroy: locale() noexcept; locale(const locale& other) noexcept; explicit locale(const char* std_name); explicit locale(const string& std_name); locale(const locale& other, const char* std_name, category); locale(const locale& other, const string& std_name, category); template locale(const locale& other, Facet* f); locale(const locale& other, const locale& one, category); ~locale(); // not virtual const locale& operator=(const locale& other) noexcept; template locale combine(const locale& other) const; // locale operations: basic_string name() const; bool operator==(const locale& other) const; bool operator!=(const locale& other) const; template bool operator()(const basic_string& s1, const basic_string& s2) const; // global locale objects: static locale global(const locale&); static const locale& classic(); }; template const Facet& use_facet(const locale&); template bool has_facet(const locale&) noexcept; // 22.3.3, convenience interfaces: template bool isspace (charT c, const locale& loc); template bool isprint (charT c, const locale& loc); template bool iscntrl (charT c, const locale& loc); template bool isupper (charT c, const locale& loc); template bool islower (charT c, const locale& loc); template bool isalpha (charT c, const locale& loc); template bool isdigit (charT c, const locale& loc); template bool ispunct (charT c, const locale& loc); template bool isxdigit(charT c, const locale& loc); template bool isalnum (charT c, const locale& loc); template bool isgraph (charT c, const locale& loc); template charT toupper(charT c, const locale& loc); template charT tolower(charT c, const locale& loc); template, class Byte_alloc = allocator> class wstring_convert { public: typedef basic_string, Byte_alloc> byte_string; typedef basic_string, Wide_alloc> wide_string; typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 wstring_convert(Codecvt* pcvt, state_type state); explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); wstring_convert(const wstring_convert&) = delete; // C++14 wstring_convert & operator=(const wstring_convert &) = delete; // C++14 ~wstring_convert(); wide_string from_bytes(char byte); wide_string from_bytes(const char* ptr); wide_string from_bytes(const byte_string& str); wide_string from_bytes(const char* first, const char* last); byte_string to_bytes(Elem wchar); byte_string to_bytes(const Elem* wptr); byte_string to_bytes(const wide_string& wstr); byte_string to_bytes(const Elem* first, const Elem* last); size_t converted() const; // noexcept in C++14 state_type state() const; }; template > class wbuffer_convert : public basic_streambuf { public: typedef typename Tr::state_type state_type; explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, state_type state = state_type()); // explicit in C++14 wbuffer_convert(const wbuffer_convert&) = delete; // C++14 wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 ~wbuffer_convert(); // C++14 streambuf* rdbuf() const; streambuf* rdbuf(streambuf* bytebuf); state_type state() const; }; // 22.4.1 and 22.4.1.3, ctype: class ctype_base; template class ctype; template <> class ctype; // specialization template class ctype_byname; template <> class ctype_byname; // specialization class codecvt_base; template class codecvt; template class codecvt_byname; // 22.4.2 and 22.4.3, numeric: template class num_get; template class num_put; template class numpunct; template class numpunct_byname; // 22.4.4, col lation: template class collate; template class collate_byname; // 22.4.5, date and time: class time_base; template class time_get; template class time_get_byname; template class time_put; template class time_put_byname; // 22.4.6, money: class money_base; template class money_get; template class money_put; template class moneypunct; template class moneypunct_byname; // 22.4.7, message retrieval: class messages_base; template class messages; template class messages_byname; } // std */ #include <__config> #include <__locale> #include <__debug> #include #include #include #include #include #include #ifndef __APPLE__ #include #endif #include #include #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include #elif defined(_NEWLIB_VERSION) // FIXME: replace all the uses of _NEWLIB_VERSION with __NEWLIB__ preceded by an // include of once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html // has had a chance to bake for a bit #include #endif #ifdef _LIBCPP_HAS_CATOPEN #include #endif #ifdef __APPLE__ #include #endif #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif #ifdef _LIBCPP_LOCALE__L_EXTENSIONS #include <__bsd_locale_defaults.h> #else #include <__bsd_locale_fallbacks.h> #endif _LIBCPP_BEGIN_NAMESPACE_STD #if defined(__APPLE__) || defined(__FreeBSD__) # define _LIBCPP_GET_C_LOCALE 0 #elif defined(__CloudABI__) || defined(__NetBSD__) # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE #else # define _LIBCPP_GET_C_LOCALE __cloc() // Get the C locale object _LIBCPP_FUNC_VIS locale_t __cloc(); #define __cloc_defined #endif typedef _VSTD::remove_pointer::type __locale_struct; typedef _VSTD::unique_ptr<__locale_struct, decltype(&freelocale)> __locale_unique_ptr; // __scan_keyword // Scans [__b, __e) until a match is found in the basic_strings range // [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke). // __b will be incremented (visibly), consuming CharT until a match is found // or proved to not exist. A keyword may be "", in which will match anything. // If one keyword is a prefix of another, and the next CharT in the input // might match another keyword, the algorithm will attempt to find the longest // matching keyword. If the longer matching keyword ends up not matching, then // no keyword match is found. If no keyword match is found, __ke is returned // and failbit is set in __err. // Else an iterator pointing to the matching keyword is found. If more than // one keyword matches, an iterator to the first matching keyword is returned. // If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, // __ct is used to force to lower case before comparing characters. // Examples: // Keywords: "a", "abb" // If the input is "a", the first keyword matches and eofbit is set. // If the input is "abc", no match is found and "ab" are consumed. template _LIBCPP_HIDDEN _ForwardIterator __scan_keyword(_InputIterator& __b, _InputIterator __e, _ForwardIterator __kb, _ForwardIterator __ke, const _Ctype& __ct, ios_base::iostate& __err, bool __case_sensitive = true) { typedef typename iterator_traits<_InputIterator>::value_type _CharT; size_t __nkw = static_cast(_VSTD::distance(__kb, __ke)); const unsigned char __doesnt_match = '\0'; const unsigned char __might_match = '\1'; const unsigned char __does_match = '\2'; unsigned char __statbuf[100]; unsigned char* __status = __statbuf; unique_ptr __stat_hold(0, free); if (__nkw > sizeof(__statbuf)) { __status = (unsigned char*)malloc(__nkw); if (__status == 0) __throw_bad_alloc(); __stat_hold.reset(__status); } size_t __n_might_match = __nkw; // At this point, any keyword might match size_t __n_does_match = 0; // but none of them definitely do // Initialize all statuses to __might_match, except for "" keywords are __does_match unsigned char* __st = __status; for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (!__ky->empty()) *__st = __might_match; else { *__st = __does_match; --__n_might_match; ++__n_does_match; } } // While there might be a match, test keywords against the next CharT for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx) { // Peek at the next CharT but don't consume it _CharT __c = *__b; if (!__case_sensitive) __c = __ct.toupper(__c); bool __consume = false; // For each keyword which might match, see if the __indx character is __c // If a match if found, consume __c // If a match is found, and that is the last character in the keyword, // then that keyword matches. // If the keyword doesn't match this character, then change the keyword // to doesn't match __st = __status; for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (*__st == __might_match) { _CharT __kc = (*__ky)[__indx]; if (!__case_sensitive) __kc = __ct.toupper(__kc); if (__c == __kc) { __consume = true; if (__ky->size() == __indx+1) { *__st = __does_match; --__n_might_match; ++__n_does_match; } } else { *__st = __doesnt_match; --__n_might_match; } } } // consume if we matched a character if (__consume) { ++__b; // If we consumed a character and there might be a matched keyword that // was marked matched on a previous iteration, then such keywords // which are now marked as not matching. if (__n_might_match + __n_does_match > 1) { __st = __status; for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void) ++__st) { if (*__st == __does_match && __ky->size() != __indx+1) { *__st = __doesnt_match; --__n_does_match; } } } } } // We've exited the loop because we hit eof and/or we have no more "might matches". if (__b == __e) __err |= ios_base::eofbit; // Return the first matching result for (__st = __status; __kb != __ke; ++__kb, (void) ++__st) if (*__st == __does_match) break; if (__kb == __ke) __err |= ios_base::failbit; return __kb; } struct _LIBCPP_TYPE_VIS __num_get_base { static const int __num_get_buf_sz = 40; static int __get_base(ios_base&); static const char __src[33]; }; _LIBCPP_FUNC_VIS void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err); template struct __num_get : protected __num_get_base { static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep); static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, _CharT* __atoms); static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp, char* __a, char*& __a_end, _CharT __decimal_point, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* __atoms); }; template string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); use_facet >(__loc).widen(__src, __src + 26, __atoms); const numpunct<_CharT>& __np = use_facet >(__loc); __thousands_sep = __np.thousands_sep(); return __np.grouping(); } template string __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) { locale __loc = __iob.getloc(); use_facet >(__loc).widen(__src, __src + 32, __atoms); const numpunct<_CharT>& __np = use_facet >(__loc); __decimal_point = __np.decimal_point(); __thousands_sep = __np.thousands_sep(); return __np.grouping(); } template int __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, unsigned& __dc, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, _CharT* __atoms) { if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { *__a_end++ = __ct == __atoms[24] ? '+' : '-'; __dc = 0; return 0; } if (__grouping.size() != 0 && __ct == __thousands_sep) { if (__g_end-__g < __num_get_buf_sz) { *__g_end++ = __dc; __dc = 0; } return 0; } ptrdiff_t __f = find(__atoms, __atoms + 26, __ct) - __atoms; if (__f >= 24) return -1; switch (__base) { case 8: case 10: if (__f >= __base) return -1; break; case 16: if (__f < 22) break; if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') { __dc = 0; *__a_end++ = __src[__f]; return 0; } return -1; } *__a_end++ = __src[__f]; ++__dc; return 0; } template int __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp, char* __a, char*& __a_end, _CharT __decimal_point, _CharT __thousands_sep, const string& __grouping, unsigned* __g, unsigned*& __g_end, unsigned& __dc, _CharT* __atoms) { if (__ct == __decimal_point) { if (!__in_units) return -1; __in_units = false; *__a_end++ = '.'; if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz) *__g_end++ = __dc; return 0; } if (__ct == __thousands_sep && __grouping.size() != 0) { if (!__in_units) return -1; if (__g_end-__g < __num_get_buf_sz) { *__g_end++ = __dc; __dc = 0; } return 0; } ptrdiff_t __f = find(__atoms, __atoms + 32, __ct) - __atoms; if (__f >= 32) return -1; char __x = __src[__f]; if (__x == '-' || __x == '+') { if (__a_end == __a || (__a_end[-1] & 0x5F) == (__exp & 0x7F)) { *__a_end++ = __x; return 0; } return -1; } if (__x == 'x' || __x == 'X') __exp = 'P'; else if ((__x & 0x5F) == __exp) { __exp |= 0x80; if (__in_units) { __in_units = false; if (__grouping.size() != 0 && __g_end-__g < __num_get_buf_sz) *__g_end++ = __dc; } } *__a_end++ = __x; if (__f >= 22) return 0; ++__dc; return 0; } _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get) template > class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { public: typedef _CharT char_type; typedef _InputIterator iter_type; _LIBCPP_ALWAYS_INLINE explicit num_get(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { return do_get(__b, __e, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { return do_get(__b, __e, __iob, __err, __v); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~num_get() {} template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type __do_get_floating_point (iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type __do_get_signed (iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const; template _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type __do_get_unsigned (iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const; virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; }; template locale::id num_get<_CharT, _InputIterator>::id; template _Tp __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { if (__a != __a_end) { typename remove_reference::type __save_errno = errno; errno = 0; char *__p2; long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); typename remove_reference::type __current_errno = errno; if (__current_errno == 0) errno = __save_errno; if (__p2 != __a_end) { __err = ios_base::failbit; return 0; } else if (__current_errno == ERANGE || __ll < numeric_limits<_Tp>::min() || numeric_limits<_Tp>::max() < __ll) { __err = ios_base::failbit; if (__ll > 0) return numeric_limits<_Tp>::max(); else return numeric_limits<_Tp>::min(); } return static_cast<_Tp>(__ll); } __err = ios_base::failbit; return 0; } template _Tp __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) { if (__a != __a_end) { if (*__a == '-') { __err = ios_base::failbit; return 0; } typename remove_reference::type __save_errno = errno; errno = 0; char *__p2; unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); typename remove_reference::type __current_errno = errno; if (__current_errno == 0) errno = __save_errno; if (__p2 != __a_end) { __err = ios_base::failbit; return 0; } else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll) { __err = ios_base::failbit; return numeric_limits<_Tp>::max(); } return static_cast<_Tp>(__ll); } __err = ios_base::failbit; return 0; } template _LIBCPP_INLINE_VISIBILITY _Tp __do_strtod(const char* __a, char** __p2); template <> inline _LIBCPP_INLINE_VISIBILITY float __do_strtod(const char* __a, char** __p2) { return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE); } template <> inline _LIBCPP_INLINE_VISIBILITY double __do_strtod(const char* __a, char** __p2) { return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE); } template <> inline _LIBCPP_INLINE_VISIBILITY long double __do_strtod(const char* __a, char** __p2) { return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE); } template _LIBCPP_HIDDEN _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) { if (__a != __a_end) { typename remove_reference::type __save_errno = errno; errno = 0; char *__p2; _Tp __ld = __do_strtod<_Tp>(__a, &__p2); typename remove_reference::type __current_errno = errno; if (__current_errno == 0) errno = __save_errno; if (__p2 != __a_end) { __err = ios_base::failbit; return 0; } else if (__current_errno == ERANGE) __err = ios_base::failbit; return __ld; } __err = ios_base::failbit; return 0; } template _InputIterator num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const { if ((__iob.flags() & ios_base::boolalpha) == 0) { long __lv = -1; __b = do_get(__b, __e, __iob, __err, __lv); switch (__lv) { case 0: __v = false; break; case 1: __v = true; break; default: __v = true; __err = ios_base::failbit; break; } return __b; } const ctype<_CharT>& __ct = use_facet >(__iob.getloc()); const numpunct<_CharT>& __np = use_facet >(__iob.getloc()); typedef typename numpunct<_CharT>::string_type string_type; const string_type __names[2] = {__np.truename(), __np.falsename()}; const string_type* __i = __scan_keyword(__b, __e, __names, __names+2, __ct, __err); __v = __i == __names; return __b; } // signed template template _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const { // Stage 1 int __base = this->__get_base(__iob); // Stage 2 char_type __atoms[26]; char_type __thousands_sep; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; char* __a_end = __a; unsigned __g[__num_get_base::__num_get_buf_sz]; unsigned* __g_end = __g; unsigned __dc = 0; for (; __b != __e; ++__b) { if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); __buf.resize(__buf.capacity()); __a = &__buf[0]; __a_end = __a + __tmp; } if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) break; } if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked if (__b == __e) __err |= ios_base::eofbit; return __b; } // unsigned template template _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const { // Stage 1 int __base = this->__get_base(__iob); // Stage 2 char_type __atoms[26]; char_type __thousands_sep; string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; char* __a_end = __a; unsigned __g[__num_get_base::__num_get_buf_sz]; unsigned* __g_end = __g; unsigned __dc = 0; for (; __b != __e; ++__b) { if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); __buf.resize(__buf.capacity()); __a = &__buf[0]; __a_end = __a + __tmp; } if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) break; } if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked if (__b == __e) __err |= ios_base::eofbit; return __b; } // floating point template template _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const { // Stage 1, nothing to do // Stage 2 char_type __atoms[32]; char_type __decimal_point; char_type __thousands_sep; string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep); string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; char* __a_end = __a; unsigned __g[__num_get_base::__num_get_buf_sz]; unsigned* __g_end = __g; unsigned __dc = 0; bool __in_units = true; char __exp = 'E'; for (; __b != __e; ++__b) { if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); __buf.resize(__buf.capacity()); __a = &__buf[0]; __a_end = __a + __tmp; } if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, __decimal_point, __thousands_sep, __grouping, __g, __g_end, __dc, __atoms)) break; } if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 __v = __num_get_float<_Fp>(__a, __a_end, __err); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked if (__b == __e) __err |= ios_base::eofbit; return __b; } template _InputIterator num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const { // Stage 1 int __base = 16; // Stage 2 char_type __atoms[26]; char_type __thousands_sep = 0; string __grouping; use_facet >(__iob.getloc()).widen(__num_get_base::__src, __num_get_base::__src + 26, __atoms); string __buf; __buf.resize(__buf.capacity()); char* __a = &__buf[0]; char* __a_end = __a; unsigned __g[__num_get_base::__num_get_buf_sz]; unsigned* __g_end = __g; unsigned __dc = 0; for (; __b != __e; ++__b) { if (__a_end == __a + __buf.size()) { size_t __tmp = __buf.size(); __buf.resize(2*__buf.size()); __buf.resize(__buf.capacity()); __a = &__buf[0]; __a_end = __a + __tmp; } if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms)) break; } // Stage 3 __buf.resize(__a_end - __a); if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) __err = ios_base::failbit; // EOF checked if (__b == __e) __err |= ios_base::eofbit; return __b; } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get) struct _LIBCPP_TYPE_VIS __num_put_base { protected: static void __format_int(char* __fmt, const char* __len, bool __signd, ios_base::fmtflags __flags); static bool __format_float(char* __fmt, const char* __len, ios_base::fmtflags __flags); static char* __identify_padding(char* __nb, char* __ne, const ios_base& __iob); }; template struct __num_put : protected __num_put_base { static void __widen_and_group_int(char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); static void __widen_and_group_float(char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc); }; template void __num_put<_CharT>::__widen_and_group_int(char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { const ctype<_CharT>& __ct = use_facet > (__loc); const numpunct<_CharT>& __npt = use_facet >(__loc); string __grouping = __npt.grouping(); if (__grouping.empty()) { __ct.widen(__nb, __ne, __ob); __oe = __ob + (__ne - __nb); } else { __oe = __ob; char* __nf = __nb; if (*__nf == '-' || *__nf == '+') *__oe++ = __ct.widen(*__nf++); if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { *__oe++ = __ct.widen(*__nf++); *__oe++ = __ct.widen(*__nf++); } reverse(__nf, __ne); _CharT __thousands_sep = __npt.thousands_sep(); unsigned __dc = 0; unsigned __dg = 0; for (char* __p = __nf; __p < __ne; ++__p) { if (static_cast(__grouping[__dg]) > 0 && __dc == static_cast(__grouping[__dg])) { *__oe++ = __thousands_sep; __dc = 0; if (__dg < __grouping.size()-1) ++__dg; } *__oe++ = __ct.widen(*__p); ++__dc; } reverse(__ob + (__nf - __nb), __oe); } if (__np == __ne) __op = __oe; else __op = __ob + (__np - __nb); } template void __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) { const ctype<_CharT>& __ct = use_facet > (__loc); const numpunct<_CharT>& __npt = use_facet >(__loc); string __grouping = __npt.grouping(); __oe = __ob; char* __nf = __nb; if (*__nf == '-' || *__nf == '+') *__oe++ = __ct.widen(*__nf++); char* __ns; if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) { *__oe++ = __ct.widen(*__nf++); *__oe++ = __ct.widen(*__nf++); for (__ns = __nf; __ns < __ne; ++__ns) if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE)) break; } else { for (__ns = __nf; __ns < __ne; ++__ns) if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE)) break; } if (__grouping.empty()) { __ct.widen(__nf, __ns, __oe); __oe += __ns - __nf; } else { reverse(__nf, __ns); _CharT __thousands_sep = __npt.thousands_sep(); unsigned __dc = 0; unsigned __dg = 0; for (char* __p = __nf; __p < __ns; ++__p) { if (__grouping[__dg] > 0 && __dc == static_cast(__grouping[__dg])) { *__oe++ = __thousands_sep; __dc = 0; if (__dg < __grouping.size()-1) ++__dg; } *__oe++ = __ct.widen(*__p); ++__dc; } reverse(__ob + (__nf - __nb), __oe); } for (__nf = __ns; __nf < __ne; ++__nf) { if (*__nf == '.') { *__oe++ = __npt.decimal_point(); ++__nf; break; } else *__oe++ = __ct.widen(*__nf); } __ct.widen(__nf, __ne, __oe); __oe += __ne - __nf; if (__np == __ne) __op = __oe; else __op = __ob + (__np - __nb); } _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put) template > class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { public: typedef _CharT char_type; typedef _OutputIterator iter_type; _LIBCPP_ALWAYS_INLINE explicit num_put(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { return do_put(__s, __iob, __fl, __v); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { return do_put(__s, __iob, __fl, __v); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~num_put() {} virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const; }; template locale::id num_put<_CharT, _OutputIterator>::id; template _LIBCPP_HIDDEN _OutputIterator __pad_and_output(_OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) { streamsize __sz = __oe - __ob; streamsize __ns = __iob.width(); if (__ns > __sz) __ns -= __sz; else __ns = 0; for (;__ob < __op; ++__ob, ++__s) *__s = *__ob; for (; __ns; --__ns, ++__s) *__s = __fl; for (; __ob < __oe; ++__ob, ++__s) *__s = *__ob; __iob.width(0); return __s; } #if !defined(__APPLE__) || \ (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0) template _LIBCPP_HIDDEN ostreambuf_iterator<_CharT, _Traits> __pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) { if (__s.__sbuf_ == nullptr) return __s; streamsize __sz = __oe - __ob; streamsize __ns = __iob.width(); if (__ns > __sz) __ns -= __sz; else __ns = 0; streamsize __np = __op - __ob; if (__np > 0) { if (__s.__sbuf_->sputn(__ob, __np) != __np) { __s.__sbuf_ = nullptr; return __s; } } if (__ns > 0) { basic_string<_CharT, _Traits> __sp(__ns, __fl); if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) { __s.__sbuf_ = nullptr; return __s; } } __np = __oe - __op; if (__np > 0) { if (__s.__sbuf_->sputn(__op, __np) != __np) { __s.__sbuf_ = nullptr; return __s; } } __iob.width(0); return __s; } #endif template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { if ((__iob.flags() & ios_base::boolalpha) == 0) return do_put(__s, __iob, __fl, (unsigned long)__v); const numpunct& __np = use_facet >(__iob.getloc()); typedef typename numpunct::string_type string_type; #if _LIBCPP_DEBUG_LEVEL >= 2 string_type __tmp(__v ? __np.truename() : __np.falsename()); string_type __nm = _VSTD::move(__tmp); #else string_type __nm = __v ? __np.truename() : __np.falsename(); #endif for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) *__s = *__i; return __s; } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const { // Stage 1 - Get number in narrow char char __fmt[6] = {'%', 0}; const char* __len = "l"; this->__format_int(__fmt+1, __len, true, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 2; char __nar[__nbuf]; int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { // Stage 1 - Get number in narrow char char __fmt[8] = {'%', 0}; const char* __len = "ll"; this->__format_int(__fmt+1, __len, true, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 2; char __nar[__nbuf]; int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { // Stage 1 - Get number in narrow char char __fmt[6] = {'%', 0}; const char* __len = "l"; this->__format_int(__fmt+1, __len, false, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 1; char __nar[__nbuf]; int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { // Stage 1 - Get number in narrow char char __fmt[8] = {'%', 0}; const char* __len = "ll"; this->__format_int(__fmt+1, __len, false, __iob.flags()); const unsigned __nbuf = (numeric_limits::digits / 3) + ((numeric_limits::digits % 3) != 0) + + ((__iob.flags() & ios_base::showbase) != 0) + 1; char __nar[__nbuf]; int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const { // Stage 1 - Get number in narrow char char __fmt[8] = {'%', 0}; const char* __len = ""; bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); const unsigned __nbuf = 30; char __nar[__nbuf]; char* __nb = __nar; int __nc; if (__specify_precision) __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); unique_ptr __nbh(0, free); if (__nc > static_cast(__nbuf-1)) { if (__specify_precision) __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); if (__nb == 0) __throw_bad_alloc(); __nbh.reset(__nb); } char* __ne = __nb + __nc; char* __np = this->__identify_padding(__nb, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __ob = __o; unique_ptr __obh(0, free); if (__nb != __nar) { __ob = (char_type*)malloc(2*static_cast(__nc)*sizeof(char_type)); if (__ob == 0) __throw_bad_alloc(); __obh.reset(__ob); } char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl); return __s; } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { // Stage 1 - Get number in narrow char char __fmt[8] = {'%', 0}; const char* __len = "L"; bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); const unsigned __nbuf = 30; char __nar[__nbuf]; char* __nb = __nar; int __nc; if (__specify_precision) __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); unique_ptr __nbh(0, free); if (__nc > static_cast(__nbuf-1)) { if (__specify_precision) __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); else __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); if (__nb == 0) __throw_bad_alloc(); __nbh.reset(__nb); } char* __ne = __nb + __nc; char* __np = this->__identify_padding(__nb, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators char_type __o[2*(__nbuf-1) - 1]; char_type* __ob = __o; unique_ptr __obh(0, free); if (__nb != __nar) { __ob = (char_type*)malloc(2*static_cast(__nc)*sizeof(char_type)); if (__ob == 0) __throw_bad_alloc(); __obh.reset(__ob); } char_type* __op; // pad here char_type* __oe; // end of output this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); // [__o, __oe) contains thousands_sep'd wide number // Stage 3 & 4 __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl); return __s; } template _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { // Stage 1 - Get pointer in narrow char char __fmt[6] = "%p"; const unsigned __nbuf = 20; char __nar[__nbuf]; int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar char_type __o[2*(__nbuf-1) - 1]; char_type* __op; // pad here char_type* __oe; // end of output const ctype& __ct = use_facet >(__iob.getloc()); __ct.widen(__nar, __ne, __o); __oe = __o + (__ne - __nar); if (__np == __ne) __op = __oe; else __op = __o + (__np - __nar); // [__o, __oe) contains wide number // Stage 3 & 4 return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put) template _LIBCPP_HIDDEN int __get_up_to_n_digits(_InputIterator& __b, _InputIterator __e, ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n) { // Precondition: __n >= 1 if (__b == __e) { __err |= ios_base::eofbit | ios_base::failbit; return 0; } // get first digit _CharT __c = *__b; if (!__ct.is(ctype_base::digit, __c)) { __err |= ios_base::failbit; return 0; } int __r = __ct.narrow(__c, 0) - '0'; for (++__b, (void) --__n; __b != __e && __n > 0; ++__b, (void) --__n) { // get next digit __c = *__b; if (!__ct.is(ctype_base::digit, __c)) return __r; __r = __r * 10 + __ct.narrow(__c, 0) - '0'; } if (__b == __e) __err |= ios_base::eofbit; return __r; } class _LIBCPP_TYPE_VIS time_base { public: enum dateorder {no_order, dmy, mdy, ymd, ydm}; }; template class _LIBCPP_TEMPLATE_VIS __time_get_c_storage { protected: typedef basic_string<_CharT> string_type; virtual const string_type* __weeks() const; virtual const string_type* __months() const; virtual const string_type* __am_pm() const; virtual const string_type& __c() const; virtual const string_type& __r() const; virtual const string_type& __x() const; virtual const string_type& __X() const; _LIBCPP_ALWAYS_INLINE ~__time_get_c_storage() {} }; +template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage::__weeks() const; +template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage::__months() const; +template <> _LIBCPP_FUNC_VIS const string* __time_get_c_storage::__am_pm() const; +template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage::__c() const; +template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage::__r() const; +template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage::__x() const; +template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage::__X() const; + +template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage::__weeks() const; +template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage::__months() const; +template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage::__am_pm() const; +template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage::__c() const; +template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage::__r() const; +template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage::__x() const; +template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage::__X() const; + template > class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { public: typedef _CharT char_type; typedef _InputIterator iter_type; typedef time_base::dateorder dateorder; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE explicit time_get(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE dateorder date_order() const { return this->do_date_order(); } _LIBCPP_ALWAYS_INLINE iter_type get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { return do_get_time(__b, __e, __iob, __err, __tm); } _LIBCPP_ALWAYS_INLINE iter_type get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { return do_get_date(__b, __e, __iob, __err, __tm); } _LIBCPP_ALWAYS_INLINE iter_type get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { return do_get_weekday(__b, __e, __iob, __err, __tm); } _LIBCPP_ALWAYS_INLINE iter_type get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { return do_get_monthname(__b, __e, __iob, __err, __tm); } _LIBCPP_ALWAYS_INLINE iter_type get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { return do_get_year(__b, __e, __iob, __err, __tm); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm *__tm, char __fmt, char __mod = 0) const { return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod); } iter_type get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, const char_type* __fmtb, const char_type* __fmte) const; static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~time_get() {} virtual dateorder do_date_order() const; virtual iter_type do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const; virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod) const; private: void __get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_weekdayname(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_monthname(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_hour(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; void __get_day_year_num(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const; }; template locale::id time_get<_CharT, _InputIterator>::id; // time_get primitives template void time_get<_CharT, _InputIterator>::__get_weekdayname(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { // Note: ignoring case comes from the POSIX strptime spec const string_type* __wk = this->__weeks(); ptrdiff_t __i = __scan_keyword(__b, __e, __wk, __wk+14, __ct, __err, false) - __wk; if (__i < 14) __w = __i % 7; } template void time_get<_CharT, _InputIterator>::__get_monthname(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { // Note: ignoring case comes from the POSIX strptime spec const string_type* __month = this->__months(); ptrdiff_t __i = __scan_keyword(__b, __e, __month, __month+24, __ct, __err, false) - __month; if (__i < 24) __m = __i % 12; } template void time_get<_CharT, _InputIterator>::__get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31) __d = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1; if (!(__err & ios_base::failbit) && __t <= 11) __m = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4); if (!(__err & ios_base::failbit)) { if (__t < 69) __t += 2000; else if (69 <= __t && __t <= 99) __t += 1900; __y = __t - 1900; } } template void time_get<_CharT, _InputIterator>::__get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 4); if (!(__err & ios_base::failbit)) __y = __t - 1900; } template void time_get<_CharT, _InputIterator>::__get_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && __t <= 23) __h = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12) __h = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && __t <= 59) __m = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2); if (!(__err & ios_base::failbit) && __t <= 60) __s = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 1); if (!(__err & ios_base::failbit) && __t <= 6) __w = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_day_year_num(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 3); if (!(__err & ios_base::failbit) && __t <= 365) __d = __t; else __err |= ios_base::failbit; } template void time_get<_CharT, _InputIterator>::__get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) ; if (__b == __e) __err |= ios_base::eofbit; } template void time_get<_CharT, _InputIterator>::__get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { const string_type* __ap = this->__am_pm(); if (__ap[0].size() + __ap[1].size() == 0) { __err |= ios_base::failbit; return; } ptrdiff_t __i = __scan_keyword(__b, __e, __ap, __ap+2, __ct, __err, false) - __ap; if (__i == 0 && __h == 12) __h = 0; else if (__i == 1 && __h < 12) __h += 12; } template void time_get<_CharT, _InputIterator>::__get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype& __ct) const { if (__b == __e) { __err |= ios_base::eofbit | ios_base::failbit; return; } if (__ct.narrow(*__b, 0) != '%') __err |= ios_base::failbit; else if(++__b == __e) __err |= ios_base::eofbit; } // time_get end primitives template _InputIterator time_get<_CharT, _InputIterator>::get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, const char_type* __fmtb, const char_type* __fmte) const { const ctype& __ct = use_facet >(__iob.getloc()); __err = ios_base::goodbit; while (__fmtb != __fmte && __err == ios_base::goodbit) { if (__b == __e) { __err = ios_base::failbit; break; } if (__ct.narrow(*__fmtb, 0) == '%') { if (++__fmtb == __fmte) { __err = ios_base::failbit; break; } char __cmd = __ct.narrow(*__fmtb, 0); char __opt = '\0'; if (__cmd == 'E' || __cmd == '0') { if (++__fmtb == __fmte) { __err = ios_base::failbit; break; } __opt = __cmd; __cmd = __ct.narrow(*__fmtb, 0); } __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt); ++__fmtb; } else if (__ct.is(ctype_base::space, *__fmtb)) { for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb) ; for ( ; __b != __e && __ct.is(ctype_base::space, *__b); ++__b) ; } else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb)) { ++__b; ++__fmtb; } else __err = ios_base::failbit; } if (__b == __e) __err |= ios_base::eofbit; return __b; } template typename time_get<_CharT, _InputIterator>::dateorder time_get<_CharT, _InputIterator>::do_date_order() const { return mdy; } template _InputIterator time_get<_CharT, _InputIterator>::do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt)/sizeof(__fmt[0])); } template _InputIterator time_get<_CharT, _InputIterator>::do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { const string_type& __fmt = this->__x(); return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size()); } template _InputIterator time_get<_CharT, _InputIterator>::do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { const ctype& __ct = use_facet >(__iob.getloc()); __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); return __b; } template _InputIterator time_get<_CharT, _InputIterator>::do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { const ctype& __ct = use_facet >(__iob.getloc()); __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); return __b; } template _InputIterator time_get<_CharT, _InputIterator>::do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const { const ctype& __ct = use_facet >(__iob.getloc()); __get_year(__tm->tm_year, __b, __e, __err, __ct); return __b; } template _InputIterator time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char) const { __err = ios_base::goodbit; const ctype& __ct = use_facet >(__iob.getloc()); switch (__fmt) { case 'a': case 'A': __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct); break; case 'b': case 'B': case 'h': __get_monthname(__tm->tm_mon, __b, __e, __err, __ct); break; case 'c': { const string_type& __fm = this->__c(); __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); } break; case 'd': case 'e': __get_day(__tm->tm_mday, __b, __e, __err, __ct); break; case 'D': { const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'}; __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0])); } break; case 'F': { const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'}; __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0])); } break; case 'H': __get_hour(__tm->tm_hour, __b, __e, __err, __ct); break; case 'I': __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct); break; case 'j': __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct); break; case 'm': __get_month(__tm->tm_mon, __b, __e, __err, __ct); break; case 'M': __get_minute(__tm->tm_min, __b, __e, __err, __ct); break; case 'n': case 't': __get_white_space(__b, __e, __err, __ct); break; case 'p': __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct); break; case 'r': { const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'}; __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0])); } break; case 'R': { const char_type __fm[] = {'%', 'H', ':', '%', 'M'}; __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0])); } break; case 'S': __get_second(__tm->tm_sec, __b, __e, __err, __ct); break; case 'T': { const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'}; __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm)/sizeof(__fm[0])); } break; case 'w': __get_weekday(__tm->tm_wday, __b, __e, __err, __ct); break; case 'x': return do_get_date(__b, __e, __iob, __err, __tm); case 'X': { const string_type& __fm = this->__X(); __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size()); } break; case 'y': __get_year(__tm->tm_year, __b, __e, __err, __ct); break; case 'Y': __get_year4(__tm->tm_year, __b, __e, __err, __ct); break; case '%': __get_percent(__b, __e, __err, __ct); break; default: __err |= ios_base::failbit; } return __b; } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get) class _LIBCPP_TYPE_VIS __time_get { protected: locale_t __loc_; __time_get(const char* __nm); __time_get(const string& __nm); ~__time_get(); }; template class _LIBCPP_TEMPLATE_VIS __time_get_storage : public __time_get { protected: typedef basic_string<_CharT> string_type; string_type __weeks_[14]; string_type __months_[24]; string_type __am_pm_[2]; string_type __c_; string_type __r_; string_type __x_; string_type __X_; explicit __time_get_storage(const char* __nm); explicit __time_get_storage(const string& __nm); _LIBCPP_ALWAYS_INLINE ~__time_get_storage() {} time_base::dateorder __do_date_order() const; private: void init(const ctype<_CharT>&); string_type __analyze(char __fmt, const ctype<_CharT>&); }; template > class _LIBCPP_TEMPLATE_VIS time_get_byname : public time_get<_CharT, _InputIterator>, private __time_get_storage<_CharT> { public: typedef time_base::dateorder dateorder; typedef _InputIterator iter_type; typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_INLINE_VISIBILITY explicit time_get_byname(const char* __nm, size_t __refs = 0) : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} _LIBCPP_INLINE_VISIBILITY explicit time_get_byname(const string& __nm, size_t __refs = 0) : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {} protected: _LIBCPP_INLINE_VISIBILITY ~time_get_byname() {} _LIBCPP_INLINE_VISIBILITY virtual dateorder do_date_order() const {return this->__do_date_order();} private: _LIBCPP_INLINE_VISIBILITY virtual const string_type* __weeks() const {return this->__weeks_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type* __months() const {return this->__months_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type* __am_pm() const {return this->__am_pm_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type& __c() const {return this->__c_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type& __r() const {return this->__r_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type& __x() const {return this->__x_;} _LIBCPP_INLINE_VISIBILITY virtual const string_type& __X() const {return this->__X_;} }; _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname) class _LIBCPP_TYPE_VIS __time_put { locale_t __loc_; protected: _LIBCPP_ALWAYS_INLINE __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {} __time_put(const char* __nm); __time_put(const string& __nm); ~__time_put(); void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; }; template > class _LIBCPP_TEMPLATE_VIS time_put : public locale::facet, private __time_put { public: typedef _CharT char_type; typedef _OutputIterator iter_type; _LIBCPP_ALWAYS_INLINE explicit time_put(size_t __refs = 0) : locale::facet(__refs) {} iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) const; _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, char __fmt, char __mod = 0) const { return do_put(__s, __iob, __fl, __tm, __fmt, __mod); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~time_put() {} virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const; _LIBCPP_ALWAYS_INLINE explicit time_put(const char* __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {} _LIBCPP_ALWAYS_INLINE explicit time_put(const string& __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {} }; template locale::id time_put<_CharT, _OutputIterator>::id; template _OutputIterator time_put<_CharT, _OutputIterator>::put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe) const { const ctype& __ct = use_facet >(__iob.getloc()); for (; __pb != __pe; ++__pb) { if (__ct.narrow(*__pb, 0) == '%') { if (++__pb == __pe) { *__s++ = __pb[-1]; break; } char __mod = 0; char __fmt = __ct.narrow(*__pb, 0); if (__fmt == 'E' || __fmt == 'O') { if (++__pb == __pe) { *__s++ = __pb[-2]; *__s++ = __pb[-1]; break; } __mod = __fmt; __fmt = __ct.narrow(*__pb, 0); } __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod); } else *__s++ = *__pb; } return __s; } template _OutputIterator time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const { char_type __nar[100]; char_type* __nb = __nar; char_type* __ne = __nb + 100; __do_put(__nb, __ne, __tm, __fmt, __mod); return _VSTD::copy(__nb, __ne, __s); } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put) template > class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { public: _LIBCPP_ALWAYS_INLINE explicit time_put_byname(const char* __nm, size_t __refs = 0) : time_put<_CharT, _OutputIterator>(__nm, __refs) {} _LIBCPP_ALWAYS_INLINE explicit time_put_byname(const string& __nm, size_t __refs = 0) : time_put<_CharT, _OutputIterator>(__nm, __refs) {} protected: _LIBCPP_ALWAYS_INLINE ~time_put_byname() {} }; _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname) // money_base class _LIBCPP_TYPE_VIS money_base { public: enum part {none, space, symbol, sign, value}; struct pattern {char field[4];}; _LIBCPP_ALWAYS_INLINE money_base() {} }; // moneypunct template class _LIBCPP_TEMPLATE_VIS moneypunct : public locale::facet, public money_base { public: typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE char_type decimal_point() const {return do_decimal_point();} _LIBCPP_ALWAYS_INLINE char_type thousands_sep() const {return do_thousands_sep();} _LIBCPP_ALWAYS_INLINE string grouping() const {return do_grouping();} _LIBCPP_ALWAYS_INLINE string_type curr_symbol() const {return do_curr_symbol();} _LIBCPP_ALWAYS_INLINE string_type positive_sign() const {return do_positive_sign();} _LIBCPP_ALWAYS_INLINE string_type negative_sign() const {return do_negative_sign();} _LIBCPP_ALWAYS_INLINE int frac_digits() const {return do_frac_digits();} _LIBCPP_ALWAYS_INLINE pattern pos_format() const {return do_pos_format();} _LIBCPP_ALWAYS_INLINE pattern neg_format() const {return do_neg_format();} static locale::id id; static const bool intl = _International; protected: _LIBCPP_ALWAYS_INLINE ~moneypunct() {} virtual char_type do_decimal_point() const {return numeric_limits::max();} virtual char_type do_thousands_sep() const {return numeric_limits::max();} virtual string do_grouping() const {return string();} virtual string_type do_curr_symbol() const {return string_type();} virtual string_type do_positive_sign() const {return string_type();} virtual string_type do_negative_sign() const {return string_type(1, '-');} virtual int do_frac_digits() const {return 0;} virtual pattern do_pos_format() const {pattern __p = {{symbol, sign, none, value}}; return __p;} virtual pattern do_neg_format() const {pattern __p = {{symbol, sign, none, value}}; return __p;} }; template locale::id moneypunct<_CharT, _International>::id; template const bool moneypunct<_CharT, _International>::intl; _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct) // moneypunct_byname template class _LIBCPP_TEMPLATE_VIS moneypunct_byname : public moneypunct<_CharT, _International> { public: typedef money_base::pattern pattern; typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE explicit moneypunct_byname(const char* __nm, size_t __refs = 0) : moneypunct<_CharT, _International>(__refs) {init(__nm);} _LIBCPP_ALWAYS_INLINE explicit moneypunct_byname(const string& __nm, size_t __refs = 0) : moneypunct<_CharT, _International>(__refs) {init(__nm.c_str());} protected: _LIBCPP_ALWAYS_INLINE ~moneypunct_byname() {} virtual char_type do_decimal_point() const {return __decimal_point_;} virtual char_type do_thousands_sep() const {return __thousands_sep_;} virtual string do_grouping() const {return __grouping_;} virtual string_type do_curr_symbol() const {return __curr_symbol_;} virtual string_type do_positive_sign() const {return __positive_sign_;} virtual string_type do_negative_sign() const {return __negative_sign_;} virtual int do_frac_digits() const {return __frac_digits_;} virtual pattern do_pos_format() const {return __pos_format_;} virtual pattern do_neg_format() const {return __neg_format_;} private: char_type __decimal_point_; char_type __thousands_sep_; string __grouping_; string_type __curr_symbol_; string_type __positive_sign_; string_type __negative_sign_; int __frac_digits_; pattern __pos_format_; pattern __neg_format_; void init(const char*); }; template<> _LIBCPP_FUNC_VIS void moneypunct_byname::init(const char*); template<> _LIBCPP_FUNC_VIS void moneypunct_byname::init(const char*); template<> _LIBCPP_FUNC_VIS void moneypunct_byname::init(const char*); template<> _LIBCPP_FUNC_VIS void moneypunct_byname::init(const char*); _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname) // money_get template class __money_get { protected: typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE __money_get() {} static void __gather_info(bool __intl, const locale& __loc, money_base::pattern& __pat, char_type& __dp, char_type& __ts, string& __grp, string_type& __sym, string_type& __psn, string_type& __nsn, int& __fd); }; template void __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, money_base::pattern& __pat, char_type& __dp, char_type& __ts, string& __grp, string_type& __sym, string_type& __psn, string_type& __nsn, int& __fd) { if (__intl) { const moneypunct& __mp = use_facet >(__loc); __pat = __mp.neg_format(); __nsn = __mp.negative_sign(); __psn = __mp.positive_sign(); __dp = __mp.decimal_point(); __ts = __mp.thousands_sep(); __grp = __mp.grouping(); __sym = __mp.curr_symbol(); __fd = __mp.frac_digits(); } else { const moneypunct& __mp = use_facet >(__loc); __pat = __mp.neg_format(); __nsn = __mp.negative_sign(); __psn = __mp.positive_sign(); __dp = __mp.decimal_point(); __ts = __mp.thousands_sep(); __grp = __mp.grouping(); __sym = __mp.curr_symbol(); __fd = __mp.frac_digits(); } } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get) template > class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { public: typedef _CharT char_type; typedef _InputIterator iter_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE explicit money_get(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { return do_get(__b, __e, __intl, __iob, __err, __v); } _LIBCPP_ALWAYS_INLINE iter_type get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { return do_get(__b, __e, __intl, __iob, __err, __v); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~money_get() {} virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const; virtual iter_type do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const; private: static bool __do_get(iter_type& __b, iter_type __e, bool __intl, const locale& __loc, ios_base::fmtflags __flags, ios_base::iostate& __err, bool& __neg, const ctype& __ct, unique_ptr& __wb, char_type*& __wn, char_type* __we); }; template locale::id money_get<_CharT, _InputIterator>::id; _LIBCPP_FUNC_VIS void __do_nothing(void*); template _LIBCPP_HIDDEN void __double_or_nothing(unique_ptr<_Tp, void(*)(void*)>& __b, _Tp*& __n, _Tp*& __e) { bool __owns = __b.get_deleter() != __do_nothing; size_t __cur_cap = static_cast(__e-__b.get()) * sizeof(_Tp); size_t __new_cap = __cur_cap < numeric_limits::max() / 2 ? 2 * __cur_cap : numeric_limits::max(); if (__new_cap == 0) __new_cap = sizeof(_Tp); size_t __n_off = static_cast(__n - __b.get()); _Tp* __t = (_Tp*)realloc(__owns ? __b.get() : 0, __new_cap); if (__t == 0) __throw_bad_alloc(); if (__owns) __b.release(); __b = unique_ptr<_Tp, void(*)(void*)>(__t, free); __new_cap /= sizeof(_Tp); __n = __b.get() + __n_off; __e = __b.get() + __new_cap; } // true == success template bool money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, bool __intl, const locale& __loc, ios_base::fmtflags __flags, ios_base::iostate& __err, bool& __neg, const ctype& __ct, unique_ptr& __wb, char_type*& __wn, char_type* __we) { const unsigned __bz = 100; unsigned __gbuf[__bz]; unique_ptr __gb(__gbuf, __do_nothing); unsigned* __gn = __gb.get(); unsigned* __ge = __gn + __bz; money_base::pattern __pat; char_type __dp; char_type __ts; string __grp; string_type __sym; string_type __psn; string_type __nsn; // Capture the spaces read into money_base::{space,none} so they // can be compared to initial spaces in __sym. string_type __spaces; int __fd; __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp, __sym, __psn, __nsn, __fd); const string_type* __trailing_sign = 0; __wn = __wb.get(); for (unsigned __p = 0; __p < 4 && __b != __e; ++__p) { switch (__pat.field[__p]) { case money_base::space: if (__p != 3) { if (__ct.is(ctype_base::space, *__b)) __spaces.push_back(*__b++); else { __err |= ios_base::failbit; return false; } } - // drop through + _LIBCPP_FALLTHROUGH(); case money_base::none: if (__p != 3) { while (__b != __e && __ct.is(ctype_base::space, *__b)) __spaces.push_back(*__b++); } break; case money_base::sign: if (__psn.size() + __nsn.size() > 0) { if (__psn.size() == 0 || __nsn.size() == 0) { // sign is optional if (__psn.size() > 0) { // __nsn.size() == 0 if (*__b == __psn[0]) { ++__b; if (__psn.size() > 1) __trailing_sign = &__psn; } else __neg = true; } else if (*__b == __nsn[0]) // __nsn.size() > 0 && __psn.size() == 0 { ++__b; __neg = true; if (__nsn.size() > 1) __trailing_sign = &__nsn; } } else // sign is required { if (*__b == __psn[0]) { ++__b; if (__psn.size() > 1) __trailing_sign = &__psn; } else if (*__b == __nsn[0]) { ++__b; __neg = true; if (__nsn.size() > 1) __trailing_sign = &__nsn; } else { __err |= ios_base::failbit; return false; } } } break; case money_base::symbol: { bool __more_needed = __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast(money_base::none)); bool __sb = (__flags & ios_base::showbase) != 0; if (__sb || __more_needed) { typename string_type::const_iterator __sym_space_end = __sym.begin(); if (__p > 0 && (__pat.field[__p - 1] == money_base::none || __pat.field[__p - 1] == money_base::space)) { // Match spaces we've already read against spaces at // the beginning of __sym. while (__sym_space_end != __sym.end() && __ct.is(ctype_base::space, *__sym_space_end)) ++__sym_space_end; const size_t __num_spaces = __sym_space_end - __sym.begin(); if (__num_spaces > __spaces.size() || !equal(__spaces.end() - __num_spaces, __spaces.end(), __sym.begin())) { // No match. Put __sym_space_end back at the // beginning of __sym, which will prevent a // match in the next loop. __sym_space_end = __sym.begin(); } } typename string_type::const_iterator __sym_curr_char = __sym_space_end; while (__sym_curr_char != __sym.end() && __b != __e && *__b == *__sym_curr_char) { ++__b; ++__sym_curr_char; } if (__sb && __sym_curr_char != __sym.end()) { __err |= ios_base::failbit; return false; } } } break; case money_base::value: { unsigned __ng = 0; for (; __b != __e; ++__b) { char_type __c = *__b; if (__ct.is(ctype_base::digit, __c)) { if (__wn == __we) __double_or_nothing(__wb, __wn, __we); *__wn++ = __c; ++__ng; } else if (__grp.size() > 0 && __ng > 0 && __c == __ts) { if (__gn == __ge) __double_or_nothing(__gb, __gn, __ge); *__gn++ = __ng; __ng = 0; } else break; } if (__gb.get() != __gn && __ng > 0) { if (__gn == __ge) __double_or_nothing(__gb, __gn, __ge); *__gn++ = __ng; } if (__fd > 0) { if (__b == __e || *__b != __dp) { __err |= ios_base::failbit; return false; } for (++__b; __fd > 0; --__fd, ++__b) { if (__b == __e || !__ct.is(ctype_base::digit, *__b)) { __err |= ios_base::failbit; return false; } if (__wn == __we) __double_or_nothing(__wb, __wn, __we); *__wn++ = *__b; } } if (__wn == __wb.get()) { __err |= ios_base::failbit; return false; } } break; } } if (__trailing_sign) { for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) { if (__b == __e || *__b != (*__trailing_sign)[__i]) { __err |= ios_base::failbit; return false; } } } if (__gb.get() != __gn) { ios_base::iostate __et = ios_base::goodbit; __check_grouping(__grp, __gb.get(), __gn, __et); if (__et) { __err |= ios_base::failbit; return false; } } return true; } template _InputIterator money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const { const int __bz = 100; char_type __wbuf[__bz]; unique_ptr __wb(__wbuf, __do_nothing); char_type* __wn; char_type* __we = __wbuf + __bz; locale __loc = __iob.getloc(); const ctype& __ct = use_facet >(__loc); bool __neg = false; if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { const char __src[] = "0123456789"; char_type __atoms[sizeof(__src)-1]; __ct.widen(__src, __src + (sizeof(__src)-1), __atoms); char __nbuf[__bz]; char* __nc = __nbuf; unique_ptr __h(0, free); if (__wn - __wb.get() > __bz-2) { __h.reset((char*)malloc(static_cast(__wn - __wb.get() + 2))); if (__h.get() == 0) __throw_bad_alloc(); __nc = __h.get(); } if (__neg) *__nc++ = '-'; for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc) *__nc = __src[find(__atoms, _VSTD::end(__atoms), *__w) - __atoms]; *__nc = char(); if (sscanf(__nbuf, "%Lf", &__v) != 1) __throw_runtime_error("money_get error"); } if (__b == __e) __err |= ios_base::eofbit; return __b; } template _InputIterator money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const { const int __bz = 100; char_type __wbuf[__bz]; unique_ptr __wb(__wbuf, __do_nothing); char_type* __wn; char_type* __we = __wbuf + __bz; locale __loc = __iob.getloc(); const ctype& __ct = use_facet >(__loc); bool __neg = false; if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) { __v.clear(); if (__neg) __v.push_back(__ct.widen('-')); char_type __z = __ct.widen('0'); char_type* __w; for (__w = __wb.get(); __w < __wn-1; ++__w) if (*__w != __z) break; __v.append(__w, __wn); } if (__b == __e) __err |= ios_base::eofbit; return __b; } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get) // money_put template class __money_put { protected: typedef _CharT char_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE __money_put() {} static void __gather_info(bool __intl, bool __neg, const locale& __loc, money_base::pattern& __pat, char_type& __dp, char_type& __ts, string& __grp, string_type& __sym, string_type& __sn, int& __fd); static void __format(char_type* __mb, char_type*& __mi, char_type*& __me, ios_base::fmtflags __flags, const char_type* __db, const char_type* __de, const ctype& __ct, bool __neg, const money_base::pattern& __pat, char_type __dp, char_type __ts, const string& __grp, const string_type& __sym, const string_type& __sn, int __fd); }; template void __money_put<_CharT>::__gather_info(bool __intl, bool __neg, const locale& __loc, money_base::pattern& __pat, char_type& __dp, char_type& __ts, string& __grp, string_type& __sym, string_type& __sn, int& __fd) { if (__intl) { const moneypunct& __mp = use_facet >(__loc); if (__neg) { __pat = __mp.neg_format(); __sn = __mp.negative_sign(); } else { __pat = __mp.pos_format(); __sn = __mp.positive_sign(); } __dp = __mp.decimal_point(); __ts = __mp.thousands_sep(); __grp = __mp.grouping(); __sym = __mp.curr_symbol(); __fd = __mp.frac_digits(); } else { const moneypunct& __mp = use_facet >(__loc); if (__neg) { __pat = __mp.neg_format(); __sn = __mp.negative_sign(); } else { __pat = __mp.pos_format(); __sn = __mp.positive_sign(); } __dp = __mp.decimal_point(); __ts = __mp.thousands_sep(); __grp = __mp.grouping(); __sym = __mp.curr_symbol(); __fd = __mp.frac_digits(); } } template void __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __me, ios_base::fmtflags __flags, const char_type* __db, const char_type* __de, const ctype& __ct, bool __neg, const money_base::pattern& __pat, char_type __dp, char_type __ts, const string& __grp, const string_type& __sym, const string_type& __sn, int __fd) { __me = __mb; for (unsigned __p = 0; __p < 4; ++__p) { switch (__pat.field[__p]) { case money_base::none: __mi = __me; break; case money_base::space: __mi = __me; *__me++ = __ct.widen(' '); break; case money_base::sign: if (!__sn.empty()) *__me++ = __sn[0]; break; case money_base::symbol: if (!__sym.empty() && (__flags & ios_base::showbase)) __me = _VSTD::copy(__sym.begin(), __sym.end(), __me); break; case money_base::value: { // remember start of value so we can reverse it char_type* __t = __me; // find beginning of digits if (__neg) ++__db; // find end of digits const char_type* __d; for (__d = __db; __d < __de; ++__d) if (!__ct.is(ctype_base::digit, *__d)) break; // print fractional part if (__fd > 0) { int __f; for (__f = __fd; __d > __db && __f > 0; --__f) *__me++ = *--__d; char_type __z = __f > 0 ? __ct.widen('0') : char_type(); for (; __f > 0; --__f) *__me++ = __z; *__me++ = __dp; } // print units part if (__d == __db) { *__me++ = __ct.widen('0'); } else { unsigned __ng = 0; unsigned __ig = 0; unsigned __gl = __grp.empty() ? numeric_limits::max() : static_cast(__grp[__ig]); while (__d != __db) { if (__ng == __gl) { *__me++ = __ts; __ng = 0; if (++__ig < __grp.size()) __gl = __grp[__ig] == numeric_limits::max() ? numeric_limits::max() : static_cast(__grp[__ig]); } *__me++ = *--__d; ++__ng; } } // reverse it reverse(__t, __me); } break; } } // print rest of sign, if any if (__sn.size() > 1) __me = _VSTD::copy(__sn.begin()+1, __sn.end(), __me); // set alignment if ((__flags & ios_base::adjustfield) == ios_base::left) __mi = __me; else if ((__flags & ios_base::adjustfield) != ios_base::internal) __mi = __mb; } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put) template > class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { public: typedef _CharT char_type; typedef _OutputIterator iter_type; typedef basic_string string_type; _LIBCPP_ALWAYS_INLINE explicit money_put(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { return do_put(__s, __intl, __iob, __fl, __units); } _LIBCPP_ALWAYS_INLINE iter_type put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { return do_put(__s, __intl, __iob, __fl, __digits); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~money_put() {} virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const; virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const; }; template locale::id money_put<_CharT, _OutputIterator>::id; template _OutputIterator money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const { // convert to char const size_t __bs = 100; char __buf[__bs]; char* __bb = __buf; char_type __digits[__bs]; char_type* __db = __digits; size_t __n = static_cast(snprintf(__bb, __bs, "%.0Lf", __units)); unique_ptr __hn(0, free); unique_ptr __hd(0, free); // secure memory for digit storage if (__n > __bs-1) { __n = static_cast(__libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units)); if (__bb == 0) __throw_bad_alloc(); __hn.reset(__bb); __hd.reset((char_type*)malloc(__n * sizeof(char_type))); if (__hd == nullptr) __throw_bad_alloc(); __db = __hd.get(); } // gather info locale __loc = __iob.getloc(); const ctype& __ct = use_facet >(__loc); __ct.widen(__bb, __bb + __n, __db); bool __neg = __n > 0 && __bb[0] == '-'; money_base::pattern __pat; char_type __dp; char_type __ts; string __grp; string_type __sym; string_type __sn; int __fd; this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); // secure memory for formatting char_type __mbuf[__bs]; char_type* __mb = __mbuf; unique_ptr __hw(0, free); size_t __exn = static_cast(__n) > __fd ? (__n - static_cast(__fd)) * 2 + __sn.size() + __sym.size() + static_cast(__fd) + 1 : __sn.size() + __sym.size() + static_cast(__fd) + 2; if (__exn > __bs) { __hw.reset((char_type*)malloc(__exn * sizeof(char_type))); __mb = __hw.get(); if (__mb == 0) __throw_bad_alloc(); } // format char_type* __mi; char_type* __me; this->__format(__mb, __mi, __me, __iob.flags(), __db, __db + __n, __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd); return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } template _OutputIterator money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const { // gather info locale __loc = __iob.getloc(); const ctype& __ct = use_facet >(__loc); bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-'); money_base::pattern __pat; char_type __dp; char_type __ts; string __grp; string_type __sym; string_type __sn; int __fd; this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd); // secure memory for formatting char_type __mbuf[100]; char_type* __mb = __mbuf; unique_ptr __h(0, free); size_t __exn = static_cast(__digits.size()) > __fd ? (__digits.size() - static_cast(__fd)) * 2 + __sn.size() + __sym.size() + static_cast(__fd) + 1 : __sn.size() + __sym.size() + static_cast(__fd) + 2; if (__exn > 100) { __h.reset((char_type*)malloc(__exn * sizeof(char_type))); __mb = __h.get(); if (__mb == 0) __throw_bad_alloc(); } // format char_type* __mi; char_type* __me; this->__format(__mb, __mi, __me, __iob.flags(), __digits.data(), __digits.data() + __digits.size(), __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd); return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put) // messages class _LIBCPP_TYPE_VIS messages_base { public: typedef ptrdiff_t catalog; _LIBCPP_ALWAYS_INLINE messages_base() {} }; template class _LIBCPP_TEMPLATE_VIS messages : public locale::facet, public messages_base { public: typedef _CharT char_type; typedef basic_string<_CharT> string_type; _LIBCPP_ALWAYS_INLINE explicit messages(size_t __refs = 0) : locale::facet(__refs) {} _LIBCPP_ALWAYS_INLINE catalog open(const basic_string& __nm, const locale& __loc) const { return do_open(__nm, __loc); } _LIBCPP_ALWAYS_INLINE string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { return do_get(__c, __set, __msgid, __dflt); } _LIBCPP_ALWAYS_INLINE void close(catalog __c) const { do_close(__c); } static locale::id id; protected: _LIBCPP_ALWAYS_INLINE ~messages() {} virtual catalog do_open(const basic_string&, const locale&) const; virtual string_type do_get(catalog, int __set, int __msgid, const string_type& __dflt) const; virtual void do_close(catalog) const; }; template locale::id messages<_CharT>::id; template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { #ifdef _LIBCPP_HAS_CATOPEN catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); if (__cat != -1) __cat = static_cast((static_cast(__cat) >> 1)); return __cat; #else // !_LIBCPP_HAS_CATOPEN return -1; #endif // _LIBCPP_HAS_CATOPEN } template typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { #ifdef _LIBCPP_HAS_CATOPEN string __ndflt; __narrow_to_utf8()(back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); if (__c != -1) __c <<= 1; nl_catd __cat = (nl_catd)__c; char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); string_type __w; __widen_from_utf8()(back_inserter(__w), __n, __n + strlen(__n)); return __w; #else // !_LIBCPP_HAS_CATOPEN return __dflt; #endif // _LIBCPP_HAS_CATOPEN } template void messages<_CharT>::do_close(catalog __c) const { #ifdef _LIBCPP_HAS_CATOPEN if (__c != -1) __c <<= 1; nl_catd __cat = (nl_catd)__c; catclose(__cat); #endif // _LIBCPP_HAS_CATOPEN } _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages) template class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { public: typedef messages_base::catalog catalog; typedef basic_string<_CharT> string_type; _LIBCPP_ALWAYS_INLINE explicit messages_byname(const char*, size_t __refs = 0) : messages<_CharT>(__refs) {} _LIBCPP_ALWAYS_INLINE explicit messages_byname(const string&, size_t __refs = 0) : messages<_CharT>(__refs) {} protected: _LIBCPP_ALWAYS_INLINE ~messages_byname() {} }; _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname) template, class _Byte_alloc = allocator > class _LIBCPP_TEMPLATE_VIS wstring_convert { public: typedef basic_string, _Byte_alloc> byte_string; typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string; typedef typename _Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; private: byte_string __byte_err_string_; wide_string __wide_err_string_; _Codecvt* __cvtptr_; state_type __cvtstate_; size_t __cvtcount_; wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); _LIBCPP_ALWAYS_INLINE wstring_convert(_Codecvt* __pcvt, state_type __state); _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_ALWAYS_INLINE wstring_convert(wstring_convert&& __wc); #endif ~wstring_convert(); _LIBCPP_ALWAYS_INLINE wide_string from_bytes(char __byte) {return from_bytes(&__byte, &__byte+1);} _LIBCPP_ALWAYS_INLINE wide_string from_bytes(const char* __ptr) {return from_bytes(__ptr, __ptr + char_traits::length(__ptr));} _LIBCPP_ALWAYS_INLINE wide_string from_bytes(const byte_string& __str) {return from_bytes(__str.data(), __str.data() + __str.size());} wide_string from_bytes(const char* __first, const char* __last); _LIBCPP_ALWAYS_INLINE byte_string to_bytes(_Elem __wchar) {return to_bytes(&__wchar, &__wchar+1);} _LIBCPP_ALWAYS_INLINE byte_string to_bytes(const _Elem* __wptr) {return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));} _LIBCPP_ALWAYS_INLINE byte_string to_bytes(const wide_string& __wstr) {return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());} byte_string to_bytes(const _Elem* __first, const _Elem* __last); _LIBCPP_ALWAYS_INLINE size_t converted() const _NOEXCEPT {return __cvtcount_;} _LIBCPP_ALWAYS_INLINE state_type state() const {return __cvtstate_;} }; template inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt) : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) { } template inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt, state_type __state) : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) { } template wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err) : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) { __cvtptr_ = new _Codecvt; } #ifndef _LIBCPP_CXX03_LANG template inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(wstring_convert&& __wc) : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)), __wide_err_string_(_VSTD::move(__wc.__wide_err_string_)), __cvtptr_(__wc.__cvtptr_), __cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtcount_) { __wc.__cvtptr_ = nullptr; } #endif // _LIBCPP_CXX03_LANG template wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert() { delete __cvtptr_; } template typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: from_bytes(const char* __frm, const char* __frm_end) { __cvtcount_ = 0; if (__cvtptr_ != nullptr) { wide_string __ws(2*(__frm_end - __frm), _Elem()); if (__frm != __frm_end) __ws.resize(__ws.capacity()); codecvt_base::result __r = codecvt_base::ok; state_type __st = __cvtstate_; if (__frm != __frm_end) { _Elem* __to = &__ws[0]; _Elem* __to_end = __to + __ws.size(); const char* __frm_nxt; do { _Elem* __to_nxt; __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); __cvtcount_ += __frm_nxt - __frm; if (__frm_nxt == __frm) { __r = codecvt_base::error; } else if (__r == codecvt_base::noconv) { __ws.resize(__to - &__ws[0]); // This only gets executed if _Elem is char __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end); __frm = __frm_nxt; __r = codecvt_base::ok; } else if (__r == codecvt_base::ok) { __ws.resize(__to_nxt - &__ws[0]); __frm = __frm_nxt; } else if (__r == codecvt_base::partial) { ptrdiff_t __s = __to_nxt - &__ws[0]; __ws.resize(2 * __s); __to = &__ws[0] + __s; __to_end = &__ws[0] + __ws.size(); __frm = __frm_nxt; } } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); } if (__r == codecvt_base::ok) return __ws; } if (__wide_err_string_.empty()) __throw_range_error("wstring_convert: from_bytes error"); return __wide_err_string_; } template typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::byte_string wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: to_bytes(const _Elem* __frm, const _Elem* __frm_end) { __cvtcount_ = 0; if (__cvtptr_ != nullptr) { byte_string __bs(2*(__frm_end - __frm), char()); if (__frm != __frm_end) __bs.resize(__bs.capacity()); codecvt_base::result __r = codecvt_base::ok; state_type __st = __cvtstate_; if (__frm != __frm_end) { char* __to = &__bs[0]; char* __to_end = __to + __bs.size(); const _Elem* __frm_nxt; do { char* __to_nxt; __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt); __cvtcount_ += __frm_nxt - __frm; if (__frm_nxt == __frm) { __r = codecvt_base::error; } else if (__r == codecvt_base::noconv) { __bs.resize(__to - &__bs[0]); // This only gets executed if _Elem is char __bs.append((const char*)__frm, (const char*)__frm_end); __frm = __frm_nxt; __r = codecvt_base::ok; } else if (__r == codecvt_base::ok) { __bs.resize(__to_nxt - &__bs[0]); __frm = __frm_nxt; } else if (__r == codecvt_base::partial) { ptrdiff_t __s = __to_nxt - &__bs[0]; __bs.resize(2 * __s); __to = &__bs[0] + __s; __to_end = &__bs[0] + __bs.size(); __frm = __frm_nxt; } } while (__r == codecvt_base::partial && __frm_nxt < __frm_end); } if (__r == codecvt_base::ok) { size_t __s = __bs.size(); __bs.resize(__bs.capacity()); char* __to = &__bs[0] + __s; char* __to_end = __to + __bs.size(); do { char* __to_nxt; __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt); if (__r == codecvt_base::noconv) { __bs.resize(__to - &__bs[0]); __r = codecvt_base::ok; } else if (__r == codecvt_base::ok) { __bs.resize(__to_nxt - &__bs[0]); } else if (__r == codecvt_base::partial) { ptrdiff_t __sp = __to_nxt - &__bs[0]; __bs.resize(2 * __sp); __to = &__bs[0] + __sp; __to_end = &__bs[0] + __bs.size(); } } while (__r == codecvt_base::partial); if (__r == codecvt_base::ok) return __bs; } } if (__byte_err_string_.empty()) __throw_range_error("wstring_convert: to_bytes error"); return __byte_err_string_; } template > class _LIBCPP_TEMPLATE_VIS wbuffer_convert : public basic_streambuf<_Elem, _Tr> { public: // types: typedef _Elem char_type; typedef _Tr traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef typename _Codecvt::state_type state_type; private: char* __extbuf_; const char* __extbufnext_; const char* __extbufend_; char __extbuf_min_[8]; size_t __ebs_; char_type* __intbuf_; size_t __ibs_; streambuf* __bufptr_; _Codecvt* __cv_; state_type __st_; ios_base::openmode __cm_; bool __owns_eb_; bool __owns_ib_; bool __always_noconv_; wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); public: _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY streambuf* rdbuf() const {return __bufptr_;} _LIBCPP_INLINE_VISIBILITY streambuf* rdbuf(streambuf* __bytebuf) { streambuf* __r = __bufptr_; __bufptr_ = __bytebuf; return __r; } _LIBCPP_INLINE_VISIBILITY state_type state() const {return __st_;} protected: virtual int_type underflow(); virtual int_type pbackfail(int_type __c = traits_type::eof()); virtual int_type overflow (int_type __c = traits_type::eof()); virtual basic_streambuf* setbuf(char_type* __s, streamsize __n); virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out); virtual int sync(); private: bool __read_mode(); void __write_mode(); wbuffer_convert* __close(); }; template wbuffer_convert<_Codecvt, _Elem, _Tr>:: wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state) : __extbuf_(0), __extbufnext_(0), __extbufend_(0), __ebs_(0), __intbuf_(0), __ibs_(0), __bufptr_(__bytebuf), __cv_(__pcvt), __st_(__state), __cm_(0), __owns_eb_(false), __owns_ib_(false), __always_noconv_(__cv_ ? __cv_->always_noconv() : false) { setbuf(0, 4096); } template wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert() { __close(); delete __cv_; if (__owns_eb_) delete [] __extbuf_; if (__owns_ib_) delete [] __intbuf_; } template typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() { if (__cv_ == 0 || __bufptr_ == 0) return traits_type::eof(); bool __initial = __read_mode(); char_type __1buf; if (this->gptr() == 0) this->setg(&__1buf, &__1buf+1, &__1buf+1); const size_t __unget_sz = __initial ? 0 : min((this->egptr() - this->eback()) / 2, 4); int_type __c = traits_type::eof(); if (this->gptr() == this->egptr()) { memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type)); if (__always_noconv_) { streamsize __nmemb = static_cast(this->egptr() - this->eback() - __unget_sz); __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb); if (__nmemb != 0) { this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb); __c = *this->gptr(); } } else { _LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" ); if (__extbufend_ != __extbufnext_) memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); streamsize __nmemb = _VSTD::min(static_cast(this->egptr() - this->eback() - __unget_sz), static_cast(__extbufend_ - __extbufnext_)); codecvt_base::result __r; // FIXME: Do we ever need to restore the state here? //state_type __svs = __st_; streamsize __nr = __bufptr_->sgetn(const_cast(__extbufnext_), __nmemb); if (__nr != 0) { __extbufend_ = __extbufnext_ + __nr; char_type* __inext; __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, this->egptr(), __inext); if (__r == codecvt_base::noconv) { this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_); __c = *this->gptr(); } else if (__inext != this->eback() + __unget_sz) { this->setg(this->eback(), this->eback() + __unget_sz, __inext); __c = *this->gptr(); } } } } else __c = *this->gptr(); if (this->eback() == &__1buf) this->setg(0, 0, 0); return __c; } template typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) { if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr()) { if (traits_type::eq_int_type(__c, traits_type::eof())) { this->gbump(-1); return traits_type::not_eof(__c); } if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) { this->gbump(-1); *this->gptr() = traits_type::to_char_type(__c); return __c; } } return traits_type::eof(); } template typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) { if (__cv_ == 0 || __bufptr_ == 0) return traits_type::eof(); __write_mode(); char_type __1buf; char_type* __pb_save = this->pbase(); char_type* __epb_save = this->epptr(); if (!traits_type::eq_int_type(__c, traits_type::eof())) { if (this->pptr() == 0) this->setp(&__1buf, &__1buf+1); *this->pptr() = traits_type::to_char_type(__c); this->pbump(1); } if (this->pptr() != this->pbase()) { if (__always_noconv_) { streamsize __nmemb = static_cast(this->pptr() - this->pbase()); if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) return traits_type::eof(); } else { char* __extbe = __extbuf_; codecvt_base::result __r; do { const char_type* __e; __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); if (__e == this->pbase()) return traits_type::eof(); if (__r == codecvt_base::noconv) { streamsize __nmemb = static_cast(this->pptr() - this->pbase()); if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb) return traits_type::eof(); } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) { streamsize __nmemb = static_cast(__extbe - __extbuf_); if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) return traits_type::eof(); if (__r == codecvt_base::partial) { this->setp((char_type*)__e, this->pptr()); this->pbump(this->epptr() - this->pbase()); } } else return traits_type::eof(); } while (__r == codecvt_base::partial); } this->setp(__pb_save, __epb_save); } return traits_type::not_eof(__c); } template basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) { this->setg(0, 0, 0); this->setp(0, 0); if (__owns_eb_) delete [] __extbuf_; if (__owns_ib_) delete [] __intbuf_; __ebs_ = __n; if (__ebs_ > sizeof(__extbuf_min_)) { if (__always_noconv_ && __s) { __extbuf_ = (char*)__s; __owns_eb_ = false; } else { __extbuf_ = new char[__ebs_]; __owns_eb_ = true; } } else { __extbuf_ = __extbuf_min_; __ebs_ = sizeof(__extbuf_min_); __owns_eb_ = false; } if (!__always_noconv_) { __ibs_ = max(__n, sizeof(__extbuf_min_)); if (__s && __ibs_ >= sizeof(__extbuf_min_)) { __intbuf_ = __s; __owns_ib_ = false; } else { __intbuf_ = new char_type[__ibs_]; __owns_ib_ = true; } } else { __ibs_ = 0; __intbuf_ = 0; __owns_ib_ = false; } return this; } template typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __om) { int __width = __cv_->encoding(); if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync()) return pos_type(off_type(-1)); // __width > 0 || __off == 0, now check __way if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end) return pos_type(off_type(-1)); pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om); __r.state(__st_); return __r; } template typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch) { if (__cv_ == 0 || __bufptr_ == 0 || sync()) return pos_type(off_type(-1)); if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1))) return pos_type(off_type(-1)); return __sp; } template int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() { if (__cv_ == 0 || __bufptr_ == 0) return 0; if (__cm_ & ios_base::out) { if (this->pptr() != this->pbase()) if (overflow() == traits_type::eof()) return -1; codecvt_base::result __r; do { char* __extbe; __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe); streamsize __nmemb = static_cast(__extbe - __extbuf_); if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb) return -1; } while (__r == codecvt_base::partial); if (__r == codecvt_base::error) return -1; if (__bufptr_->pubsync()) return -1; } else if (__cm_ & ios_base::in) { off_type __c; if (__always_noconv_) __c = this->egptr() - this->gptr(); else { int __width = __cv_->encoding(); __c = __extbufend_ - __extbufnext_; if (__width > 0) __c += __width * (this->egptr() - this->gptr()); else { if (this->gptr() != this->egptr()) { reverse(this->gptr(), this->egptr()); codecvt_base::result __r; const char_type* __e = this->gptr(); char* __extbe; do { __r = __cv_->out(__st_, __e, this->egptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe); switch (__r) { case codecvt_base::noconv: __c += this->egptr() - this->gptr(); break; case codecvt_base::ok: case codecvt_base::partial: __c += __extbe - __extbuf_; break; default: return -1; } } while (__r == codecvt_base::partial); } } } if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1))) return -1; this->setg(0, 0, 0); __cm_ = 0; } return 0; } template bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() { if (!(__cm_ & ios_base::in)) { this->setp(0, 0); if (__always_noconv_) this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_); else this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_); __cm_ = ios_base::in; return true; } return false; } template void wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode() { if (!(__cm_ & ios_base::out)) { this->setg(0, 0, 0); if (__ebs_ > sizeof(__extbuf_min_)) { if (__always_noconv_) this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__ebs_ - 1)); else this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1)); } else this->setp(0, 0); __cm_ = ios_base::out; } } template wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() { wbuffer_convert* __rt = 0; if (__cv_ != 0 && __bufptr_ != 0) { __rt = this; if ((__cm_ & ios_base::out) && sync()) __rt = 0; } return __rt; } _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_LOCALE Index: vendor/libc++/dist/include/memory =================================================================== --- vendor/libc++/dist/include/memory (revision 317954) +++ vendor/libc++/dist/include/memory (revision 317955) @@ -1,5533 +1,5544 @@ // -*- C++ -*- //===-------------------------- memory ------------------------------------===// // // 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_MEMORY #define _LIBCPP_MEMORY /* memory synopsis namespace std { struct allocator_arg_t { }; constexpr allocator_arg_t allocator_arg = allocator_arg_t(); template struct uses_allocator; template struct pointer_traits { typedef Ptr pointer; typedef
element_type; typedef
difference_type; template using rebind =
; static pointer pointer_to(
); }; template struct pointer_traits { typedef T* pointer; typedef T element_type; typedef ptrdiff_t difference_type; template using rebind = U*; static pointer pointer_to(
) noexcept; }; template struct allocator_traits { typedef Alloc allocator_type; typedef typename allocator_type::value_type value_type; typedef Alloc::pointer | value_type* pointer; typedef Alloc::const_pointer | pointer_traits::rebind const_pointer; typedef Alloc::void_pointer | pointer_traits::rebind void_pointer; typedef Alloc::const_void_pointer | pointer_traits::rebind const_void_pointer; typedef Alloc::difference_type | pointer_traits::difference_type difference_type; typedef Alloc::size_type | make_unsigned::type size_type; typedef Alloc::propagate_on_container_copy_assignment | false_type propagate_on_container_copy_assignment; typedef Alloc::propagate_on_container_move_assignment | false_type propagate_on_container_move_assignment; typedef Alloc::propagate_on_container_swap | false_type propagate_on_container_swap; typedef Alloc::is_always_equal | is_empty is_always_equal; template using rebind_alloc = Alloc::rebind::other | Alloc; template using rebind_traits = allocator_traits>; static pointer allocate(allocator_type& a, size_type n); static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; template static void construct(allocator_type& a, T* p, Args&&... args); template static void destroy(allocator_type& a, T* p); static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); }; template <> class allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template class allocator { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T* pointer; typedef const T* const_pointer; typedef typename add_lvalue_reference::type reference; typedef typename add_lvalue_reference::type const_reference; typedef T value_type; template struct rebind {typedef allocator other;}; allocator() noexcept; allocator(const allocator&) noexcept; template allocator(const allocator&) noexcept; ~allocator(); pointer address(reference x) const noexcept; const_pointer address(const_reference x) const noexcept; pointer allocate(size_type, allocator::const_pointer hint = 0); void deallocate(pointer p, size_type n) noexcept; size_type max_size() const noexcept; template void construct(U* p, Args&&... args); template void destroy(U* p); }; template bool operator==(const allocator&, const allocator&) noexcept; template bool operator!=(const allocator&, const allocator&) noexcept; template class raw_storage_iterator : public iterator // purposefully not C++03 { public: explicit raw_storage_iterator(OutputIterator x); raw_storage_iterator& operator*(); raw_storage_iterator& operator=(const T& element); raw_storage_iterator& operator++(); raw_storage_iterator operator++(int); }; template pair get_temporary_buffer(ptrdiff_t n) noexcept; template void return_temporary_buffer(T* p) noexcept; template T* addressof(T& r) noexcept; template T* addressof(const T&& r) noexcept = delete; template ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); template ForwardIterator uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); template void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); template ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); template void destroy_at(T* location); template void destroy(ForwardIterator first, ForwardIterator last); template ForwardIterator destroy_n(ForwardIterator first, Size n); template ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result); template pair uninitialized_move_n(InputIterator first, Size n, ForwardIterator result); template void uninitialized_value_construct(ForwardIterator first, ForwardIterator last); template ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n); template void uninitialized_default_construct(ForwardIterator first, ForwardIterator last); template ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); template struct auto_ptr_ref {}; // removed in C++17 template class auto_ptr // removed in C++17 { public: typedef X element_type; explicit auto_ptr(X* p =0) throw(); auto_ptr(auto_ptr&) throw(); template auto_ptr(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr&) throw(); template auto_ptr& operator=(auto_ptr&) throw(); auto_ptr& operator=(auto_ptr_ref r) throw(); ~auto_ptr() throw(); typename add_lvalue_reference::type operator*() const throw(); X* operator->() const throw(); X* get() const throw(); X* release() throw(); void reset(X* p =0) throw(); auto_ptr(auto_ptr_ref) throw(); template operator auto_ptr_ref() throw(); template operator auto_ptr() throw(); }; template struct default_delete { constexpr default_delete() noexcept = default; template default_delete(const default_delete&) noexcept; void operator()(T*) const noexcept; }; template struct default_delete { constexpr default_delete() noexcept = default; void operator()(T*) const noexcept; template void operator()(U*) const = delete; }; template > class unique_ptr { public: typedef see below pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d1) noexcept; unique_ptr(pointer p, see below d2) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } template unique_ptr(unique_ptr&& u) noexcept; template unique_ptr(auto_ptr&& u) noexcept; // removed in C++17 // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; template unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers typename add_lvalue_reference::type operator*() const; pointer operator->() const noexcept; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void swap(unique_ptr& u) noexcept; }; template class unique_ptr { public: typedef implementation-defined pointer; typedef T element_type; typedef D deleter_type; // constructors constexpr unique_ptr() noexcept; explicit unique_ptr(pointer p) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(pointer p, see below d) noexcept; unique_ptr(unique_ptr&& u) noexcept; unique_ptr(nullptr_t) noexcept : unique_ptr() { } // destructor ~unique_ptr(); // assignment unique_ptr& operator=(unique_ptr&& u) noexcept; unique_ptr& operator=(nullptr_t) noexcept; // observers T& operator[](size_t i) const; pointer get() const noexcept; deleter_type& get_deleter() noexcept; const deleter_type& get_deleter() const noexcept; explicit operator bool() const noexcept; // modifiers pointer release() noexcept; void reset(pointer p = pointer()) noexcept; void reset(nullptr_t) noexcept; template void reset(U) = delete; void swap(unique_ptr& u) noexcept; }; template void swap(unique_ptr& x, unique_ptr& y) noexcept; template bool operator==(const unique_ptr& x, const unique_ptr& y); template bool operator!=(const unique_ptr& x, const unique_ptr& y); template bool operator<(const unique_ptr& x, const unique_ptr& y); template bool operator<=(const unique_ptr& x, const unique_ptr& y); template bool operator>(const unique_ptr& x, const unique_ptr& y); template bool operator>=(const unique_ptr& x, const unique_ptr& y); template bool operator==(const unique_ptr& x, nullptr_t) noexcept; template bool operator==(nullptr_t, const unique_ptr& y) noexcept; template bool operator!=(const unique_ptr& x, nullptr_t) noexcept; template bool operator!=(nullptr_t, const unique_ptr& y) noexcept; template bool operator<(const unique_ptr& x, nullptr_t); template bool operator<(nullptr_t, const unique_ptr& y); template bool operator<=(const unique_ptr& x, nullptr_t); template bool operator<=(nullptr_t, const unique_ptr& y); template bool operator>(const unique_ptr& x, nullptr_t); template bool operator>(nullptr_t, const unique_ptr& y); template bool operator>=(const unique_ptr& x, nullptr_t); template bool operator>=(nullptr_t, const unique_ptr& y); class bad_weak_ptr : public std::exception { bad_weak_ptr() noexcept; }; template unique_ptr make_unique(Args&&... args); // C++14 template unique_ptr make_unique(size_t n); // C++14 template unspecified make_unique(Args&&...) = delete; // C++14, T == U[N] template class shared_ptr { public: typedef T element_type; typedef weak_ptr weak_type; // C++17 // constructors: constexpr shared_ptr() noexcept; template explicit shared_ptr(Y* p); template shared_ptr(Y* p, D d); template shared_ptr(Y* p, D d, A a); template shared_ptr(nullptr_t p, D d); template shared_ptr(nullptr_t p, D d, A a); template shared_ptr(const shared_ptr& r, T *p) noexcept; shared_ptr(const shared_ptr& r) noexcept; template shared_ptr(const shared_ptr& r) noexcept; shared_ptr(shared_ptr&& r) noexcept; template shared_ptr(shared_ptr&& r) noexcept; template explicit shared_ptr(const weak_ptr& r); template shared_ptr(auto_ptr&& r); // removed in C++17 template shared_ptr(unique_ptr&& r); shared_ptr(nullptr_t) : shared_ptr() { } // destructor: ~shared_ptr(); // assignment: shared_ptr& operator=(const shared_ptr& r) noexcept; template shared_ptr& operator=(const shared_ptr& r) noexcept; shared_ptr& operator=(shared_ptr&& r) noexcept; template shared_ptr& operator=(shared_ptr&& r); template shared_ptr& operator=(auto_ptr&& r); // removed in C++17 template shared_ptr& operator=(unique_ptr&& r); // modifiers: void swap(shared_ptr& r) noexcept; void reset() noexcept; template void reset(Y* p); template void reset(Y* p, D d); template void reset(Y* p, D d, A a); // observers: T* get() const noexcept; T& operator*() const noexcept; T* operator->() const noexcept; long use_count() const noexcept; bool unique() const noexcept; explicit operator bool() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; // shared_ptr comparisons: template bool operator==(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator!=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator<=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator>=(shared_ptr const& a, shared_ptr const& b) noexcept; template bool operator==(const shared_ptr& x, nullptr_t) noexcept; template bool operator==(nullptr_t, const shared_ptr& y) noexcept; template bool operator!=(const shared_ptr& x, nullptr_t) noexcept; template bool operator!=(nullptr_t, const shared_ptr& y) noexcept; template bool operator<(const shared_ptr& x, nullptr_t) noexcept; template bool operator<(nullptr_t, const shared_ptr& y) noexcept; template bool operator<=(const shared_ptr& x, nullptr_t) noexcept; template bool operator<=(nullptr_t, const shared_ptr& y) noexcept; template bool operator>(const shared_ptr& x, nullptr_t) noexcept; template bool operator>(nullptr_t, const shared_ptr& y) noexcept; template bool operator>=(const shared_ptr& x, nullptr_t) noexcept; template bool operator>=(nullptr_t, const shared_ptr& y) noexcept; // shared_ptr specialized algorithms: template void swap(shared_ptr& a, shared_ptr& b) noexcept; // shared_ptr casts: template shared_ptr static_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr dynamic_pointer_cast(shared_ptr const& r) noexcept; template shared_ptr const_pointer_cast(shared_ptr const& r) noexcept; // shared_ptr I/O: template basic_ostream& operator<< (basic_ostream& os, shared_ptr const& p); // shared_ptr get_deleter: template D* get_deleter(shared_ptr const& p) noexcept; template shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); template class weak_ptr { public: typedef T element_type; // constructors constexpr weak_ptr() noexcept; template weak_ptr(shared_ptr const& r) noexcept; weak_ptr(weak_ptr const& r) noexcept; template weak_ptr(weak_ptr const& r) noexcept; weak_ptr(weak_ptr&& r) noexcept; // C++14 template weak_ptr(weak_ptr&& r) noexcept; // C++14 // destructor ~weak_ptr(); // assignment weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(weak_ptr const& r) noexcept; template weak_ptr& operator=(shared_ptr const& r) noexcept; weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 template weak_ptr& operator=(weak_ptr&& r) noexcept; // C++14 // modifiers void swap(weak_ptr& r) noexcept; void reset() noexcept; // observers long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; template bool owner_before(shared_ptr const& b) const noexcept; template bool owner_before(weak_ptr const& b) const noexcept; }; // weak_ptr specialized algorithms: template void swap(weak_ptr& a, weak_ptr& b) noexcept; // class owner_less: template struct owner_less; template struct owner_less> : binary_function, shared_ptr, bool> { typedef bool result_type; bool operator()(shared_ptr const&, shared_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template struct owner_less> : binary_function, weak_ptr, bool> { typedef bool result_type; bool operator()(weak_ptr const&, weak_ptr const&) const noexcept; bool operator()(shared_ptr const&, weak_ptr const&) const noexcept; bool operator()(weak_ptr const&, shared_ptr const&) const noexcept; }; template <> // Added in C++14 struct owner_less { template bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const noexcept; template bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const noexcept; typedef void is_transparent; }; template class enable_shared_from_this { protected: constexpr enable_shared_from_this() noexcept; enable_shared_from_this(enable_shared_from_this const&) noexcept; enable_shared_from_this& operator=(enable_shared_from_this const&) noexcept; ~enable_shared_from_this(); public: shared_ptr shared_from_this(); shared_ptr shared_from_this() const; }; template bool atomic_is_lock_free(const shared_ptr* p); template shared_ptr atomic_load(const shared_ptr* p); template shared_ptr atomic_load_explicit(const shared_ptr* p, memory_order mo); template void atomic_store(shared_ptr* p, shared_ptr r); template void atomic_store_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template shared_ptr atomic_exchange(shared_ptr* p, shared_ptr r); template shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template bool atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_strong( shared_ptr* p, shared_ptr* v, shared_ptr w); template bool atomic_compare_exchange_weak_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); template bool atomic_compare_exchange_strong_explicit(shared_ptr* p, shared_ptr* v, shared_ptr w, memory_order success, memory_order failure); // Hash support template struct hash; template struct hash >; template struct hash >; // Pointer safety enum class pointer_safety { relaxed, preferred, strict }; void declare_reachable(void *p); template T *undeclare_reachable(T *p); void declare_no_pointers(char *p, size_t n); void undeclare_no_pointers(char *p, size_t n); pointer_safety get_pointer_safety() noexcept; void* align(size_t alignment, size_t size, void*& ptr, size_t& space); } // std */ #include <__config> #include #include #include #include #include #include #include #include #include <__functional_base> #include #include #include #include #include #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include #endif #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD template inline _LIBCPP_ALWAYS_INLINE _ValueType __libcpp_relaxed_load(_ValueType const* __value) { #if !defined(_LIBCPP_HAS_NO_THREADS) && \ defined(__ATOMIC_RELAXED) && \ (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) return __atomic_load_n(__value, __ATOMIC_RELAXED); #else return *__value; #endif } template inline _LIBCPP_ALWAYS_INLINE _ValueType __libcpp_acquire_load(_ValueType const* __value) { #if !defined(_LIBCPP_HAS_NO_THREADS) && \ defined(__ATOMIC_ACQUIRE) && \ (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) return __atomic_load_n(__value, __ATOMIC_ACQUIRE); #else return *__value; #endif } // addressof moved to template class allocator; template <> class _LIBCPP_TEMPLATE_VIS allocator { public: typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template struct rebind {typedef allocator<_Up> other;}; }; template <> class _LIBCPP_TEMPLATE_VIS allocator { public: typedef const void* pointer; typedef const void* const_pointer; typedef const void value_type; template struct rebind {typedef allocator<_Up> other;}; }; // pointer_traits template struct __has_element_type { private: struct __two {char __lx; char __lxx;}; template static __two __test(...); template static char __test(typename _Up::element_type* = 0); public: static const bool value = sizeof(__test<_Tp>(0)) == 1; }; template ::value> struct __pointer_traits_element_type; template struct __pointer_traits_element_type<_Ptr, true> { typedef typename _Ptr::element_type type; }; #ifndef _LIBCPP_HAS_NO_VARIADICS template