Merge to upstream r293197.

Bug: http://b/34740564
Test: make checkbuild && ./run_tests.py  # Tested aosp_sailfish-eng
Change-Id: I33320f72d9170548010c023bd28f03578461b5ff
This commit is contained in:
Dan Albert
2017-01-26 18:55:51 -08:00
3317 changed files with 142487 additions and 23981 deletions

View File

@@ -1,4 +1,4 @@
{ {
"project_id" : "libcxx", "project_id" : "libcxx",
"conduit_uri" : "http://reviews.llvm.org/" "conduit_uri" : "https://reviews.llvm.org/"
} }

12
.clang-format Normal file
View File

@@ -0,0 +1,12 @@
BasedOnStyle: LLVM
---
Language: Cpp
AlwaysBreakTemplateDeclarations: true
PointerAlignment: Left
# Disable formatting options which may break tests.
SortIncludes: false
ReflowComments: false
---

7
.gitignore vendored
View File

@@ -52,3 +52,10 @@ docs/_build/
# PyBuilder # PyBuilder
target/ target/
# MSVC libraries test harness
env.lst
keep.lst
# Editor by-products
.vscode/

View File

@@ -3,7 +3,7 @@
#=============================================================================== #===============================================================================
# Setup Project # Setup Project
#=============================================================================== #===============================================================================
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.4.3)
if(POLICY CMP0042) if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
@@ -19,23 +19,26 @@ set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH}
) )
# Find the LLVM sources and simulate LLVM CMake options.
include(HandleOutOfTreeLLVM)
if (LIBCXX_BUILT_STANDALONE) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(libcxx CXX C) project(libcxx CXX C)
set(PACKAGE_NAME libcxx) set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION trunk-svn) set(PACKAGE_VERSION 4.0.0svn)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
# Find the LLVM sources and simulate LLVM CMake options.
include(HandleOutOfTreeLLVM)
endif() endif()
if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND) if (LIBCXX_STANDALONE_BUILD)
message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: " include(FindPythonInterp)
"llvm-config not found and LLVM_PATH not defined.\n" if( NOT PYTHONINTERP_FOUND )
"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config " message(WARNING "Failed to find python interpreter. "
"or -DLLVM_PATH=path/to/llvm-source-root.") "The libc++ test suite will be disabled.")
set(LLVM_INCLUDE_TESTS OFF)
endif()
endif() endif()
# Require out of source build. # Require out of source build.
@@ -45,40 +48,95 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." 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 # Setup CMake Options
#=============================================================================== #===============================================================================
include(CMakeDependentOption)
# Basic options --------------------------------------------------------------- # Basic options ---------------------------------------------------------------
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) 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) option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
option(LIBCXX_ENABLE_FILESYSTEM
"Build filesystem as part of libc++experimental.a" ${LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY})
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) 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}) option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS})
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
"Define suffix of library directory name (32/64)") "Define suffix of library directory name (32/64)")
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF) 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++.") set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) 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 --------------------------------------------------------- # ABI Library options ---------------------------------------------------------
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING set(LIBCXX_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use." FORCE) "Specify C++ ABI library to use.")
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) set(CXXABIS none default libcxxabi libcxxrt libstdc++ libsupc++ vcruntime)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
# FIXME: This is a temporary hack to force LLVM buildbots to store
# the fixed cache entry instead of the previous cache entry. This is needed
# because some LLVM buildbots don't clear their cache. It will be removed
# once all LLVM bots have been run.
if (LIBCXX_CXX_ABI STREQUAL "")
set(LIBCXX_CXX_ABI "default" CACHE STRING
"Specify the C++ ABI library to use." FORCE)
endif()
# Setup the default options if LIBCXX_CXX_ABI is not specified. # Setup the default options if LIBCXX_CXX_ABI is not specified.
if (NOT LIBCXX_CXX_ABI) if (LIBCXX_CXX_ABI STREQUAL "default")
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND find_path(
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") 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 ((NOT LIBCXX_STANDALONE_BUILD OR HAVE_LIBCXXABI) AND
IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
set(LIBCXX_CXX_ABI_INTREE 1) set(LIBCXX_CXX_ABI_INTREE 1)
else() else()
set(LIBCXX_CXX_ABI_LIBNAME "none") if (LIBCXX_TARGETING_MSVC)
# FIXME: Figure out how to configure the ABI library on Windows.
set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
else()
set(LIBCXX_CXX_ABI_LIBNAME "default")
endif()
endif() endif()
else() else()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
@@ -96,6 +154,7 @@ option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF)
if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY 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 "none"
AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "default"
AND PYTHONINTERP_FOUND AND PYTHONINTERP_FOUND
AND LIBCXX_ENABLE_SHARED) AND LIBCXX_ENABLE_SHARED)
set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON)
@@ -126,12 +185,20 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
"Build libc++ with support for a monotonic clock. "Build libc++ with support for a monotonic clock.
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) 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_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 ---------------------------------------------------------------- # Misc options ----------------------------------------------------------------
# FIXME: Turn -pedantic back ON. It is currently off because it warns # FIXME: Turn -pedantic back ON. It is currently off because it warns
# about #include_next which is used everywhere. # about #include_next which is used everywhere.
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." 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) option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
@@ -165,6 +232,11 @@ option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE"
# Check option configurations # 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 # Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
# LIBCXX_ENABLE_THREADS is on. # LIBCXX_ENABLE_THREADS is on.
if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
@@ -172,6 +244,35 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
" when LIBCXX_ENABLE_THREADS is also set to OFF.") " when LIBCXX_ENABLE_THREADS is also set to OFF.")
endif() 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 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
# is ON. # is ON.
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
@@ -195,6 +296,9 @@ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
else() else()
message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
endif() 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() endif()
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
@@ -227,7 +331,9 @@ endif()
set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_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}) set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
@@ -237,13 +343,36 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
# LIBCXX_COMPILE_FLAGS: Compile only flags. # LIBCXX_COMPILE_FLAGS: Compile only flags.
# LIBCXX_LINK_FLAGS: Linker 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_COMPILE_FLAGS "")
set(LIBCXX_LINK_FLAGS "") set(LIBCXX_LINK_FLAGS "")
set(LIBCXX_LIBRARIES "") 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. # Configure compiler.
include(config-ix) include(config-ix)
if (LIBCXX_USE_COMPILER_RT)
list(APPEND LIBCXX_LINK_FLAGS "-rtlib=compiler-rt")
endif()
# Configure coverage options. # Configure coverage options.
if (LIBCXX_GENERATE_COVERAGE) if (LIBCXX_GENERATE_COVERAGE)
include(CodeCoverage) include(CodeCoverage)
@@ -251,6 +380,11 @@ if (LIBCXX_GENERATE_COVERAGE)
endif() endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) 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 # Setup Compiler Flags
@@ -258,22 +392,36 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
include(HandleLibCXXABI) # Setup the ABI library flags include(HandleLibCXXABI) # Setup the ABI library flags
# Include macros for adding and removing libc++ flags. if (NOT LIBCXX_STANDALONE_BUILD)
include(HandleLibcxxFlags)
# Remove flags that may have snuck in. # Remove flags that may have snuck in.
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
-stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32) -lc++abi)
endif()
remove_flags(-stdlib=libc++ -stdlib=libstdc++)
# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. # 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_PEqDANTIC.
# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
# so they don't get transformed into -Wno and -errors respectivly. # so they don't get transformed into -Wno and -errors respectivly.
remove_flags(-Wno-pedantic -pedantic-errors -pedantic) remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
# Required flags ============================================================== # Required flags ==============================================================
add_compile_flags_if_supported(-std=c++11) set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG) if (LIBCXX_HAS_MUSL_LIBC)
message(FATAL_ERROR "C++11 is required but the compiler does not support -std=c++11") # 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() endif()
# On all systems the system c++ standard library headers need to be excluded. # On all systems the system c++ standard library headers need to be excluded.
@@ -282,18 +430,30 @@ endif()
# headers # headers
add_compile_flags_if_supported(-nostdinc++) add_compile_flags_if_supported(-nostdinc++)
# Target flags ================================================================ # Hide all inline function definitions which have not explicitly been marked
add_flags_if(LIBCXX_BUILD_32_BITS -m32) # visible. This prevents new definitions for inline functions from appearing in
add_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}") # the dylib when get ODR used by another function.
add_flags_if(LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}") add_compile_flags_if_supported(-fvisibility-inlines-hidden)
add_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
# Let the library headers know they are currently being used to build the
# library.
add_definitions(-D_LIBCPP_BUILDING_LIBRARY)
# Warning flags =============================================================== # Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
add_compile_flags_if_supported( add_compile_flags_if_supported(
-Wall -W -Wwrite-strings -Wall -Wextra -W -Wwrite-strings
-Wno-unused-parameter -Wno-long-long -Wno-unused-parameter -Wno-long-long
-Werror=return-type) -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)
endif()
if (LIBCXX_ENABLE_WERROR) if (LIBCXX_ENABLE_WERROR)
add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-Werror)
add_compile_flags_if_supported(-WX) add_compile_flags_if_supported(-WX)
@@ -305,6 +465,9 @@ endif()
if (LIBCXX_ENABLE_PEDANTIC) if (LIBCXX_ENABLE_PEDANTIC)
add_compile_flags_if_supported(-pedantic) add_compile_flags_if_supported(-pedantic)
endif() endif()
if (LIBCXX_DISABLE_MACRO_CONFLICT_WARNINGS)
add_definitions(-D_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
endif()
# Exception flags ============================================================= # Exception flags =============================================================
if (LIBCXX_ENABLE_EXCEPTIONS) if (LIBCXX_ENABLE_EXCEPTIONS)
@@ -324,22 +487,41 @@ if (NOT LIBCXX_ENABLE_RTTI)
add_compile_flags_if_supported(-fno-rtti) add_compile_flags_if_supported(-fno-rtti)
endif() 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 ============================================================= # Assertion flags =============================================================
define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
if (LIBCXX_ENABLE_ASSERTIONS) 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. # MSVC doesn't like _DEBUG on release builds. See PR 4379.
define_if_not(MSVC -D_DEBUG) define_if_not(LIBCXX_TARGETING_MSVC -D_DEBUG)
endif() endif()
# Feature flags =============================================================== # Modules flags ===============================================================
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) # 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 ============================================================= # Sanitizer flags =============================================================
# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do # Configure for sanitizers. If LIBCXX_STANDALONE_BUILD then we have to do
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
if (LIBCXX_BUILT_STANDALONE) if (LIBCXX_STANDALONE_BUILD)
set(LLVM_USE_SANITIZER "" CACHE STRING set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build the library and tests") "Define the sanitizer used to build the library and tests")
# NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
@@ -384,17 +566,32 @@ 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_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_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) 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) if (LIBCXX_NEEDS_SITE_CONFIG)
configure_file( configure_file("include/__config_site.in"
include/__config_site.in "${LIBCXX_BINARY_DIR}/__config_site"
${LIBCXX_BINARY_DIR}/__config_site
@ONLY) @ONLY)
# Provide the config definitions by included the generated __config_site # Provide the config definitions by included the generated __config_site
# file at compile time. # 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") add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
endif() endif()
endif()
#=============================================================================== #===============================================================================
# Setup Source Code And Tests # Setup Source Code And Tests
@@ -403,8 +600,13 @@ include_directories(include)
add_subdirectory(include) add_subdirectory(include)
add_subdirectory(lib) add_subdirectory(lib)
if (LIBCXX_INCLUDE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
if (LIBCXX_INCLUDE_TESTS) if (LIBCXX_INCLUDE_TESTS)
add_subdirectory(test) add_subdirectory(test)
add_subdirectory(lib/abi)
endif() endif()
if (LIBCXX_INCLUDE_DOCS) if (LIBCXX_INCLUDE_DOCS)
add_subdirectory(docs) add_subdirectory(docs)

View File

@@ -37,6 +37,10 @@ E: mclow.lists@gmail.com
E: marshall@idio.com E: marshall@idio.com
D: C++14 support, patches and bug fixes. D: C++14 support, patches and bug fixes.
N: Jonathan B Coe
E: jbcoe@me.com
D: Implementation of propagate_const.
N: Eric Fiselier N: Eric Fiselier
E: eric@efcs.ca E: eric@efcs.ca
D: LFTS support, patches and bug fixes. D: LFTS support, patches and bug fixes.
@@ -76,6 +80,10 @@ N: Andrew Morrow
E: andrew.c.morrow@gmail.com E: andrew.c.morrow@gmail.com
D: Minor patches and Linux fixes. D: Minor patches and Linux fixes.
N: Michael Park
E: mpark@apache.org
D: Implementation of <variant>.
N: Arvid Picciani N: Arvid Picciani
E: aep at exys dot org E: aep at exys dot org
D: Minor patches and musl port. D: Minor patches and musl port.

View File

@@ -14,7 +14,7 @@ Full text of the relevant licenses is included below.
University of Illinois/NCSA University of Illinois/NCSA
Open Source License Open Source License
Copyright (c) 2009-2016 by the contributors listed in CREDITS.TXT Copyright (c) 2009-2017 by the contributors listed in CREDITS.TXT
All rights reserved. All rights reserved.

28
NOTES.TXT Normal file
View File

@@ -0,0 +1,28 @@
//===---------------------------------------------------------------------===//
// Notes relating to various libc++ tasks
//===---------------------------------------------------------------------===//
This file contains notes about various libc++ tasks and processes.
//===---------------------------------------------------------------------===//
// Post-Release TODO
//===---------------------------------------------------------------------===//
These notes contain a list of things that must be done after branching for
an LLVM release.
1. Update _LIBCPP_VERSION in `__config`
2. Update the __libcpp_version file.
3. Update the version number in `docs/conf.py`
4. Create ABI lists for the previous release under `lib/abi`
//===---------------------------------------------------------------------===//
// Adding a new header TODO
//===---------------------------------------------------------------------===//
These notes contain a list of things that must be done upon adding a new header
to libc++.
1. Add a test under `test/libcxx` that the header defines `_LIBCPP_VERSION`.
2. Update `test/libcxx/double_include.sh.cpp` to include the new header.
3. Create a submodule in `include/module.modulemap` for the new header.

View File

@@ -1,46 +1,19 @@
This is meant to be a general place to list things that should be done "someday" This is meant to be a general place to list things that should be done "someday"
3.8 Release Goals
=================
* LFTS v1 (EricWF, MClow)
* Filesystem TS (EricWF)
* ASIO TS (MClow)
* <regex> Improvements (MClow)
* Setup ABI Versioning policy (EricWF)
* Fix PR19302 - Fix UB in list and __tree.
ABI Related Tasks
=================
* Explicitly manage and verify symbols exported from the dylib.
* Explore using namespaces for managing symbol visibility.
* Introduce and document ABI versioning/evolution policy.
CXX Runtime Library Tasks CXX Runtime Library Tasks
========================= =========================
* Cleanup #ifdef hell in sources files that supports the different ABI libraries.
* Fix that CMake always link to /usr/lib/libc++abi.dylib on OS X. * Fix that CMake always link to /usr/lib/libc++abi.dylib on OS X.
* Fix selection of ABI symbol list on OS X.
* Have CMake generate linker scripts for libc++.so that it properly links the
runtime library.
* Look into mirroring libsupc++'s typeinfo vtable layout when libsupc++/libstdc++ * Look into mirroring libsupc++'s typeinfo vtable layout when libsupc++/libstdc++
is used as the runtime library. is used as the runtime library.
* Audit libraries that CMake links into libc++. Are they all required?
* Investigate and document interoperability between libc++ and libstdc++ on * Investigate and document interoperability between libc++ and libstdc++ on
linux. Do this for every supported c++ runtime library. linux. Do this for every supported c++ runtime library.
Atomic Related Tasks Atomic Related Tasks
==================== ====================
* Enable mixing of clang and GCC atomics internally. Currently some
parts of libc++ use atomics only when clang provides them.
(see memory@5380 for an example)
* Audit use of libatomic builtins in <atomic> with GCC.
* future should use <atomic> for synchronization. * future should use <atomic> for synchronization.
Test Suite Tasks Test Suite Tasks
================ ================
* Move all libc++ specific tests from test/std into test/libcxx.
* Improve how LIT handles compiler warnings.
* Improve the quality and portability of the locale test data. * Improve the quality and portability of the locale test data.
* Convert failure tests to use Clang Verify. * Convert failure tests to use Clang Verify.
@@ -50,7 +23,4 @@ Misc Tasks
* run clang-tidy on libc++ * run clang-tidy on libc++
* Document the "conditionally-supported" bits of libc++ * Document the "conditionally-supported" bits of libc++
* Look at basic_string's move assignment operator, re LWG 2063 and POCMA * Look at basic_string's move assignment operator, re LWG 2063 and POCMA
* libc++ is missing try_emplace
* Put a static_assert in std::allocator to deny const/volatile types (LWG 2447) * Put a static_assert in std::allocator to deny const/volatile types (LWG 2447)
* Document support (or lack of) for C++11 libraries in C++03.
* Document supported compilers.

154
benchmarks/CMakeLists.txt Normal file
View File

@@ -0,0 +1,154 @@
include(ExternalProject)
include(CheckCXXCompilerFlag)
#==============================================================================
# Build Google Benchmark for libc++
#==============================================================================
set(BENCHMARK_LIBCXX_COMPILE_FLAGS
-Wno-unused-command-line-argument
-nostdinc++
-isystem ${LIBCXX_SOURCE_DIR}/include
-L${LIBCXX_LIBRARY_DIR}
-Wl,-rpath,${LIBCXX_LIBRARY_DIR}
)
if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS
-L${LIBCXX_CXX_ABI_LIBRARY_PATH}
-Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH})
endif()
split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS)
ExternalProject_Add(google-benchmark-libcxx
EXCLUDE_FROM_ALL ON
DEPENDS cxx
PREFIX benchmark-libcxx
SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx
CMAKE_CACHE_ARGS
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=RELEASE
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_LIBCXX_COMPILE_FLAGS}
-DBENCHMARK_USE_LIBCXX:BOOL=ON
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
#==============================================================================
# Build Google Benchmark for the native stdlib
#==============================================================================
set(BENCHMARK_NATIVE_TARGET_FLAGS)
if (LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN)
set(BENCHMARK_NATIVE_TARGET_FLAGS
-gcc-toolchain ${LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN})
endif()
split_list(BENCHMARK_NATIVE_TARGET_FLAGS)
if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
ExternalProject_Add(google-benchmark-native
EXCLUDE_FROM_ALL ON
PREFIX benchmark-native
SOURCE_DIR ${LIBCXX_SOURCE_DIR}/utils/google-benchmark
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native
CMAKE_CACHE_ARGS
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${BENCHMARK_NATIVE_TARGET_FLAGS}
-DCMAKE_BUILD_TYPE:STRING=RELEASE
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
endif()
#==============================================================================
# Benchmark tests configuration
#==============================================================================
add_custom_target(cxx-benchmarks)
set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx)
set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native)
set(BENCHMARK_TEST_COMPILE_FLAGS
-std=c++14 -O2
-I${BENCHMARK_LIBCXX_INSTALL}/include
-I${LIBCXX_SOURCE_DIR}/test/support
)
set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS
-nostdinc++
-isystem ${LIBCXX_SOURCE_DIR}/include
${BENCHMARK_TEST_COMPILE_FLAGS}
-Wno-user-defined-literals
)
set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS
-nodefaultlibs
-L${BENCHMARK_LIBCXX_INSTALL}/lib/
)
set(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS
${BENCHMARK_NATIVE_TARGET_FLAGS}
${BENCHMARK_TEST_COMPILE_FLAGS}
)
set(BENCHMARK_TEST_NATIVE_LINK_FLAGS
${BENCHMARK_NATIVE_TARGET_FLAGS}
-L${BENCHMARK_NATIVE_INSTALL}/lib
)
split_list(BENCHMARK_TEST_COMPILE_FLAGS)
split_list(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS)
split_list(BENCHMARK_TEST_LIBCXX_LINK_FLAGS)
split_list(BENCHMARK_TEST_NATIVE_COMPILE_FLAGS)
split_list(BENCHMARK_TEST_NATIVE_LINK_FLAGS)
macro(add_benchmark_test name source_file)
set(libcxx_target ${name}_libcxx)
add_executable(${libcxx_target} EXCLUDE_FROM_ALL ${source_file})
add_dependencies(${libcxx_target} cxx google-benchmark-libcxx)
add_dependencies(cxx-benchmarks ${libcxx_target})
if (LIBCXX_ENABLE_SHARED)
target_link_libraries(${libcxx_target} cxx_shared)
else()
target_link_libraries(${libcxx_target} cxx_static)
endif()
if (TARGET cxx_experimental)
target_link_libraries(${libcxx_target} cxx_experimental)
endif()
target_link_libraries(${libcxx_target} -lbenchmark)
set_target_properties(${libcxx_target}
PROPERTIES
OUTPUT_NAME "${name}.libcxx.out"
COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}"
LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}")
if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
set(native_target ${name}_native)
add_executable(${native_target} EXCLUDE_FROM_ALL ${source_file})
add_dependencies(${native_target} google-benchmark-native
google-benchmark-libcxx)
target_link_libraries(${native_target} -lbenchmark)
if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++")
target_link_libraries(${native_target} -lstdc++fs)
elseif (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libc++")
target_link_libraries(${native_target} -lc++experimental)
endif()
if (LIBCXX_HAS_PTHREAD_LIB)
target_link_libraries(${native_target} -pthread)
endif()
add_dependencies(cxx-benchmarks ${native_target})
set_target_properties(${native_target}
PROPERTIES
OUTPUT_NAME "${name}.native.out"
INCLUDE_DIRECTORIES ""
COMPILE_FLAGS "${BENCHMARK_TEST_NATIVE_COMPILE_FLAGS}"
LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}")
endif()
endmacro()
#==============================================================================
# Register Benchmark tests
#==============================================================================
file(GLOB BENCHMARK_TESTS "*.bench.cpp")
foreach(test_path ${BENCHMARK_TESTS})
get_filename_component(test_file "${test_path}" NAME)
string(REPLACE ".bench.cpp" "" test_name "${test_file}")
if (NOT DEFINED ${test_name}_REPORTED)
message(STATUS "Adding Benchmark: ${test_file}")
# Only report the adding of the benchmark once.
set(${test_name}_REPORTED ON CACHE INTERNAL "")
endif()
add_benchmark_test(${test_name} ${test_file})
endforeach()

View File

@@ -0,0 +1,113 @@
#ifndef BENCHMARK_CONTAINER_BENCHMARKS_HPP
#define BENCHMARK_CONTAINER_BENCHMARKS_HPP
#include <cassert>
#include "benchmark/benchmark_api.h"
namespace ContainerBenchmarks {
template <class Container, class GenInputs>
void BM_ConstructIterIter(benchmark::State& st, Container, GenInputs gen) {
auto in = gen(st.range(0));
const auto begin = in.begin();
const auto end = in.end();
benchmark::DoNotOptimize(&in);
while (st.KeepRunning()) {
Container c(begin, end);
benchmark::DoNotOptimize(c.data());
}
}
template <class Container, class GenInputs>
void BM_InsertValue(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.end();
while (st.KeepRunning()) {
c.clear();
for (auto it = in.begin(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.insert(*it).first));
}
benchmark::ClobberMemory();
}
}
template <class Container, class GenInputs>
void BM_InsertValueRehash(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.end();
while (st.KeepRunning()) {
c.clear();
c.rehash(16);
for (auto it = in.begin(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.insert(*it).first));
}
benchmark::ClobberMemory();
}
}
template <class Container, class GenInputs>
void BM_InsertDuplicate(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.end();
c.insert(in.begin(), in.end());
benchmark::DoNotOptimize(&c);
benchmark::DoNotOptimize(&in);
while (st.KeepRunning()) {
for (auto it = in.begin(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.insert(*it).first));
}
benchmark::ClobberMemory();
}
}
template <class Container, class GenInputs>
void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.end();
c.insert(in.begin(), in.end());
benchmark::DoNotOptimize(&c);
benchmark::DoNotOptimize(&in);
while (st.KeepRunning()) {
for (auto it = in.begin(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.emplace(*it).first));
}
benchmark::ClobberMemory();
}
}
template <class Container, class GenInputs>
static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
c.insert(in.begin(), in.end());
benchmark::DoNotOptimize(&(*c.begin()));
const auto end = in.data() + in.size();
while (st.KeepRunning()) {
for (auto it = in.data(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.find(*it)));
}
benchmark::ClobberMemory();
}
}
template <class Container, class GenInputs>
static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
c.rehash(8);
auto in = gen(st.range(0));
c.insert(in.begin(), in.end());
benchmark::DoNotOptimize(&(*c.begin()));
const auto end = in.data() + in.size();
while (st.KeepRunning()) {
for (auto it = in.data(); it != end; ++it) {
benchmark::DoNotOptimize(&(*c.find(*it)));
}
benchmark::ClobberMemory();
}
}
} // end namespace ContainerBenchmarks
#endif // BENCHMARK_CONTAINER_BENCHMARKS_HPP

View File

@@ -0,0 +1,142 @@
#ifndef BENCHMARK_GENERATE_INPUT_HPP
#define BENCHMARK_GENERATE_INPUT_HPP
#include <algorithm>
#include <random>
#include <vector>
#include <string>
#include <climits>
#include <cstddef>
static const char Letters[] = {
'0','1','2','3','4',
'5','6','7','8','9',
'A','B','C','D','E','F',
'G','H','I','J','K',
'L','M','N','O','P',
'Q','R','S','T','U',
'V','W','X','Y','Z',
'a','b','c','d','e','f',
'g','h','i','j','k',
'l','m','n','o','p',
'q','r','s','t','u',
'v','w','x','y','z'
};
static const std::size_t LettersSize = sizeof(Letters);
inline std::default_random_engine& getRandomEngine() {
static std::default_random_engine RandEngine(std::random_device{}());
return RandEngine;
}
inline char getRandomChar() {
std::uniform_int_distribution<> LettersDist(0, LettersSize-1);
return Letters[LettersDist(getRandomEngine())];
}
template <class IntT>
inline IntT getRandomInteger() {
std::uniform_int_distribution<IntT> dist;
return dist(getRandomEngine());
}
inline std::string getRandomString(std::size_t Len) {
std::string str(Len, 0);
std::generate_n(str.begin(), Len, &getRandomChar);
return str;
}
template <class IntT>
inline std::vector<IntT> getDuplicateIntegerInputs(size_t N) {
std::vector<IntT> inputs(N, static_cast<IntT>(-1));
return inputs;
}
template <class IntT>
inline std::vector<IntT> getSortedIntegerInputs(size_t N) {
std::vector<IntT> inputs;
for (size_t i=0; i < N; i += 1)
inputs.push_back(i);
return inputs;
}
template <class IntT>
std::vector<IntT> getSortedLargeIntegerInputs(size_t N) {
std::vector<IntT> inputs;
for (size_t i=0; i < N; ++i) {
inputs.push_back(i + N);
}
return inputs;
}
template <class IntT>
std::vector<IntT> getSortedTopBitsIntegerInputs(size_t N) {
std::vector<IntT> inputs = getSortedIntegerInputs<IntT>(N);
for (auto& E : inputs) E <<= ((sizeof(IntT) / 2) * CHAR_BIT);
return inputs;
}
template <class IntT>
inline std::vector<IntT> getReverseSortedIntegerInputs(size_t N) {
std::vector<IntT> inputs;
std::size_t i = N;
while (i > 0) {
--i;
inputs.push_back(i);
}
return inputs;
}
template <class IntT>
std::vector<IntT> getPipeOrganIntegerInputs(size_t N) {
std::vector<IntT> v; v.reserve(N);
for (size_t i = 0; i < N/2; ++i) v.push_back(i);
for (size_t i = N/2; i < N; ++i) v.push_back(N - i);
return v;
}
template <class IntT>
std::vector<IntT> getRandomIntegerInputs(size_t N) {
std::vector<IntT> inputs;
for (size_t i=0; i < N; ++i) {
inputs.push_back(getRandomInteger<IntT>());
}
return inputs;
}
inline std::vector<std::string> getDuplicateStringInputs(size_t N) {
std::vector<std::string> inputs(N, getRandomString(1024));
return inputs;
}
inline std::vector<std::string> getRandomStringInputs(size_t N) {
std::vector<std::string> inputs;
for (size_t i=0; i < N; ++i) {
inputs.push_back(getRandomString(1024));
}
return inputs;
}
inline std::vector<std::string> getSortedStringInputs(size_t N) {
std::vector<std::string> inputs = getRandomStringInputs(N);
std::sort(inputs.begin(), inputs.end());
return inputs;
}
inline std::vector<std::string> getReverseSortedStringInputs(size_t N) {
std::vector<std::string> inputs = getSortedStringInputs(N);
std::reverse(inputs.begin(), inputs.end());
return inputs;
}
inline std::vector<const char*> getRandomCStringInputs(size_t N) {
static std::vector<std::string> inputs = getRandomStringInputs(N);
std::vector<const char*> cinputs;
for (auto const& str : inputs)
cinputs.push_back(str.c_str());
return cinputs;
}
#endif // BENCHMARK_GENERATE_INPUT_HPP

View File

@@ -0,0 +1,62 @@
#include <unordered_set>
#include <vector>
#include <cstdint>
#include "benchmark/benchmark_api.h"
#include "GenerateInput.hpp"
constexpr std::size_t TestNumInputs = 1024;
template <class GenInputs>
void BM_Sort(benchmark::State& st, GenInputs gen) {
using ValueType = typename decltype(gen(0))::value_type;
const auto in = gen(st.range(0));
std::vector<ValueType> inputs[5];
auto reset_inputs = [&]() {
for (auto& C : inputs) {
C = in;
benchmark::DoNotOptimize(C.data());
}
};
reset_inputs();
while (st.KeepRunning()) {
for (auto& I : inputs) {
std::sort(I.data(), I.data() + I.size());
benchmark::DoNotOptimize(I.data());
}
st.PauseTiming();
reset_inputs();
benchmark::ClobberMemory();
st.ResumeTiming();
}
}
BENCHMARK_CAPTURE(BM_Sort, random_uint32,
getRandomIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_uint32,
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, sorted_descending_uint32,
getReverseSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, single_element_uint32,
getDuplicateIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, pipe_organ_uint32,
getPipeOrganIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, random_strings,
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, sorted_ascending_strings,
getSortedStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, sorted_descending_strings,
getReverseSortedStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Sort, single_element_strings,
getDuplicateStringInputs)->Arg(TestNumInputs);
BENCHMARK_MAIN()

View File

@@ -0,0 +1,138 @@
#include <experimental/filesystem>
#include "benchmark/benchmark_api.h"
#include "GenerateInput.hpp"
#include "test_iterators.h"
namespace fs = std::experimental::filesystem;
static const size_t TestNumInputs = 1024;
template <class GenInputs>
void BM_PathConstructString(benchmark::State &st, GenInputs gen) {
using namespace fs;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
benchmark::DoNotOptimize(PP.native().data());
while (st.KeepRunning()) {
const path P(PP.native());
benchmark::DoNotOptimize(P.native().data());
}
}
BENCHMARK_CAPTURE(BM_PathConstructString, large_string,
getRandomStringInputs)->Arg(TestNumInputs);
template <class GenInputs>
void BM_PathConstructCStr(benchmark::State &st, GenInputs gen) {
using namespace fs;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
benchmark::DoNotOptimize(PP.native().data());
while (st.KeepRunning()) {
const path P(PP.native().c_str());
benchmark::DoNotOptimize(P.native().data());
}
}
BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string,
getRandomStringInputs)->Arg(TestNumInputs);
template <template <class...> class ItType, class GenInputs>
void BM_PathConstructIter(benchmark::State &st, GenInputs gen) {
using namespace fs;
using Iter = ItType<std::string::const_iterator>;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
auto Start = Iter(PP.native().begin());
auto End = Iter(PP.native().end());
benchmark::DoNotOptimize(PP.native().data());
benchmark::DoNotOptimize(Start);
benchmark::DoNotOptimize(End);
while (st.KeepRunning()) {
const path P(Start, End);
benchmark::DoNotOptimize(P.native().data());
}
}
template <class GenInputs>
void BM_PathConstructInputIter(benchmark::State &st, GenInputs gen) {
BM_PathConstructIter<input_iterator>(st, gen);
}
template <class GenInputs>
void BM_PathConstructForwardIter(benchmark::State &st, GenInputs gen) {
BM_PathConstructIter<forward_iterator>(st, gen);
}
BENCHMARK_CAPTURE(BM_PathConstructInputIter, large_string,
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_PathConstructForwardIter, large_string,
getRandomStringInputs)->Arg(TestNumInputs);
template <class GenInputs>
void BM_PathIterateMultipleTimes(benchmark::State &st, GenInputs gen) {
using namespace fs;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
benchmark::DoNotOptimize(PP.native().data());
while (st.KeepRunning()) {
for (auto &E : PP) {
benchmark::DoNotOptimize(E.native().data());
}
benchmark::ClobberMemory();
}
}
BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements,
getRandomStringInputs)->Arg(TestNumInputs);
template <class GenInputs>
void BM_PathIterateOnce(benchmark::State &st, GenInputs gen) {
using namespace fs;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
benchmark::DoNotOptimize(PP.native().data());
while (st.KeepRunning()) {
const path P = PP.native();
for (auto &E : P) {
benchmark::DoNotOptimize(E.native().data());
}
benchmark::ClobberMemory();
}
}
BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements,
getRandomStringInputs)->Arg(TestNumInputs);
template <class GenInputs>
void BM_PathIterateOnceBackwards(benchmark::State &st, GenInputs gen) {
using namespace fs;
const auto in = gen(st.range(0));
path PP;
for (auto& Part : in)
PP /= Part;
benchmark::DoNotOptimize(PP.native().data());
while (st.KeepRunning()) {
const path P = PP.native();
const auto B = P.begin();
auto I = P.end();
while (I != B) {
--I;
benchmark::DoNotOptimize(*I);
}
benchmark::DoNotOptimize(*I);
}
}
BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements,
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_MAIN()

View File

@@ -0,0 +1,49 @@
#include <unordered_set>
#include <vector>
#include <cstdint>
#include "benchmark/benchmark_api.h"
#include "GenerateInput.hpp"
constexpr std::size_t MAX_STRING_LEN = 8 << 14;
// Benchmark when there is no match.
static void BM_StringFindNoMatch(benchmark::State &state) {
std::string s1(state.range(0), '-');
std::string s2(8, '*');
while (state.KeepRunning())
benchmark::DoNotOptimize(s1.find(s2));
}
BENCHMARK(BM_StringFindNoMatch)->Range(10, MAX_STRING_LEN);
// Benchmark when the string matches first time.
static void BM_StringFindAllMatch(benchmark::State &state) {
std::string s1(MAX_STRING_LEN, '-');
std::string s2(state.range(0), '-');
while (state.KeepRunning())
benchmark::DoNotOptimize(s1.find(s2));
}
BENCHMARK(BM_StringFindAllMatch)->Range(1, MAX_STRING_LEN);
// Benchmark when the string matches somewhere in the end.
static void BM_StringFindMatch1(benchmark::State &state) {
std::string s1(MAX_STRING_LEN / 2, '*');
s1 += std::string(state.range(0), '-');
std::string s2(state.range(0), '-');
while (state.KeepRunning())
benchmark::DoNotOptimize(s1.find(s2));
}
BENCHMARK(BM_StringFindMatch1)->Range(1, MAX_STRING_LEN / 4);
// Benchmark when the string matches somewhere from middle to the end.
static void BM_StringFindMatch2(benchmark::State &state) {
std::string s1(MAX_STRING_LEN / 2, '*');
s1 += std::string(state.range(0), '-');
s1 += std::string(state.range(0), '*');
std::string s2(state.range(0), '-');
while (state.KeepRunning())
benchmark::DoNotOptimize(s1.find(s2));
}
BENCHMARK(BM_StringFindMatch2)->Range(1, MAX_STRING_LEN / 4);
BENCHMARK_MAIN()

View File

@@ -0,0 +1,306 @@
#include <unordered_set>
#include <vector>
#include <functional>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include "benchmark/benchmark_api.h"
#include "ContainerBenchmarks.hpp"
#include "GenerateInput.hpp"
using namespace ContainerBenchmarks;
constexpr std::size_t TestNumInputs = 1024;
template <class _Size>
inline __attribute__((__always_inline__))
_Size loadword(const void* __p) {
_Size __r;
std::memcpy(&__r, __p, sizeof(__r));
return __r;
}
inline __attribute__((__always_inline__))
std::size_t rotate_by_at_least_1(std::size_t __val, int __shift) {
return (__val >> __shift) | (__val << (64 - __shift));
}
inline __attribute__((__always_inline__))
std::size_t hash_len_16(std::size_t __u, std::size_t __v) {
const std::size_t __mul = 0x9ddfea08eb382d69ULL;
std::size_t __a = (__u ^ __v) * __mul;
__a ^= (__a >> 47);
std::size_t __b = (__v ^ __a) * __mul;
__b ^= (__b >> 47);
__b *= __mul;
return __b;
}
template <std::size_t _Len>
inline __attribute__((__always_inline__))
std::size_t hash_len_0_to_8(const char* __s) {
static_assert(_Len == 4 || _Len == 8, "");
const uint64_t __a = loadword<uint32_t>(__s);
const uint64_t __b = loadword<uint32_t>(__s + _Len - 4);
return hash_len_16(_Len + (__a << 3), __b);
}
struct UInt32Hash {
UInt32Hash() = default;
inline __attribute__((__always_inline__))
std::size_t operator()(uint32_t data) const {
return hash_len_0_to_8<4>(reinterpret_cast<const char*>(&data));
}
};
struct UInt64Hash {
UInt64Hash() = default;
inline __attribute__((__always_inline__))
std::size_t operator()(uint64_t data) const {
return hash_len_0_to_8<8>(reinterpret_cast<const char*>(&data));
}
};
struct UInt128Hash {
UInt128Hash() = default;
inline __attribute__((__always_inline__))
std::size_t operator()(__uint128_t data) const {
const __uint128_t __mask = static_cast<std::size_t>(-1);
const std::size_t __a = (std::size_t)(data & __mask);
const std::size_t __b = (std::size_t)((data & (__mask << 64)) >> 64);
return hash_len_16(__a, rotate_by_at_least_1(__b + 16, 16)) ^ __b;
}
};
struct UInt32Hash2 {
UInt32Hash2() = default;
inline __attribute__((__always_inline__))
std::size_t operator()(uint32_t data) const {
const uint32_t __m = 0x5bd1e995;
const uint32_t __r = 24;
uint32_t __h = 4;
uint32_t __k = data;
__k *= __m;
__k ^= __k >> __r;
__k *= __m;
__h *= __m;
__h ^= __k;
__h ^= __h >> 13;
__h *= __m;
__h ^= __h >> 15;
return __h;
}
};
struct UInt64Hash2 {
UInt64Hash2() = default;
inline __attribute__((__always_inline__))
std::size_t operator()(uint64_t data) const {
return hash_len_0_to_8<8>(reinterpret_cast<const char*>(&data));
}
};
//----------------------------------------------------------------------------//
// BM_Hash
// ---------------------------------------------------------------------------//
template <class HashFn, class GenInputs>
void BM_Hash(benchmark::State& st, HashFn fn, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.data() + in.size();
std::size_t last_hash = 0;
benchmark::DoNotOptimize(&last_hash);
while (st.KeepRunning()) {
for (auto it = in.data(); it != end; ++it) {
benchmark::DoNotOptimize(last_hash += fn(*it));
}
benchmark::ClobberMemory();
}
}
BENCHMARK_CAPTURE(BM_Hash,
uint32_random_std_hash,
std::hash<uint32_t>{},
getRandomIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Hash,
uint32_random_custom_hash,
UInt32Hash{},
getRandomIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Hash,
uint32_top_std_hash,
std::hash<uint32_t>{},
getSortedTopBitsIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Hash,
uint32_top_custom_hash,
UInt32Hash{},
getSortedTopBitsIntegerInputs<uint32_t>) -> Arg(TestNumInputs);
//----------------------------------------------------------------------------//
// BM_InsertValue
// ---------------------------------------------------------------------------//
// Sorted Assending //
BENCHMARK_CAPTURE(BM_InsertValue,
unordered_set_uint32,
std::unordered_set<uint32_t>{},
getRandomIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertValue,
unordered_set_uint32_sorted,
std::unordered_set<uint32_t>{},
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
// Top Bytes //
BENCHMARK_CAPTURE(BM_InsertValue,
unordered_set_top_bits_uint32,
std::unordered_set<uint32_t>{},
getSortedTopBitsIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertValueRehash,
unordered_set_top_bits_uint32,
std::unordered_set<uint32_t, UInt32Hash>{},
getSortedTopBitsIntegerInputs<uint32_t>)->Arg(TestNumInputs);
// String //
BENCHMARK_CAPTURE(BM_InsertValue,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertValueRehash,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
//----------------------------------------------------------------------------//
// BM_Find
// ---------------------------------------------------------------------------//
// Random //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_random_uint64,
std::unordered_set<uint64_t>{},
getRandomIntegerInputs<uint64_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_random_uint64,
std::unordered_set<uint64_t, UInt64Hash>{},
getRandomIntegerInputs<uint64_t>)->Arg(TestNumInputs);
// Sorted //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_sorted_uint64,
std::unordered_set<uint64_t>{},
getSortedIntegerInputs<uint64_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_sorted_uint64,
std::unordered_set<uint64_t, UInt64Hash>{},
getSortedIntegerInputs<uint64_t>)->Arg(TestNumInputs);
// Sorted //
#if 1
BENCHMARK_CAPTURE(BM_Find,
unordered_set_sorted_uint128,
std::unordered_set<__uint128_t, UInt128Hash>{},
getSortedTopBitsIntegerInputs<__uint128_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_sorted_uint128,
std::unordered_set<__uint128_t, UInt128Hash>{},
getSortedTopBitsIntegerInputs<__uint128_t>)->Arg(TestNumInputs);
#endif
// Sorted //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_sorted_uint32,
std::unordered_set<uint32_t>{},
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_sorted_uint32,
std::unordered_set<uint32_t, UInt32Hash2>{},
getSortedIntegerInputs<uint32_t>)->Arg(TestNumInputs);
// Sorted Ascending //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_sorted_large_uint64,
std::unordered_set<uint64_t>{},
getSortedLargeIntegerInputs<uint64_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_sorted_large_uint64,
std::unordered_set<uint64_t, UInt64Hash>{},
getSortedLargeIntegerInputs<uint64_t>)->Arg(TestNumInputs);
// Top Bits //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_top_bits_uint64,
std::unordered_set<uint64_t>{},
getSortedTopBitsIntegerInputs<uint64_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_top_bits_uint64,
std::unordered_set<uint64_t, UInt64Hash>{},
getSortedTopBitsIntegerInputs<uint64_t>)->Arg(TestNumInputs);
// String //
BENCHMARK_CAPTURE(BM_Find,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_FindRehash,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
///////////////////////////////////////////////////////////////////////////////
BENCHMARK_CAPTURE(BM_InsertDuplicate,
unordered_set_int,
std::unordered_set<int>{},
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertDuplicate,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
unordered_set_int,
std::unordered_set<int>{},
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
unordered_set_string,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertDuplicate,
unordered_set_int_insert_arg,
std::unordered_set<int>{},
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_InsertDuplicate,
unordered_set_string_insert_arg,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
unordered_set_int_insert_arg,
std::unordered_set<int>{},
getRandomIntegerInputs<unsigned>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
unordered_set_string_arg,
std::unordered_set<std::string>{},
getRandomCStringInputs)->Arg(TestNumInputs);
BENCHMARK_MAIN()

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <memory>
#include "benchmark/benchmark_api.h"
static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
while (st.KeepRunning()) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
}
}
BENCHMARK(BM_SharedPtrCreateDestroy);
static void BM_SharedPtrIncDecRef(benchmark::State& st) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
while (st.KeepRunning()) {
std::shared_ptr<int> sp2(sp);
benchmark::ClobberMemory();
}
}
BENCHMARK(BM_SharedPtrIncDecRef);
static void BM_WeakPtrIncDecRef(benchmark::State& st) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
while (st.KeepRunning()) {
std::weak_ptr<int> wp(sp);
benchmark::ClobberMemory();
}
}
BENCHMARK(BM_WeakPtrIncDecRef);
BENCHMARK_MAIN()

View File

@@ -0,0 +1,32 @@
#include <vector>
#include <functional>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include "benchmark/benchmark_api.h"
#include "ContainerBenchmarks.hpp"
#include "GenerateInput.hpp"
using namespace ContainerBenchmarks;
constexpr std::size_t TestNumInputs = 1024;
BENCHMARK_CAPTURE(BM_ConstructIterIter,
vector_char,
std::vector<char>{},
getRandomIntegerInputs<char>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_ConstructIterIter,
vector_size_t,
std::vector<size_t>{},
getRandomIntegerInputs<size_t>)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_ConstructIterIter,
vector_string,
std::vector<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_MAIN()

View File

@@ -9,10 +9,16 @@ INCLUDE(CheckCXXSourceCompiles)
function(check_cxx_atomics varname) function(check_cxx_atomics varname)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include") set(CMAKE_REQUIRED_FLAGS "-nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
if (${LIBCXX_GCC_TOOLCHAIN}) if (${LIBCXX_GCC_TOOLCHAIN})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
endif() endif()
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif()
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
endif()
check_cxx_source_compiles(" check_cxx_source_compiles("
#include <cstdint> #include <cstdint>
#include <atomic> #include <atomic>
@@ -26,9 +32,9 @@ int main() {
endfunction(check_cxx_atomics) endfunction(check_cxx_atomics)
check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
# If not, check if the library exists, and atomics work with it. # If not, check if the library exists, and atomics work with it.
if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB) if(NOT LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB)
check_library_exists(atomic __atomic_fetch_add_8 "" LIBCXX_HAS_ATOMIC_LIB)
if(LIBCXX_HAS_ATOMIC_LIB) if(LIBCXX_HAS_ATOMIC_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) check_cxx_atomics(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)

View File

@@ -10,25 +10,34 @@
# abidefines: A list of defines needed to compile libc++ with the ABI library # abidefines: A list of defines needed to compile libc++ with the ABI library
# abilib : The ABI library to link against. # abilib : The ABI library to link against.
# abifiles : A list of files (which may be relative paths) to copy into the # abifiles : A list of files (which may be relative paths) to copy into the
# libc++ build tree for the build. These files will also be # libc++ build tree for the build. These files will be copied
# twice: once into include/, so the libc++ build itself can find
# them, and once into include/c++/v1, so that a clang built into
# the same build area will find them. These files will also be
# installed alongside the libc++ headers. # installed alongside the libc++ headers.
# abidirs : A list of relative paths to create under an include directory # abidirs : A list of relative paths to create under an include directory
# in the libc++ build directory. # in the libc++ build directory.
# #
macro(setup_abi_lib abidefines abilib abifiles abidirs) macro(setup_abi_lib abidefines abilib abifiles abidirs)
list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines}) list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}" set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
CACHE PATH CACHE PATH
"Paths to C++ ABI header directories separated by ';'." FORCE "Paths to C++ ABI header directories separated by ';'." FORCE
) )
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_CXX_ABI_LIBRARY_PATH}"
CACHE PATH
"Paths to C++ ABI library directory"
)
set(LIBCXX_CXX_ABI_LIBRARY ${abilib}) set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
set(LIBCXX_ABILIB_FILES ${abifiles}) set(LIBCXX_ABILIB_FILES ${abifiles})
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include") # The place in the build tree where we store out-of-source headers.
file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1")
foreach(_d ${abidirs}) foreach(_d ${abidirs})
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}") file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}/${_d}")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/${_d}")
endforeach() endforeach()
foreach(fpath ${LIBCXX_ABILIB_FILES}) foreach(fpath ${LIBCXX_ABILIB_FILES})
@@ -39,16 +48,19 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
get_filename_component(dstdir ${fpath} PATH) get_filename_component(dstdir ${fpath} PATH)
get_filename_component(ifile ${fpath} NAME) get_filename_component(ifile ${fpath} NAME)
file(COPY "${incpath}/${fpath}" file(COPY "${incpath}/${fpath}"
DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}" DESTINATION "${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}"
)
file(COPY "${incpath}/${fpath}"
DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1/${dstdir}"
) )
if (LIBCXX_INSTALL_HEADERS) if (LIBCXX_INSTALL_HEADERS)
install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}" install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
DESTINATION include/c++/v1/${dstdir} DESTINATION include/c++/v1/${dstdir}
COMPONENT libcxx COMPONENT libcxx
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
endif() endif()
list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}") list(APPEND abilib_headers "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}")
endif() endif()
endforeach() endforeach()
if (NOT found) if (NOT found)
@@ -56,9 +68,7 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
endif() endif()
endforeach() endforeach()
add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers}) include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
include_directories("${CMAKE_BINARY_DIR}/include")
endmacro() endmacro()
@@ -100,9 +110,16 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
setup_abi_lib("-DLIBCXXRT" setup_abi_lib("-DLIBCXXRT"
"cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
) )
elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "vcruntime")
# Nothing TODO
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
# Nothing TODO
else()
message(FATAL_ERROR message(FATAL_ERROR
"Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are " "Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \
"supported for c++ abi." Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are
supported for c++ abi."
) )
endif () endif ()

View File

@@ -26,6 +26,10 @@ endmacro()
# or added in other parts of LLVM's cmake configuration. # or added in other parts of LLVM's cmake configuration.
macro(remove_flags) macro(remove_flags)
foreach(var ${ARGN}) foreach(var ${ARGN})
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
@@ -76,6 +80,26 @@ macro(config_define value def)
set(LIBCXX_NEEDS_SITE_CONFIG ON) set(LIBCXX_NEEDS_SITE_CONFIG ON)
endmacro() endmacro()
# Add a list of flags to all of 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS',
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'.
macro(add_target_flags)
foreach(value ${ARGN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${value}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${value}")
list(APPEND LIBCXX_COMPILE_FLAGS ${value})
list(APPEND LIBCXX_LINK_FLAGS ${value})
endforeach()
endmacro()
# If the specified 'condition' is true then add a list of flags to
# all of 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', 'LIBCXX_COMPILE_FLAGS'
# and 'LIBCXX_LINK_FLAGS'.
macro(add_target_flags_if condition)
if (${condition})
add_target_flags(${ARGN})
endif()
endmacro()
# Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and # Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and
# 'LIBCXX_LINK_FLAGS'. # 'LIBCXX_LINK_FLAGS'.
macro(add_flags) macro(add_flags)
@@ -168,6 +192,14 @@ macro(add_library_flags_if condition)
endif() endif()
endmacro() endmacro()
# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
macro(add_interface_library)
foreach(lib ${ARGN})
list(APPEND LIBCXX_LIBRARIES ${lib})
list(APPEND LIBCXX_INTERFACE_LIBRARIES ${lib})
endforeach()
endmacro()
# Turn a comma separated CMake list into a space separated string. # Turn a comma separated CMake list into a space separated string.
macro(split_list listname) macro(split_list listname)
string(REPLACE ";" " " ${listname} "${${listname}}") string(REPLACE ";" " " ${listname} "${${listname}}")

View File

@@ -1,15 +1,18 @@
macro(find_llvm_parts) macro(find_llvm_parts)
# Rely on llvm-config. # Rely on llvm-config.
set(CONFIG_OUTPUT) set(CONFIG_OUTPUT)
find_program(LLVM_CONFIG "llvm-config") if(NOT LLVM_CONFIG_PATH)
find_program(LLVM_CONFIG_PATH "llvm-config")
endif()
if(DEFINED LLVM_PATH) if(DEFINED LLVM_PATH)
set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree") set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
set(LLVM_MAIN_SRC_DIR ${LLVM_PATH}) set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
elseif(LLVM_CONFIG) elseif(LLVM_CONFIG_PATH)
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
set(CONFIG_COMMAND ${LLVM_CONFIG} set(LIBCXX_USING_INSTALLED_LLVM 1)
set(CONFIG_COMMAND ${LLVM_CONFIG_PATH}
"--includedir" "--includedir"
"--prefix" "--prefix"
"--src-root") "--src-root")
@@ -35,45 +38,64 @@ macro(find_llvm_parts)
set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
# --cmakedir is supported since llvm r291218 (4.0 release)
execute_process(
COMMAND ${LLVM_CONFIG_PATH} --cmakedir
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE CONFIG_OUTPUT
ERROR_QUIET)
if(NOT HAD_ERROR)
string(STRIP "${CONFIG_OUTPUT}" LLVM_CMAKE_PATH)
else()
set(LLVM_CMAKE_PATH
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
endif()
else() else()
set(LLVM_FOUND OFF) set(LLVM_FOUND OFF)
message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
"llvm-config not found and LLVM_PATH not defined.\n"
"Reconfigure with -DLLVM_CONFIG_PATH=path/to/llvm-config "
"or -DLLVM_PATH=path/to/llvm-source-root.")
return() return()
endif() endif()
if (NOT EXISTS ${LLVM_MAIN_SRC_DIR}) if (EXISTS "${LLVM_CMAKE_PATH}")
set(LLVM_FOUND OFF)
message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}")
return()
endif()
if(NOT EXISTS ${LLVM_CMAKE_PATH})
set(LLVM_FOUND OFF)
message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
return()
endif()
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
else()
set(LLVM_FOUND OFF)
message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found")
return()
endif()
set(LLVM_FOUND ON) set(LLVM_FOUND ON)
endmacro(find_llvm_parts) endmacro(find_llvm_parts)
macro(configure_out_of_tree_llvm)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LIBCXX_BUILT_STANDALONE 1)
message(STATUS "Configuring for standalone build.") message(STATUS "Configuring for standalone build.")
set(LIBCXX_STANDALONE_BUILD 1)
find_llvm_parts() find_llvm_parts()
# LLVM Options -------------------------------------------------------------- # Add LLVM Functions --------------------------------------------------------
include(FindPythonInterp) if (LLVM_FOUND AND LIBCXX_USING_INSTALLED_LLVM)
if( NOT PYTHONINTERP_FOUND ) include(LLVMConfig) # For TARGET_TRIPLE
message(WARNING "Failed to find python interpreter. " else()
"The libc++ test suite will be disabled.") if (WIN32)
set(LLVM_INCLUDE_TESTS OFF) set(LLVM_ON_UNIX 0)
set(LLVM_ON_WIN32 1)
else()
set(LLVM_ON_UNIX 1)
set(LLVM_ON_WIN32 0)
endif()
endif()
if (LLVM_FOUND)
include(AddLLVM OPTIONAL)
endif() endif()
# LLVM Options --------------------------------------------------------------
if (NOT DEFINED LLVM_INCLUDE_TESTS) if (NOT DEFINED LLVM_INCLUDE_TESTS)
set(LLVM_INCLUDE_TESTS ${LLVM_FOUND}) set(LLVM_INCLUDE_TESTS ${LLVM_FOUND})
endif() endif()
@@ -93,46 +115,16 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif() endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
# Make sure we can use the console pool for recent cmake and ninja > 1.5
# Needed for add_lit_testsuite
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
# Required doc configuration # Required doc configuration
if (LLVM_ENABLE_SPHINX) if (LLVM_ENABLE_SPHINX)
message(STATUS "Sphinx enabled.")
find_package(Sphinx REQUIRED) find_package(Sphinx REQUIRED)
else()
message(STATUS "Sphinx disabled.")
endif() endif()
# FIXME - This is cribbed from HandleLLVMOptions.cmake. if (LLVM_ON_UNIX AND NOT APPLE)
if(WIN32)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
if(CYGWIN)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
else(CYGWIN)
set(LLVM_ON_WIN32 1)
set(LLVM_ON_UNIX 0)
endif(CYGWIN)
else(WIN32)
if(UNIX)
set(LLVM_ON_WIN32 0)
set(LLVM_ON_UNIX 1)
if(APPLE)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
else(APPLE)
set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
endif(APPLE) else()
else(UNIX) set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
MESSAGE(SEND_ERROR "Unable to determine platform")
endif(UNIX)
endif(WIN32)
# Add LLVM Functions --------------------------------------------------------
include(AddLLVM OPTIONAL)
endif() endif()
endmacro(configure_out_of_tree_llvm)
configure_out_of_tree_llvm()

View File

@@ -1,6 +1,51 @@
include(CheckLibraryExists) include(CheckLibraryExists)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
if(WIN32 AND NOT MINGW)
# NOTE(compnerd) this is technically a lie, there is msvcrt, but for now, lets
# let the default linking take care of that.
set(LIBCXX_HAS_C_LIB NO)
else()
check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
endif()
if (NOT LIBCXX_USE_COMPILER_RT)
if(WIN32 AND NOT MINGW)
set(LIBCXX_HAS_GCC_S_LIB NO)
else()
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
endif()
endif()
# libc++ is built with -nodefaultlibs, so we want all our checks to also
# use this option, otherwise we may end up with an inconsistency between
# the flags we think we require during configuration (if the checks are
# performed without -nodefaultlibs) and the flags that are actually
# required during compilation (which has the -nodefaultlibs). libc is
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
if (LIBCXX_HAS_C_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
endif ()
if (LIBCXX_USE_COMPILER_RT)
list(APPEND CMAKE_REQUIRED_LIBRARIES -rtlib=compiler-rt)
elseif (LIBCXX_HAS_GCC_S_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
endif ()
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif ()
if (CMAKE_C_FLAGS MATCHES -fsanitize-coverage OR CMAKE_CXX_FLAGS MATCHES -fsanitize-coverage)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters")
endif ()
endif ()
if(NOT WIN32 OR MINGW)
include(CheckLibcxxAtomic) include(CheckLibcxxAtomic)
endif()
# Check compiler flags # Check compiler flags
@@ -13,8 +58,14 @@ check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
# Check libraries # Check libraries
if(WIN32 AND NOT MINGW)
# TODO(compnerd) do we want to support an emulation layer that allows for the
# use of pthread-win32 or similar libraries to emulate pthreads on Windows?
set(LIBCXX_HAS_PTHREAD_LIB NO)
set(LIBCXX_HAS_M_LIB NO)
set(LIBCXX_HAS_RT_LIB NO)
else()
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB) check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
check_library_exists(m ccos "" LIBCXX_HAS_M_LIB) check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB) check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB) endif()

View File

@@ -1,3 +1,4 @@
.. _BuildingLibcxx:
=============== ===============
Building libc++ Building libc++
@@ -48,7 +49,7 @@ The basic steps needed to build libc++ are:
For more information about configuring libc++ see :ref:`CMake Options`. For more information about configuring libc++ see :ref:`CMake Options`.
* ``make cxx`` --- will build libc++ and libc++abi. * ``make cxx`` --- will build libc++ and libc++abi.
* ``make check-libcxx check-libcxxabi`` --- will run the test suites. * ``make check-cxx check-cxxabi`` --- will run the test suites.
Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib. Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib.
See :ref:`using an alternate libc++ installation <alternate libcxx>` See :ref:`using an alternate libc++ installation <alternate libcxx>`
@@ -59,7 +60,7 @@ The basic steps needed to build libc++ are:
careful not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to careful not to replace it. Remember Use the CMake option ``CMAKE_INSTALL_PREFIX`` to
select a safe place to install libc++. select a safe place to install libc++.
* ``make install-libcxx install-libcxxabi`` --- Will install the libraries and the headers * ``make install-cxx install-cxxabi`` --- Will install the libraries and the headers
.. warning:: .. warning::
* Replacing your systems libc++ installation could render the system non-functional. * Replacing your systems libc++ installation could render the system non-functional.
@@ -143,19 +144,26 @@ libc++ specific options
**Default**: ``OFF`` **Default**: ``OFF``
Build libc++ as a 32 bit library. Also see :option:`LLVM_BUILD_32_BITS`. Build libc++ as a 32 bit library. Also see `LLVM_BUILD_32_BITS`.
.. option:: LIBCXX_ENABLE_SHARED:BOOL .. option:: LIBCXX_ENABLE_SHARED:BOOL
**Default**: ``ON`` **Default**: ``ON``
Build libc++ as a shared library. If ``OFF`` is specified then libc++ is Build libc++ as a shared library. Either `LIBCXX_ENABLE_SHARED` or
built as a static library. `LIBCXX_ENABLE_STATIC` has to be enabled.
.. option:: LIBCXX_ENABLE_STATIC:BOOL
**Default**: ``ON``
Build libc++ as a static library. Either `LIBCXX_ENABLE_SHARED` or
`LIBCXX_ENABLE_STATIC` has to be enabled.
.. option:: LIBCXX_LIBDIR_SUFFIX:STRING .. option:: LIBCXX_LIBDIR_SUFFIX:STRING
Extra suffix to append to the directory where libraries are to be installed. Extra suffix to append to the directory where libraries are to be installed.
This option overrides :option:`LLVM_LIBDIR_SUFFIX`. This option overrides `LLVM_LIBDIR_SUFFIX`.
.. _libc++experimental options: .. _libc++experimental options:
@@ -171,11 +179,19 @@ libc++experimental Specific Options
.. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL .. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL
**Default**: ``OFF`` **Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND LIBCXX_INSTALL_LIBRARY``
Install libc++experimental.a alongside libc++. Install libc++experimental.a alongside libc++.
.. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL
**Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY``
Build filesystem as part of libc++experimental.a. This allows filesystem
to be disabled without turning off the entire experimental library.
.. _ABI Library Specific Options: .. _ABI Library Specific Options:
ABI Library Specific Options ABI Library Specific Options
@@ -218,7 +234,7 @@ ABI Library Specific Options
libc++abi is the C++ ABI library used. libc++abi is the C++ ABI library used.
libc++ Feature options libc++ Feature Options
---------------------- ----------------------
.. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL .. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL
@@ -233,9 +249,32 @@ libc++ Feature options
Build libc++ with run time type information. Build libc++ with run time type information.
.. option:: LIBCXX_INCLUDE_BENCHMARKS:BOOL
libc++ Feature options **Default**: ``ON``
----------------------
Build the libc++ benchmark tests and the Google Benchmark library needed
to support them.
.. option:: LIBCXX_BENCHMARK_NATIVE_STDLIB:STRING
**Default**:: ``""``
**Values**:: ``libc++``, ``libstdc++``
Build the libc++ benchmark tests and Google Benchmark library against the
specified standard library on the platform. On linux this can be used to
compare libc++ to libstdc++ by building the benchmark tests against both
standard libraries.
.. option:: LIBCXX_BENCHMARK_NATIVE_GCC_TOOLCHAIN:STRING
Use the specified GCC toolchain and standard library when building the native
stdlib benchmark tests.
libc++ ABI Feature Options
--------------------------
The following options allow building libc++ for a different ABI version. The following options allow building libc++ for a different ABI version.
@@ -336,3 +375,72 @@ own copy of libsupc++ and this can lead to subtle problems.
$ make install $ make install
You can now run clang with -stdlib=libc++. You can now run clang with -stdlib=libc++.
.. _libcxxrt_ref:
Using libcxxrt on Linux
------------------------
You will need to keep the source tree of `libcxxrt`_ available
on your build machine and your copy of the libcxxrt shared library must
be placed where your linker will find it.
We can now run CMake like:
.. code-block:: bash
$ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \
-DLIBCXX_CXX_ABI=libcxxrt \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
<libc++-source-directory>
$ make cxx
$ make install
Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as
clang is set up to link for libc++ linked to libsupc++. To get around this
you'll have to set up your linker yourself (or patch clang). For example,
.. code-block:: bash
$ clang++ -stdlib=libc++ helloworld.cpp \
-nodefaultlibs -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc
Alternately, you could just add libcxxrt to your libraries list, which in most
situations will give the same result:
.. code-block:: bash
$ clang++ -stdlib=libc++ helloworld.cpp -lcxxrt
.. _`libcxxrt`: https://github.com/pathscale/libcxxrt/
Using a local ABI library installation
---------------------------------------
.. warning::
This is not recommended in almost all cases.
These instructions should only be used when you can't install your ABI library.
Normally you must link libc++ against a ABI shared library that the
linker can find. If you want to build and test libc++ against an ABI
library not in the linker's path you needq to set
``-DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib`` when configuring CMake.
An example build using libc++abi would look like:
.. code-block:: bash
$ CC=clang CXX=clang++ cmake \
-DLIBCXX_CXX_ABI=libc++abi \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS="/path/to/libcxxabi/include" \
-DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib" \
path/to/libcxx
$ make
When testing libc++ LIT will automatically link against the proper ABI
library.

View File

@@ -0,0 +1,100 @@
==========
Debug Mode
==========
.. contents::
:local
.. _using-debug-mode:
Using Debug Mode
================
Libc++ provides a debug mode that enables assertions meant to detect incorrect
usage of the standard library. By default these assertions are disabled but
they can be enabled using the ``_LIBCPP_DEBUG`` macro.
**_LIBCPP_DEBUG** Macro
-----------------------
**_LIBCPP_DEBUG**:
This macro is used to enable assertions and iterator debugging checks within
libc++. By default it is undefined.
**Values**: ``0``, ``1``
Defining ``_LIBCPP_DEBUG`` to ``0`` or greater enables most of libc++'s
assertions. Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging"
which provides additional assertions about the validity of iterators used by
the program.
Note that this option has no effect on libc++'s ABI
**_LIBCPP_DEBUG_USE_EXCEPTIONS**:
When this macro is defined ``_LIBCPP_ASSERT`` failures throw
``__libcpp_debug_exception`` instead of aborting. Additionally this macro
disables exception specifications on functions containing ``_LIBCPP_ASSERT``
checks. This allows assertion failures to correctly throw through these
functions.
Handling Assertion Failures
---------------------------
When a debug assertion fails the assertion handler is called via the
``std::__libcpp_debug_function`` function pointer. It is possible to override
this function pointer using a different handler function. Libc++ provides two
different assertion handlers, the default handler
``std::__libcpp_abort_debug_handler`` which aborts the program, and
``std::__libcpp_throw_debug_handler`` which throws an instance of
``std::__libcpp_debug_exception``. Libc++ can be changed to use the throwing
assertion handler as follows:
.. code-block:: cpp
#define _LIBCPP_DEBUG 1
#include <string>
int main() {
std::__libcpp_debug_function = std::__libcpp_throw_debug_function;
try {
std::string::iterator bad_it;
std::string str("hello world");
str.insert(bad_it, '!'); // causes debug assertion
} catch (std::__libcpp_debug_exception const&) {
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
Debug Mode Checks
=================
Libc++'s debug mode offers two levels of checking. The first enables various
precondition checks throughout libc++. The second additionally enables
"iterator debugging" which checks the validity of iterators used by the program.
Basic Checks
============
These checks are enabled when ``_LIBCPP_DEBUG`` is defined to either 0 or 1.
The following checks are enabled by ``_LIBCPP_DEBUG``:
* FIXME: Update this list
Iterator Debugging Checks
=========================
These checks are enabled when ``_LIBCPP_DEBUG`` is defined to 1.
The following containers and STL classes support iterator debugging:
* ``std::string``
* ``std::vector<T>`` (``T != bool``)
* ``std::list``
* ``std::unordered_map``
* ``std::unordered_multimap``
* ``std::unordered_set``
* ``std::unordered_multiset``
The remaining containers do not currently support iterator debugging.
Patches welcome.

View File

@@ -0,0 +1,79 @@
=====================
Threading Support API
=====================
.. contents::
:local:
Overview
========
Libc++ supports using multiple different threading models and configurations
to implement the threading parts of libc++, including ``<thread>`` and ``<mutex>``.
These different models provide entirely different interfaces from each
other. To address this libc++ wraps the underlying threading API in a new and
consistent API, which it uses internally to implement threading primitives.
The ``<__threading_support>`` header is where libc++ defines its internal
threading interface. It contains forward declarations of the internal threading
interface as well as definitions for the interface.
External Threading API and the ``<__external_threading>`` header
================================================================
In order to support vendors with custom threading API's libc++ allows the
entire internal threading interface to be provided by an external,
vendor provided, header.
When ``_LIBCPP_HAS_THREAD_API_EXTERNAL`` is defined the ``<__threading_support>``
header simply forwards to the ``<__external_threading>`` header (which must exist).
It is expected that the ``<__external_threading>`` header provide the exact
interface normally provided by ``<__threading_support>``.
External Threading Library
==========================
libc++ can be compiled with its internal threading API delegating to an external
library. Such a configuration is useful for library vendors who wish to
distribute a thread-agnostic libc++ library, where the users of the library are
expected to provide the implementation of the libc++ internal threading API.
On a production setting, this would be achieved through a custom
``<__external_threading>`` header, which declares the libc++ internal threading
API but leaves out the implementation.
The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
such a configuration while allowing it to be tested on a platform that supports
any of the threading systems (e.g. pthread) supported in ``__threading_support``
header. Therefore, the main purpose of this option is to allow testing of this
particular configuration of the library without being tied to a vendor-specific
threading system. This option is only meant to be used by libc++ library
developers.
Threading Configuration Macros
==============================
**_LIBCPP_HAS_NO_THREADS**
This macro is defined when libc++ is built without threading support. It
should not be manually defined by the user.
**_LIBCPP_HAS_THREAD_API_EXTERNAL**
This macro is defined when libc++ should use the ``<__external_threading>``
header to provide the internal threading API. This macro overrides
``_LIBCPP_HAS_THREAD_API_PTHREAD``.
**_LIBCPP_HAS_THREAD_API_PTHREAD**
This macro is defined when libc++ should use POSIX threads to implement the
internal threading API.
**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
This macro is defined when libc++ expects the definitions of the internal
threading API to be provided by an external library. When defined
``<__threading_support>`` will only provide the forward declarations and
typedefs for the internal threading API.
**_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL**
This macro is used to build an external threading library using the
``<__threading_support>``. Specifically it exposes the threading API
definitions in ``<__threading_support>`` as non-inline definitions meant to
be compiled into a library.

View File

@@ -0,0 +1,134 @@
========================
Symbol Visibility Macros
========================
.. contents::
:local:
Overview
========
Libc++ uses various "visibility" macros in order to provide a stable ABI in
both the library and the headers. These macros work by changing the
visibility and inlining characteristics of the symbols they are applied to.
Visibility Macros
=================
**_LIBCPP_HIDDEN**
Mark a symbol as hidden so it will not be exported from shared libraries.
**_LIBCPP_FUNC_VIS**
Mark a symbol as being exported by the libc++ library. This attribute must
be applied to the declaration of all functions exported by the libc++ dylib.
**_LIBCPP_EXTERN_VIS**
Mark a symbol as being exported by the libc++ library. This attribute may
only be applied to objects defined in the libc++ library. On Windows this
macro applies `dllimport`/`dllexport` to the symbol. On all other platforms
this macro has no effect.
**_LIBCPP_OVERRIDABLE_FUNC_VIS**
Mark a symbol as being exported by the libc++ library, but allow it to be
overridden locally. On non-Windows, this is equivalent to `_LIBCPP_FUNC_VIS`.
This macro is applied to all `operator new` and `operator delete` overloads.
**Windows Behavior**: Any symbol marked `dllimport` cannot be overridden
locally, since `dllimport` indicates the symbol should be bound to a separate
DLL. All `operator new` and `operator delete` overloads are required to be
locally overridable, and therefore must not be marked `dllimport`. On Windows,
this macro therefore expands to `__declspec(dllexport)` when building the
library and has an empty definition otherwise.
**_LIBCPP_INLINE_VISIBILITY**
Mark a function as hidden and force inlining whenever possible.
**_LIBCPP_ALWAYS_INLINE**
A synonym for `_LIBCPP_INLINE_VISIBILITY`
**_LIBCPP_TYPE_VIS**
Mark a type's typeinfo and vtable as having default visibility.
`_LIBCPP_TYPE_VIS`. This macro has no effect on the visibility of the
type's member functions. This attribute cannot be used on class templates.
**GCC Behavior**: GCC does not support Clang's `type_visibility(...)`
attribute. With GCC the `visibility(...)` attribute is used and member
functions are affected.
**_LIBCPP_TEMPLATE_VIS**
The same as `_LIBCPP_TYPE_VIS` except that it may be applied to class
templates.
**Windows Behavior**: DLLs do not support dllimport/export on class templates.
The macro has an empty definition on this platform.
**_LIBCPP_ENUM_VIS**
Mark the typeinfo of an enum as having default visibility. This attribute
should be applied to all enum declarations.
**Windows Behavior**: DLLs do not support importing or exporting enumeration
typeinfo. The macro has an empty definition on this platform.
**GCC Behavior**: GCC un-hides the typeinfo for enumerations by default, even
if `-fvisibility=hidden` is specified. Additionally applying a visibility
attribute to an enum class results in a warning. The macro has an empty
definition with GCC.
**_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS**
Mark the member functions, typeinfo, and vtable of the type named in
a `_LIBCPP_EXTERN_TEMPLATE` declaration as being exported by the libc++ library.
This attribute must be specified on all extern class template declarations.
This macro is used to override the `_LIBCPP_TEMPLATE_VIS` attribute
specified on the primary template and to export the member functions produced
by the explicit instantiation in the dylib.
**GCC Behavior**: GCC ignores visibility attributes applied the type in
extern template declarations and applying an attribute results in a warning.
However since `_LIBCPP_TEMPLATE_VIS` is the same as
`__attribute__((visibility("default"))` the visibility is already correct.
The macro has an empty definition with GCC.
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
incompatible *on a template class* on Windows; the former suppresses
instantiation, while the latter forces it. Specifying both on the same
declaration makes the template class be instantiated, which is not desirable
inside headers. This macro therefore expands to `dllimport` outside of libc++
but nothing inside of it (rather than expanding to `dllexport`); instead, the
explicit instantiations themselves are marked as exported. Note that this
applies *only* to extern template *classes*. Extern template *functions* obey
regular import/export semantics, and applying `dllexport` directly to the
extern template declaration is the correct thing to do for them.
**_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**
Mark the member functions, typeinfo, and vtable of an explicit instantiation
of a class template as being exported by the libc++ library. This attribute
must be specified on all template class explicit instantiations.
It is only necessary to mark the explicit instantiation itself (as opposed to
the extern template declaration) as exported on Windows, as discussed above.
On all other platforms, this macro has an empty definition.
**_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY**
Mark a member function of a class template as visible and always inline. This
macro should only be applied to member functions of class templates that are
externally instantiated. It is important that these symbols are not marked
as hidden as that will prevent the dylib definition from being found.
This macro is used to maintain ABI compatibility for symbols that have been
historically exported by the libc++ library but are now marked inline.
**_LIBCPP_EXCEPTION_ABI**
Mark the member functions, typeinfo, and vtable of the type as being exported
by the libc++ library. This macro must be applied to all *exception types*.
Exception types should be defined directly in namespace `std` and not the
versioning namespace. This allows throwing and catching some exception types
between libc++ and libstdc++.
Links
=====
* `[cfe-dev] Visibility in libc++ - 1 <http://lists.llvm.org/pipermail/cfe-dev/2013-July/030610.html>`_
* `[cfe-dev] Visibility in libc++ - 2 <http://lists.llvm.org/pipermail/cfe-dev/2013-August/031195.html>`_
* `[libcxx] Visibility fixes for Windows <http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20130805/085461.html>`_

View File

@@ -5,7 +5,7 @@
# out-of-tree builds. # out-of-tree builds.
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = SPHINXOPTS = -n -W
SPHINXBUILD = sphinx-build SPHINXBUILD = sphinx-build
PAPER = PAPER =
BUILDDIR = _build BUILDDIR = _build

View File

@@ -98,56 +98,64 @@ configuration. Passing the option on the command line will override the default.
.. program:: lit .. program:: lit
.. option:: --cxx_under_test=<path/to/compiler> .. option:: cxx_under_test=<path/to/compiler>
Specify the compiler used to build the tests. Specify the compiler used to build the tests.
.. option:: cxx_stdlib_under_test=<stdlib name>
**Values**: libc++, libstdc++
Specify the C++ standard library being tested. Unless otherwise specified
libc++ is used. This option is intended to allow running the libc++ test
suite against other standard library implementations.
.. option:: std=<standard version> .. option:: std=<standard version>
**Values**: c++98, c++03, c++11, c++14, c++1z **Values**: c++98, c++03, c++11, c++14, c++1z
Change the standard version used when building the tests. Change the standard version used when building the tests.
.. option:: --libcxx_site_config=<path/to/lit.site.cfg> .. option:: libcxx_site_config=<path/to/lit.site.cfg>
Specify the site configuration to use when running the tests. This option Specify the site configuration to use when running the tests. This option
overrides the enviroment variable LIBCXX_SITE_CONFIG. overrides the enviroment variable LIBCXX_SITE_CONFIG.
.. option:: --libcxx_headers=<path/to/headers> .. option:: cxx_headers=<path/to/headers>
Specify the libc++ headers that are tested. By default the headers in the Specify the c++ standard library headers that are tested. By default the
source tree are used. headers in the source tree are used.
.. option:: --cxx_library_root=<path/to/lib/> .. option:: cxx_library_root=<path/to/lib/>
Specify the directory of the libc++ library to be tested. By default the Specify the directory of the libc++ library to be tested. By default the
library folder of the build directory is used. This option cannot be used library folder of the build directory is used. This option cannot be used
when use_system_lib is provided. when use_system_cxx_lib is provided.
.. option:: --cxx_runtime_root=<path/to/lib/> .. option:: cxx_runtime_root=<path/to/lib/>
Specify the directory of the libc++ library to use at runtime. This directory Specify the directory of the libc++ library to use at runtime. This directory
is not added to the linkers search path. This can be used to compile tests is not added to the linkers search path. This can be used to compile tests
against one version of libc++ and run them using another. The default value against one version of libc++ and run them using another. The default value
for this option is `cxx_library_root`. This option cannot be used for this option is `cxx_library_root`. This option cannot be used
when use_system_lib is provided. when use_system_cxx_lib is provided.
.. option:: --use_system_lib=<bool> .. option:: use_system_cxx_lib=<bool>
**Default**: False **Default**: False
Enable or disable testing against the installed version of libc++ library. Enable or disable testing against the installed version of libc++ library.
Note: This does not use the installed headers. Note: This does not use the installed headers.
.. option:: --use_lit_shell=<bool> .. option:: use_lit_shell=<bool>
Enable or disable the use of LIT's internal shell in ShTests. If the Enable or disable the use of LIT's internal shell in ShTests. If the
environment variable LIT_USE_INTERNAL_SHELL is present then that is used as environment variable LIT_USE_INTERNAL_SHELL is present then that is used as
the default value. Otherwise the default value is True on Windows and False the default value. Otherwise the default value is True on Windows and False
on every other platform. on every other platform.
.. option:: --no_default_flags=<bool> .. option:: no_default_flags=<bool>
**Default**: False **Default**: False
@@ -155,16 +163,16 @@ configuration. Passing the option on the command line will override the default.
option is used only flags specified using the compile_flags and link_flags option is used only flags specified using the compile_flags and link_flags
will be used. will be used.
.. option:: --compile_flags="<list-of-args>" .. option:: compile_flags="<list-of-args>"
Specify additional compile flags as a space delimited string. Specify additional compile flags as a space delimited string.
Note: This options should not be used to change the standard version used. Note: This options should not be used to change the standard version used.
.. option:: --link_flags="<list-of-args>" .. option:: link_flags="<list-of-args>"
Specify additional link flags as a space delimited string. Specify additional link flags as a space delimited string.
.. option:: --debug_level=<level> .. option:: debug_level=<level>
**Values**: 0, 1 **Values**: 0, 1
@@ -191,10 +199,68 @@ Environment Variables
.. envvar:: LIBCXX_SITE_CONFIG=<path/to/lit.site.cfg> .. envvar:: LIBCXX_SITE_CONFIG=<path/to/lit.site.cfg>
Specify the site configuration to use when running the tests. Specify the site configuration to use when running the tests.
Also see :option:`libcxx_site_config`. Also see `libcxx_site_config`.
.. envvar:: LIBCXX_COLOR_DIAGNOSTICS .. envvar:: LIBCXX_COLOR_DIAGNOSTICS
If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt
to use color diagnostic outputs from the compiler. to use color diagnostic outputs from the compiler.
Also see :option:`color_diagnostics`. Also see `color_diagnostics`.
Benchmarks
==========
Libc++ contains benchmark tests separately from the test of the test suite.
The benchmarks are written using the `Google Benchmark`_ library, a copy of which
is stored in the libc++ repository.
For more information about using the Google Benchmark library see the
`official documentation <https://github.com/google/benchmark>`_.
.. _`Google Benchmark`: https://github.com/google/benchmark
Building Benchmarks
-------------------
The benchmark tests are not built by default. The benchmarks can be built using
the ``cxx-benchmarks`` target.
An example build would look like:
.. code-block:: bash
$ cd build
$ cmake [options] <path to libcxx sources>
$ make cxx-benchmarks
This will build all of the benchmarks under ``<libcxx-src>/benchmarks`` to be
built against the just-built libc++. The compiled tests are output into
``build/benchmarks``.
The benchmarks can also be built against the platforms native standard library
using the ``-DLIBCXX_BUILD_BENCHMARKS_NATIVE_STDLIB=ON`` CMake option. This
is useful for comparing the performance of libc++ to other standard libraries.
The compiled benchmarks are named ``<test>.libcxx.out`` if they test libc++ and
``<test>.native.out`` otherwise.
Also See:
* :ref:`Building Libc++ <build instructions>`
* :ref:`CMake Options`
Running Benchmarks
------------------
The benchmarks must be run manually by the user. Currently there is no way
to run them as part of the build.
For example:
.. code-block:: bash
$ cd build/benchmarks
$ make cxx-benchmarks
$ ./algorithms.libcxx.out # Runs all the benchmarks
$ ./algorithms.libcxx.out --benchmark_filter=BM_Sort.* # Only runs the sort benchmarks
For more information about running benchmarks see `Google Benchmark`_.

View File

@@ -123,3 +123,60 @@ supported by libc++ they may be useful to users.
Known 3rd Party Implementations Include: Known 3rd Party Implementations Include:
* `Koutheir's libc++ pretty-printers <https://github.com/koutheir/libcxx-pretty-printers>`_. * `Koutheir's libc++ pretty-printers <https://github.com/koutheir/libcxx-pretty-printers>`_.
Libc++ Configuration Macros
===========================
Libc++ provides a number of configuration macros which can be used to enable
or disable extended libc++ behavior, including enabling "debug mode" or
thread safety annotations.
**_LIBCPP_DEBUG**:
See :ref:`using-debug-mode` for more information.
**_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**:
This macro is used to enable -Wthread-safety annotations on libc++'s
``std::mutex`` and ``std::lock_guard``. By default these annotations are
disabled and must be manually enabled by the user.
**_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**:
This macro is used to disable all visibility annotations inside libc++.
Defining this macro and then building libc++ with hidden visibility gives a
build of libc++ which does not export any symbols, which can be useful when
building statically for inclusion into another library.
**_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
This macro is used to re-enable an extension in `std::tuple` which allowed
it to be implicitly constructed from fewer initializers than contained
elements. Elements without an initializer are default constructed. For example:
.. code-block:: cpp
std::tuple<std::string, int, std::error_code> foo() {
return {"hello world", 42}; // default constructs error_code
}
Since libc++ 4.0 this extension has been disabled by default. This macro
may be defined to re-enable it in order to support existing code that depends
on the extension. New use of this extension should be discouraged.
See `PR 27374 <http://llvm.org/PR27374>`_ for more information.
Note: The "reduced-arity-initialization" extension is still offered but only
for explicit conversions. Example:
.. code-block:: cpp
auto foo() {
using Tup = std::tuple<std::string, int, std::error_code>;
return Tup{"hello world", 42}; // explicit constructor called. OK.
}
**_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**:
This macro disables the additional diagnostics generated by libc++ using the
`diagnose_if` attribute. These additional diagnostics include checks for:
* Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
const callable.

View File

@@ -40,16 +40,16 @@ master_doc = 'index'
# General information about the project. # General information about the project.
project = u'libc++' project = u'libc++'
copyright = u'2011-2016, LLVM Project' copyright = u'2011-2017, LLVM Project'
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '3.9' version = '5.0'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '3.9' release = '5.0'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@@ -7,7 +7,8 @@
Overview Overview
======== ========
libc++ is a new implementation of the C++ standard library, targeting C++11. libc++ is a new implementation of the C++ standard library, targeting C++11 and
above.
* Features and Goals * Features and Goals
@@ -127,13 +128,14 @@ Design Documents
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
DesignDocs/DebugMode
DesignDocs/CapturingConfigInfo DesignDocs/CapturingConfigInfo
DesignDocs/ABIVersioning DesignDocs/ABIVersioning
DesignDocs/VisibilityMacros
DesignDocs/ThreadingSupportAPI
* `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_ * `<atomic> design <http://libcxx.llvm.org/atomic_design.html>`_
* `<type_traits> design <http://libcxx.llvm.org/type_traits_design.html>`_ * `<type_traits> design <http://libcxx.llvm.org/type_traits_design.html>`_
* `Status of debug mode <http://libcxx.llvm.org/debug_mode.html>`_
* `Notes by Marshall Clow`__ * `Notes by Marshall Clow`__
.. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/ .. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/

View File

@@ -10,53 +10,57 @@ set(LIBCXX_HEADER_PATTERN
${LIBCXX_SUPPORT_HEADER_PATTERN} ${LIBCXX_SUPPORT_HEADER_PATTERN}
) )
if(NOT LIBCXX_USING_INSTALLED_LLVM AND LLVM_BINARY_DIR)
file(COPY . file(COPY .
DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1" DESTINATION "${LLVM_BINARY_DIR}/include/c++/v1"
FILES_MATCHING FILES_MATCHING
${LIBCXX_HEADER_PATTERN} ${LIBCXX_HEADER_PATTERN}
) )
endif()
if (LIBCXX_INSTALL_HEADERS) if (LIBCXX_INSTALL_HEADERS)
install(DIRECTORY . install(DIRECTORY .
DESTINATION include/c++/v1 DESTINATION include/c++/v1
COMPONENT libcxx-headers COMPONENT cxx-headers
FILES_MATCHING FILES_MATCHING
${LIBCXX_HEADER_PATTERN} ${LIBCXX_HEADER_PATTERN}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
) )
if (LIBCXX_NEEDS_SITE_CONFIG) if (LIBCXX_NEEDS_SITE_CONFIG)
set(UNIX_CAT cat)
if (WIN32)
set(UNIX_CAT type)
endif()
# Generate and install a custom __config header. The new header is created # Generate and install a custom __config header. The new header is created
# by prepending __config_site to the current __config header. # by prepending __config_site to the current __config header.
add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config
COMMAND ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__generated_config COMMAND ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py
COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> ${LIBCXX_BINARY_DIR}/__generated_config ${LIBCXX_BINARY_DIR}/__config_site
${LIBCXX_SOURCE_DIR}/include/__config
-o ${LIBCXX_BINARY_DIR}/__generated_config
DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config
${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__config_site
) )
# Add a target that executes the generation commands. # Add a target that executes the generation commands.
add_custom_target(generate_config_header ALL add_custom_target(generate_config_header ALL
DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config) DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config)
set(generated_config_deps generate_config_header)
# Install the generated header as __config. # Install the generated header as __config.
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
DESTINATION include/c++/v1 DESTINATION include/c++/v1
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
RENAME __config RENAME __config
COMPONENT libcxx-headers) COMPONENT cxx-headers)
endif() endif()
if (NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_CONFIGURATION_TYPES)
# this target is just needed as a placeholder for the distribution target # this target is just needed as a placeholder for the distribution target
add_custom_target(libcxx-headers) add_custom_target(cxx-headers)
add_custom_target(install-libcxx-headers add_custom_target(install-cxx-headers
DEPENDS libcxx-headers DEPENDS cxx-headers ${generated_config_deps}
COMMAND "${CMAKE_COMMAND}" COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libcxx-headers -DCMAKE_INSTALL_COMPONENT=cxx-headers
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake") -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_custom_target(libcxx-headers)
add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
endif() endif()
endif() endif()

View File

@@ -40,11 +40,8 @@ class __bit_reference
__storage_pointer __seg_; __storage_pointer __seg_;
__storage_type __mask_; __storage_type __mask_;
#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
friend typename _Cp::__self; friend typename _Cp::__self;
#else
friend class _Cp::__self;
#endif
friend class __bit_const_reference<_Cp>; friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, false>; friend class __bit_iterator<_Cp, false>;
public: public:
@@ -130,11 +127,7 @@ class __bit_const_reference
__storage_pointer __seg_; __storage_pointer __seg_;
__storage_type __mask_; __storage_type __mask_;
#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
friend typename _Cp::__self; friend typename _Cp::__self;
#else
friend class _Cp::__self;
#endif
friend class __bit_iterator<_Cp, true>; friend class __bit_iterator<_Cp, true>;
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -163,7 +156,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
{ {
typedef __bit_iterator<_Cp, _IsConst> _It; typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; static const int __bits_per_word = _It::__bits_per_word;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
{ {
@@ -199,7 +192,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
{ {
typedef __bit_iterator<_Cp, _IsConst> _It; typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; const int __bits_per_word = _It::__bits_per_word;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
{ {
@@ -251,7 +244,7 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
typedef __bit_iterator<_Cp, _IsConst> _It; typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type; typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word; const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0; difference_type __r = 0;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
@@ -282,7 +275,7 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ
typedef __bit_iterator<_Cp, _IsConst> _It; typedef __bit_iterator<_Cp, _IsConst> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
typedef typename _It::difference_type difference_type; typedef typename _It::difference_type difference_type;
static const unsigned __bits_per_word = _It::__bits_per_word; const int __bits_per_word = _It::__bits_per_word;
difference_type __r = 0; difference_type __r = 0;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
@@ -324,7 +317,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{ {
typedef __bit_iterator<_Cp, false> _It; typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; const int __bits_per_word = _It::__bits_per_word;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
{ {
@@ -354,7 +347,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
{ {
typedef __bit_iterator<_Cp, false> _It; typedef __bit_iterator<_Cp, false> _It;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; const int __bits_per_word = _It::__bits_per_word;
// do first partial word // do first partial word
if (__first.__ctz_ != 0) if (__first.__ctz_ != 0)
{ {
@@ -412,7 +405,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
typedef __bit_iterator<_Cp, _IsConst> _In; typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type; typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type; typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word; const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -461,7 +454,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
typedef __bit_iterator<_Cp, _IsConst> _In; typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type; typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type; typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word; static const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -551,7 +544,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
typedef __bit_iterator<_Cp, _IsConst> _In; typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type; typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type; typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word; const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -600,7 +593,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
typedef __bit_iterator<_Cp, _IsConst> _In; typedef __bit_iterator<_Cp, _IsConst> _In;
typedef typename _In::difference_type difference_type; typedef typename _In::difference_type difference_type;
typedef typename _In::__storage_type __storage_type; typedef typename _In::__storage_type __storage_type;
static const unsigned __bits_per_word = _In::__bits_per_word; const int __bits_per_word = _In::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -718,7 +711,7 @@ __swap_ranges_aligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1,
typedef __bit_iterator<__C1, false> _I1; typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type; typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type; typedef typename _I1::__storage_type __storage_type;
static const unsigned __bits_per_word = _I1::__bits_per_word; const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -768,7 +761,7 @@ __swap_ranges_unaligned(__bit_iterator<__C1, false> __first, __bit_iterator<__C1
typedef __bit_iterator<__C1, false> _I1; typedef __bit_iterator<__C1, false> _I1;
typedef typename _I1::difference_type difference_type; typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type; typedef typename _I1::__storage_type __storage_type;
static const unsigned __bits_per_word = _I1::__bits_per_word; const int __bits_per_word = _I1::__bits_per_word;
difference_type __n = __last - __first; difference_type __n = __last - __first;
if (__n > 0) if (__n > 0)
{ {
@@ -959,7 +952,7 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
typedef __bit_iterator<_Cp, _IC1> _It; typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type; typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1; difference_type __n = __last1 - __first1;
if (__n > 0) if (__n > 0)
{ {
@@ -1041,7 +1034,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
typedef __bit_iterator<_Cp, _IC1> _It; typedef __bit_iterator<_Cp, _IC1> _It;
typedef typename _It::difference_type difference_type; typedef typename _It::difference_type difference_type;
typedef typename _It::__storage_type __storage_type; typedef typename _It::__storage_type __storage_type;
static const unsigned __bits_per_word = _It::__bits_per_word; static const int __bits_per_word = _It::__bits_per_word;
difference_type __n = __last1 - __first1; difference_type __n = __last1 - __first1;
if (__n > 0) if (__n > 0)
{ {
@@ -1221,11 +1214,8 @@ private:
__bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
: __seg_(__s), __ctz_(__ctz) {} : __seg_(__s), __ctz_(__ctz) {}
#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC)
friend typename _Cp::__self; friend typename _Cp::__self;
#else
friend class _Cp::__self;
#endif
friend class __bit_reference<_Cp>; friend class __bit_reference<_Cp>;
friend class __bit_const_reference<_Cp>; friend class __bit_const_reference<_Cp>;
friend class __bit_iterator<_Cp, true>; friend class __bit_iterator<_Cp, true>;

View File

@@ -27,22 +27,52 @@
#define _GNUC_VER 0 #define _GNUC_VER 0
#endif #endif
#define _LIBCPP_VERSION 3900 #define _LIBCPP_VERSION 5000
#ifndef _LIBCPP_ABI_VERSION #ifndef _LIBCPP_ABI_VERSION
#define _LIBCPP_ABI_VERSION 1 #define _LIBCPP_ABI_VERSION 1
#endif #endif
#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
// Change short string represention so that string data starts at offset 0, // Change short string representation so that string data starts at offset 0,
// improving its alignment in some cases. // improving its alignment in some cases.
#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// Fix deque iterator type in order to support incomplete types. // Fix deque iterator type in order to support incomplete types.
#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
// Fix undefined behavior in how std::list stores it's linked nodes. // Fix undefined behavior in how std::list stores it's linked nodes.
#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB #define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
// Fix undefined behavior in how __tree stores its end and parent nodes.
#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
// 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_FORWARD_LIST_REMOVE_NODE_POINTER_UB
#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE #define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
#define _LIBCPP_ABI_VARIADIC_LOCK_GUARD
// 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
#elif _LIBCPP_ABI_VERSION == 1
#if !defined(_WIN32)
// Enable compiling copies of now inline methods into the dylib to support
// applications compiled against older libraries.
#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 #endif
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
@@ -50,6 +80,9 @@
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) #define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#endif
#ifndef __has_attribute #ifndef __has_attribute
#define __has_attribute(__x) 0 #define __has_attribute(__x) 0
@@ -68,6 +101,37 @@
#ifndef __is_identifier #ifndef __is_identifier
#define __is_identifier(__x) 1 #define __is_identifier(__x) 1
#endif #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. // Need to detect which libc we're using if we're on Linux.
#if defined(__linux__) #if defined(__linux__)
@@ -127,24 +191,22 @@
# define _LIBCPP_HAS_QUICK_EXIT # define _LIBCPP_HAS_QUICK_EXIT
#endif // __NetBSD__ #endif // __NetBSD__
#ifdef _WIN32 #if defined(_WIN32)
# define _LIBCPP_WIN32API 1
# define _LIBCPP_LITTLE_ENDIAN 1 # define _LIBCPP_LITTLE_ENDIAN 1
# define _LIBCPP_BIG_ENDIAN 0 # define _LIBCPP_BIG_ENDIAN 0
// Compiler intrinsics (MSVC) # define _LIBCPP_SHORT_WCHAR 1
#if defined(_MSC_VER) && _MSC_VER >= 1400 // If mingw not explicitly detected, assume using MS C runtime only.
# define _LIBCPP_HAS_IS_BASE_OF
# endif
# if defined(_MSC_VER) && !defined(__clang__)
# define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
# 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))
# endif
# // If mingw not explicitly detected, assume using MS C runtime only.
# ifndef __MINGW32__ # ifndef __MINGW32__
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
# endif # endif
#endif // _WIN32 # 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
#endif // defined(_WIN32)
#ifdef __sun__ #ifdef __sun__
# include <sys/isa_defs.h> # include <sys/isa_defs.h>
@@ -168,7 +230,7 @@
// including accesses to the special files under /dev. C++11's // including accesses to the special files under /dev. C++11's
// std::random_device is instead exposed through a NaCl syscall. // std::random_device is instead exposed through a NaCl syscall.
# define _LIBCPP_USING_NACL_RANDOM # define _LIBCPP_USING_NACL_RANDOM
#elif defined(_WIN32) #elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_USING_WIN32_RANDOM # define _LIBCPP_USING_WIN32_RANDOM
#else #else
# define _LIBCPP_USING_DEV_RANDOM # define _LIBCPP_USING_DEV_RANDOM
@@ -193,91 +255,7 @@
#define _LIBCPP_NO_CFI #define _LIBCPP_NO_CFI
#endif #endif
#ifdef _WIN32 #if defined(_LIBCPP_COMPILER_CLANG)
// only really useful for a DLL
#ifdef _LIBCPP_DLL // this should be a compiler builtin define ideally...
# ifdef cxx_EXPORTS
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS __declspec(dllexport)
# define _LIBCPP_TYPE_VIS __declspec(dllexport)
# else
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS __declspec(dllimport)
# define _LIBCPP_TYPE_VIS __declspec(dllimport)
# endif
#else
# define _LIBCPP_HIDDEN
# define _LIBCPP_FUNC_VIS
# define _LIBCPP_TYPE_VIS
#endif
#define _LIBCPP_TYPE_VIS_ONLY
#define _LIBCPP_FUNC_VIS_ONLY
#ifndef _LIBCPP_INLINE_VISIBILITY
# ifdef _LIBCPP_MSVC
# define _LIBCPP_INLINE_VISIBILITY __forceinline
# else // MinGW GCC and Clang
# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
# endif
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
#endif
#ifndef _LIBCPP_ALWAYS_INLINE
# ifdef _LIBCPP_MSVC
# define _LIBCPP_ALWAYS_INLINE __forceinline
# endif
#endif
#endif // _WIN32
#ifndef _LIBCPP_HIDDEN
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
#endif
#ifndef _LIBCPP_FUNC_VIS
#define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default")))
#endif
#ifndef _LIBCPP_TYPE_VIS
# if __has_attribute(__type_visibility__)
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
# endif
#endif
#ifndef _LIBCPP_PREFERRED_OVERLOAD
# if __has_attribute(__enable_if__)
# define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, "")))
# endif
#endif
#ifndef _LIBCPP_TYPE_VIS_ONLY
# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS
#endif
#ifndef _LIBCPP_FUNC_VIS_ONLY
# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
#endif
#ifndef _LIBCPP_INLINE_VISIBILITY
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
#endif
#ifndef _LIBCPP_ALWAYS_INLINE
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif
#if defined(__clang__)
// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
@@ -295,10 +273,6 @@
# define _ALIGNAS(x) __attribute__((__aligned__(x))) # define _ALIGNAS(x) __attribute__((__aligned__(x)))
#endif #endif
#if !__has_feature(cxx_alias_templates)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif
#if __cplusplus < 201103L #if __cplusplus < 201103L
typedef __char16_t char16_t; typedef __char16_t char16_t;
typedef __char32_t char32_t; typedef __char32_t char32_t;
@@ -326,50 +300,30 @@ typedef __char32_t char32_t;
# define _LIBCPP_NORETURN __attribute__ ((noreturn)) # define _LIBCPP_NORETURN __attribute__ ((noreturn))
#endif #endif
#if !(__has_feature(cxx_default_function_template_args))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#endif
#if !(__has_feature(cxx_defaulted_functions))
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif // !(__has_feature(cxx_defaulted_functions))
#if !(__has_feature(cxx_deleted_functions))
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#endif // !(__has_feature(cxx_deleted_functions))
#if !(__has_feature(cxx_lambdas)) #if !(__has_feature(cxx_lambdas))
#define _LIBCPP_HAS_NO_LAMBDAS #define _LIBCPP_HAS_NO_LAMBDAS
#endif #endif
#if !(__has_feature(cxx_nullptr)) #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 # define _LIBCPP_HAS_NO_NULLPTR
# endif # endif
#endif
#if !(__has_feature(cxx_rvalue_references)) #if !(__has_feature(cxx_rvalue_references))
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif #endif
#if !(__has_feature(cxx_static_assert))
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#if !(__has_feature(cxx_auto_type)) #if !(__has_feature(cxx_auto_type))
#define _LIBCPP_HAS_NO_AUTO_TYPE #define _LIBCPP_HAS_NO_AUTO_TYPE
#endif #endif
#if !(__has_feature(cxx_access_control_sfinae)) || !__has_feature(cxx_trailing_return)
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif
#if !(__has_feature(cxx_variadic_templates)) #if !(__has_feature(cxx_variadic_templates))
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#endif #endif
#if !(__has_feature(cxx_trailing_return))
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#endif
#if !(__has_feature(cxx_generalized_initializers)) #if !(__has_feature(cxx_generalized_initializers))
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#endif #endif
@@ -408,6 +362,9 @@ typedef __char32_t char32_t;
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
#define _LIBCPP_HAS_QUICK_EXIT #define _LIBCPP_HAS_QUICK_EXIT
#define _LIBCPP_HAS_C11_FEATURES #define _LIBCPP_HAS_C11_FEATURES
#elif defined(__Fuchsia__)
#define _LIBCPP_HAS_QUICK_EXIT
#define _LIBCPP_HAS_C11_FEATURES
#elif defined(__linux__) #elif defined(__linux__)
#if !defined(_LIBCPP_HAS_MUSL_LIBC) #if !defined(_LIBCPP_HAS_MUSL_LIBC)
#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__) #if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
@@ -454,7 +411,7 @@ namespace std {
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
#endif #endif
#elif defined(__GNUC__) #elif defined(_LIBCPP_COMPILER_GCC)
#define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS(x) __attribute__((__aligned__(x)))
#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
@@ -494,34 +451,23 @@ namespace std {
#endif #endif
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STRONG_ENUMS #define _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#else // __GXX_EXPERIMENTAL_CXX0X__ #else // __GXX_EXPERIMENTAL_CXX0X__
#if _GNUC_VER < 403 #if _GNUC_VER < 403
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_RVALUE_REFERENCES #define _LIBCPP_HAS_NO_RVALUE_REFERENCES
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif #endif
#if _GNUC_VER < 404 #if _GNUC_VER < 404
#define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DECLTYPE
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_TRAILING_RETURN
#define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -530,12 +476,6 @@ namespace std {
#if _GNUC_VER < 406 #if _GNUC_VER < 406
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#endif
#if _GNUC_VER < 407
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#endif #endif
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
@@ -554,23 +494,29 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#define _LIBCPP_HAS_NO_ASAN #define _LIBCPP_HAS_NO_ASAN
#endif #endif
#elif defined(_LIBCPP_MSVC) #elif defined(_LIBCPP_COMPILER_MSVC)
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #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_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#if _MSC_VER <= 1800
#define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #endif
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#define __alignof__ __alignof #define __alignof__ __alignof
#define _LIBCPP_NORETURN __declspec(noreturn) #define _LIBCPP_NORETURN __declspec(noreturn)
#define _ALIGNAS(x) __declspec(align(x)) #define _ALIGNAS(x) __declspec(align(x))
#define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
#define _LIBCPP_END_NAMESPACE_STD } #define _LIBCPP_END_NAMESPACE_STD }
#define _VSTD std #define _VSTD std
@@ -581,16 +527,13 @@ namespace std {
#define _LIBCPP_HAS_NO_ASAN #define _LIBCPP_HAS_NO_ASAN
#elif defined(__IBMCPP__) #elif defined(_LIBCPP_COMPILER_IBM)
#define _ALIGNAS(x) __attribute__((__aligned__(x))) #define _ALIGNAS(x) __attribute__((__aligned__(x)))
#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x))))
#define _ATTRIBUTE(x) __attribute__((x)) #define _ATTRIBUTE(x) __attribute__((x))
#define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_NORETURN __attribute__((noreturn))
#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NOEXCEPT
#define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_NULLPTR
@@ -614,7 +557,155 @@ namespace std {
#define _LIBCPP_HAS_NO_ASAN #define _LIBCPP_HAS_NO_ASAN
#endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
#if defined(__ELF__)
#define _LIBCPP_OBJECT_FORMAT_ELF 1
#elif defined(__MACH__)
#define _LIBCPP_OBJECT_FORMAT_MACHO 1
#else
#define _LIBCPP_OBJECT_FORMAT_COFF 1
#endif
#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_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_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)
# if __has_attribute(__type_visibility__)
# define _LIBCPP_TYPE_VIS __attribute__ ((__type_visibility__("default")))
# else
# define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
# endif
# else
# define _LIBCPP_TYPE_VIS
# endif
#endif
#ifndef _LIBCPP_TEMPLATE_VIS
# define _LIBCPP_TEMPLATE_VIS _LIBCPP_TYPE_VIS
#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__ ((__type_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 #ifndef _LIBCPP_HAS_NO_NOEXCEPT
# define _NOEXCEPT noexcept # define _NOEXCEPT noexcept
@@ -624,6 +715,17 @@ namespace std {
# define _NOEXCEPT_(x) # define _NOEXCEPT_(x)
#endif #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 #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef unsigned short char16_t; typedef unsigned short char16_t;
typedef unsigned int char32_t; typedef unsigned int char32_t;
@@ -633,8 +735,10 @@ typedef unsigned int char32_t;
#define _LIBCPP_HAS_NO_INT128 #define _LIBCPP_HAS_NO_INT128
#endif #endif
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT #ifdef _LIBCPP_CXX03_LANG
# if __has_extension(c_static_assert)
# define static_assert(__b, __m) _Static_assert(__b, __m)
# else
extern "C++" { extern "C++" {
template <bool> struct __static_assert_test; template <bool> struct __static_assert_test;
template <> struct __static_assert_test<true> {}; template <> struct __static_assert_test<true> {};
@@ -643,12 +747,12 @@ template <unsigned> struct __static_assert_check {};
#define static_assert(__b, __m) \ #define static_assert(__b, __m) \
typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \ typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
_LIBCPP_CONCAT(__t, __LINE__) _LIBCPP_CONCAT(__t, __LINE__)
# endif // __has_extension(c_static_assert)
#endif // _LIBCPP_HAS_NO_STATIC_ASSERT #endif // _LIBCPP_CXX03_LANG
#ifdef _LIBCPP_HAS_NO_DECLTYPE #ifdef _LIBCPP_HAS_NO_DECLTYPE
// GCC 4.6 provides __decltype in all standard modes. // GCC 4.6 provides __decltype in all standard modes.
#if !__is_identifier(__decltype) || _GNUC_VER >= 406 #if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
# define decltype(__x) __decltype(__x) # define decltype(__x) __decltype(__x)
#else #else
# define decltype(__x) __typeof__(__x) # define decltype(__x) __typeof__(__x)
@@ -661,13 +765,13 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_CONSTEXPR constexpr #define _LIBCPP_CONSTEXPR constexpr
#endif #endif
#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #ifdef _LIBCPP_CXX03_LANG
#define _LIBCPP_DEFAULT {} #define _LIBCPP_DEFAULT {}
#else #else
#define _LIBCPP_DEFAULT = default; #define _LIBCPP_DEFAULT = default;
#endif #endif
#ifdef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifdef _LIBCPP_CXX03_LANG
#define _LIBCPP_EQUAL_DELETE #define _LIBCPP_EQUAL_DELETE
#else #else
#define _LIBCPP_EQUAL_DELETE = delete #define _LIBCPP_EQUAL_DELETE = delete
@@ -679,7 +783,8 @@ template <unsigned> struct __static_assert_check {};
#define _NOALIAS #define _NOALIAS
#endif #endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) #if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
(!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions
# define _LIBCPP_EXPLICIT explicit # define _LIBCPP_EXPLICIT explicit
#else #else
# define _LIBCPP_EXPLICIT # define _LIBCPP_EXPLICIT
@@ -698,7 +803,7 @@ template <unsigned> struct __static_assert_check {};
_LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \ _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
}; };
#else // _LIBCPP_HAS_NO_STRONG_ENUMS #else // _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_TYPE_VIS x #define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS #endif // _LIBCPP_HAS_NO_STRONG_ENUMS
@@ -725,14 +830,14 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63) #define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
#endif #endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \ #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__) defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1 #define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif #endif
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
// Most unix variants have catopen. These are the specific ones that don't. // Most unix variants have catopen. These are the specific ones that don't.
#if !defined(_WIN32) && !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) #if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION)
#define _LIBCPP_HAS_CATOPEN 1 #define _LIBCPP_HAS_CATOPEN 1
#endif #endif
#endif #endif
@@ -741,6 +846,18 @@ template <unsigned> struct __static_assert_check {};
#define _DECLARE_C99_LDBL_MATH 1 #define _DECLARE_C99_LDBL_MATH 1
#endif #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__) #if defined(__APPLE__) || defined(__FreeBSD__)
#define _LIBCPP_HAS_DEFAULTRUNELOCALE #define _LIBCPP_HAS_DEFAULTRUNELOCALE
#endif #endif
@@ -749,17 +866,13 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_WCTYPE_IS_MASK #define _LIBCPP_WCTYPE_IS_MASK
#endif #endif
#ifndef _LIBCPP_TRIVIAL_PAIR_COPY_CTOR
# define _LIBCPP_TRIVIAL_PAIR_COPY_CTOR 1
#endif
#ifndef _LIBCPP_STD_VER #ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L # if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11 # define _LIBCPP_STD_VER 11
# elif __cplusplus <= 201402L # elif __cplusplus <= 201402L
# define _LIBCPP_STD_VER 14 # define _LIBCPP_STD_VER 14
# else # else
# define _LIBCPP_STD_VER 15 // current year, or date of c++17 ratification # define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
# endif # endif
#endif // _LIBCPP_STD_VER #endif // _LIBCPP_STD_VER
@@ -789,6 +902,11 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_CONSTEXPR_AFTER_CXX14 #define _LIBCPP_CONSTEXPR_AFTER_CXX14
#endif #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 #ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) # define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x)
#else #else
@@ -796,7 +914,7 @@ template <unsigned> struct __static_assert_check {};
#endif #endif
#ifndef _LIBCPP_HAS_NO_ASAN #ifndef _LIBCPP_HAS_NO_ASAN
extern "C" void __sanitizer_annotate_contiguous_container( _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
const void *, const void *, const void *, const void *); const void *, const void *, const void *, const void *);
#endif #endif
@@ -817,19 +935,32 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#endif #endif
// Thread API // Thread API
#ifndef _LIBCPP_HAS_NO_THREADS #if !defined(_LIBCPP_HAS_NO_THREADS) && \
!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# if defined(__FreeBSD__) || \ # if defined(__FreeBSD__) || \
defined(__Fuchsia__) || \
defined(__NetBSD__) || \ defined(__NetBSD__) || \
defined(__linux__) || \ defined(__linux__) || \
defined(__APPLE__) || \ defined(__APPLE__) || \
defined(__CloudABI__) || \ defined(__CloudABI__) || \
defined(__sun__) defined(__sun__)
# define _LIBCPP_THREAD_API_PTHREAD # define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_HAS_THREAD_API_WIN32
# else # else
# error "No thread API" # error "No thread API"
# endif // _LIBCPP_THREAD_API # endif // _LIBCPP_HAS_THREAD_API
#endif // _LIBCPP_HAS_NO_THREADS #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_EXTERNAL_THREAD_API may not be defined when \
_LIBCPP_HAS_NO_THREADS is defined.
#endif
#if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS)
# error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \
@@ -856,13 +987,13 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif #endif
// Thread-unsafe functions such as strtok(), mbtowc() and localtime() // Thread-unsafe functions such as strtok() and localtime()
// are not available. // are not available.
#ifdef __CloudABI__ #ifdef __CloudABI__
#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
#endif #endif
#if __has_feature(cxx_atomic) || __has_extension(c_atomic) #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
#define _LIBCPP_HAS_C_ATOMIC_IMP #define _LIBCPP_HAS_C_ATOMIC_IMP
#elif _GNUC_VER > 407 #elif _GNUC_VER > 407
#define _LIBCPP_HAS_GCC_ATOMIC_IMP #define _LIBCPP_HAS_GCC_ATOMIC_IMP
@@ -877,19 +1008,44 @@ extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
#endif #endif
#if __cplusplus < 201103L
#define _LIBCPP_CXX03_LANG
#else
#if defined(_LIBCPP_HAS_NO_VARIADIC_TEMPLATES) || defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
#error Libc++ requires a feature complete C++11 compiler in C++11 or greater.
#endif
#endif
#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \ #if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
&& __has_attribute(acquire_capability)) && __has_attribute(acquire_capability))
#define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
#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 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
#endif // __cplusplus #endif // __cplusplus
#endif // _LIBCPP_CONFIG #endif // _LIBCPP_CONFIG

View File

@@ -19,5 +19,9 @@
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK #cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
#cmakedefine _LIBCPP_HAS_MUSL_LIBC #cmakedefine _LIBCPP_HAS_MUSL_LIBC
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
#endif // _LIBCPP_CONFIG_SITE #endif // _LIBCPP_CONFIG_SITE

View File

@@ -17,23 +17,103 @@
#pragma GCC system_header #pragma GCC system_header
#endif #endif
#if _LIBCPP_DEBUG_LEVEL >= 1 #if defined(_LIBCPP_HAS_NO_NULLPTR)
# include <cstddef>
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
# include <cstdlib> # include <cstdlib>
# include <cstdio> # include <cstdio>
# include <cstddef> # include <cstddef>
# ifndef _LIBCPP_ASSERT # include <exception>
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort()))
#endif #endif
#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \
_VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m)))
#endif
#if _LIBCPP_DEBUG_LEVEL >= 2
#ifndef _LIBCPP_DEBUG_ASSERT
#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m)
#endif
#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__
#endif #endif
#ifndef _LIBCPP_ASSERT #ifndef _LIBCPP_ASSERT
# define _LIBCPP_ASSERT(x, m) ((void)0) # define _LIBCPP_ASSERT(x, m) ((void)0)
#endif #endif
#ifndef _LIBCPP_DEBUG_ASSERT
# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0)
#endif
#ifndef _LIBCPP_DEBUG_MODE
#define _LIBCPP_DEBUG_MODE(...) ((void)0)
#endif
#if _LIBCPP_DEBUG_LEVEL >= 2 #if _LIBCPP_DEBUG_LEVEL < 1
class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception;
#endif
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info()
: __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
const char* __file_;
int __line_;
const char* __pred_;
const char* __msg_;
};
/// __libcpp_debug_function_type - The type of the assertion failure handler.
typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&);
/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT
/// fails.
extern _LIBCPP_EXTERN_VIS __libcpp_debug_function_type __libcpp_debug_function;
/// __libcpp_abort_debug_function - A debug handler that aborts when called.
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
/// __libcpp_throw_debug_function - A debug handler that throws
/// an instance of __libcpp_debug_exception when called.
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __libcpp_throw_debug_function(__libcpp_debug_info const&);
/// __libcpp_set_debug_function - Set the debug handler to the specified
/// function.
_LIBCPP_FUNC_VIS
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
// Setup the throwing debug handler during dynamic initialization.
#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
# if defined(_LIBCPP_NO_EXCEPTIONS)
# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled.
# endif
static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function);
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception {
public:
__libcpp_debug_exception() _NOEXCEPT;
explicit __libcpp_debug_exception(__libcpp_debug_info const& __i);
__libcpp_debug_exception(__libcpp_debug_exception const&);
~__libcpp_debug_exception() _NOEXCEPT;
const char* what() const _NOEXCEPT;
private:
struct __libcpp_debug_exception_imp;
__libcpp_debug_exception_imp *__imp_;
};
#endif
#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
struct _LIBCPP_TYPE_VIS __c_node; struct _LIBCPP_TYPE_VIS __c_node;
struct _LIBCPP_TYPE_VIS __i_node struct _LIBCPP_TYPE_VIS __i_node
@@ -42,7 +122,7 @@ struct _LIBCPP_TYPE_VIS __i_node
__i_node* __next_; __i_node* __next_;
__c_node* __c_; __c_node* __c_;
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__i_node(const __i_node&) = delete; __i_node(const __i_node&) = delete;
__i_node& operator=(const __i_node&) = delete; __i_node& operator=(const __i_node&) = delete;
#else #else
@@ -65,7 +145,7 @@ struct _LIBCPP_TYPE_VIS __c_node
__i_node** end_; __i_node** end_;
__i_node** cap_; __i_node** cap_;
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__c_node(const __c_node&) = delete; __c_node(const __c_node&) = delete;
__c_node& operator=(const __c_node&) = delete; __c_node& operator=(const __c_node&) = delete;
#else #else
@@ -102,7 +182,7 @@ struct _C_node
}; };
template <class _Cont> template <class _Cont>
bool inline bool
_C_node<_Cont>::__dereferenceable(const void* __i) const _C_node<_Cont>::__dereferenceable(const void* __i) const
{ {
typedef typename _Cont::const_iterator iterator; typedef typename _Cont::const_iterator iterator;
@@ -112,7 +192,7 @@ _C_node<_Cont>::__dereferenceable(const void* __i) const
} }
template <class _Cont> template <class _Cont>
bool inline bool
_C_node<_Cont>::__decrementable(const void* __i) const _C_node<_Cont>::__decrementable(const void* __i) const
{ {
typedef typename _Cont::const_iterator iterator; typedef typename _Cont::const_iterator iterator;
@@ -122,7 +202,7 @@ _C_node<_Cont>::__decrementable(const void* __i) const
} }
template <class _Cont> template <class _Cont>
bool inline bool
_C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const _C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
{ {
typedef typename _Cont::const_iterator iterator; typedef typename _Cont::const_iterator iterator;
@@ -132,7 +212,7 @@ _C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const
} }
template <class _Cont> template <class _Cont>
bool inline bool
_C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const _C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const
{ {
typedef typename _Cont::const_iterator iterator; typedef typename _Cont::const_iterator iterator;
@@ -152,7 +232,7 @@ class _LIBCPP_TYPE_VIS __libcpp_db
__libcpp_db(); __libcpp_db();
public: public:
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__libcpp_db(const __libcpp_db&) = delete; __libcpp_db(const __libcpp_db&) = delete;
__libcpp_db& operator=(const __libcpp_db&) = delete; __libcpp_db& operator=(const __libcpp_db&) = delete;
#else #else
@@ -214,9 +294,9 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db();
_LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db();
_LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
#endif _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_DEBUG_H #endif // _LIBCPP_DEBUG_H

View File

@@ -445,7 +445,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const
} // __function } // __function
template<class _Rp> template<class _Rp>
class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> class _LIBCPP_TEMPLATE_VIS function<_Rp()>
{ {
typedef __function::__base<_Rp()> __base; typedef __function::__base<_Rp()> __base;
aligned_storage<3*sizeof(void*)>::type __buf_; aligned_storage<3*sizeof(void*)>::type __buf_;
@@ -642,6 +642,8 @@ template<class _Rp>
void void
function<_Rp()>::swap(function& __f) function<_Rp()>::swap(function& __f)
{ {
if (_VSTD::addressof(__f) == this)
return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{ {
typename aligned_storage<sizeof(__buf_)>::type __tempbuf; typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -679,10 +681,8 @@ template<class _Rp>
_Rp _Rp
function<_Rp()>::operator()() const function<_Rp()>::operator()() const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); __throw_bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
return (*__f_)(); return (*__f_)();
} }
@@ -720,7 +720,7 @@ function<_Rp()>::target() const
#endif // _LIBCPP_NO_RTTI #endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0> template<class _Rp, class _A0>
class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)>
: public unary_function<_A0, _Rp> : public unary_function<_A0, _Rp>
{ {
typedef __function::__base<_Rp(_A0)> __base; typedef __function::__base<_Rp(_A0)> __base;
@@ -918,6 +918,8 @@ template<class _Rp, class _A0>
void void
function<_Rp(_A0)>::swap(function& __f) function<_Rp(_A0)>::swap(function& __f)
{ {
if (_VSTD::addressof(__f) == this)
return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{ {
typename aligned_storage<sizeof(__buf_)>::type __tempbuf; typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -955,10 +957,8 @@ template<class _Rp, class _A0>
_Rp _Rp
function<_Rp(_A0)>::operator()(_A0 __a0) const function<_Rp(_A0)>::operator()(_A0 __a0) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); __throw_bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
return (*__f_)(__a0); return (*__f_)(__a0);
} }
@@ -996,7 +996,7 @@ function<_Rp(_A0)>::target() const
#endif // _LIBCPP_NO_RTTI #endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0, class _A1> template<class _Rp, class _A0, class _A1>
class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)>
: public binary_function<_A0, _A1, _Rp> : public binary_function<_A0, _A1, _Rp>
{ {
typedef __function::__base<_Rp(_A0, _A1)> __base; typedef __function::__base<_Rp(_A0, _A1)> __base;
@@ -1194,6 +1194,8 @@ template<class _Rp, class _A0, class _A1>
void void
function<_Rp(_A0, _A1)>::swap(function& __f) function<_Rp(_A0, _A1)>::swap(function& __f)
{ {
if (_VSTD::addressof(__f) == this)
return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{ {
typename aligned_storage<sizeof(__buf_)>::type __tempbuf; typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -1231,10 +1233,8 @@ template<class _Rp, class _A0, class _A1>
_Rp _Rp
function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); __throw_bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
return (*__f_)(__a0, __a1); return (*__f_)(__a0, __a1);
} }
@@ -1272,7 +1272,7 @@ function<_Rp(_A0, _A1)>::target() const
#endif // _LIBCPP_NO_RTTI #endif // _LIBCPP_NO_RTTI
template<class _Rp, class _A0, class _A1, class _A2> template<class _Rp, class _A0, class _A1, class _A2>
class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)>
{ {
typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; typedef __function::__base<_Rp(_A0, _A1, _A2)> __base;
aligned_storage<3*sizeof(void*)>::type __buf_; aligned_storage<3*sizeof(void*)>::type __buf_;
@@ -1470,6 +1470,8 @@ template<class _Rp, class _A0, class _A1, class _A2>
void void
function<_Rp(_A0, _A1, _A2)>::swap(function& __f) function<_Rp(_A0, _A1, _A2)>::swap(function& __f)
{ {
if (_VSTD::addressof(__f) == this)
return;
if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_)
{ {
typename aligned_storage<sizeof(__buf_)>::type __tempbuf; typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
@@ -1507,10 +1509,8 @@ template<class _Rp, class _A0, class _A1, class _A2>
_Rp _Rp
function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); __throw_bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
return (*__f_)(__a0, __a1, __a2); return (*__f_)(__a0, __a1, __a2);
} }

View File

@@ -16,6 +16,7 @@
#include <typeinfo> #include <typeinfo>
#include <exception> #include <exception>
#include <new> #include <new>
#include <utility>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -23,15 +24,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Arg, class _Result>
struct _LIBCPP_TYPE_VIS_ONLY unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Arg1, class _Arg2, class _Result> template <class _Arg1, class _Arg2, class _Result>
struct _LIBCPP_TYPE_VIS_ONLY binary_function struct _LIBCPP_TEMPLATE_VIS binary_function
{ {
typedef _Arg1 first_argument_type; typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type; typedef _Arg2 second_argument_type;
@@ -54,7 +48,7 @@ template <class _Tp = void>
#else #else
template <class _Tp> template <class _Tp>
#endif #endif
struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool> struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool>
{ {
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const bool operator()(const _Tp& __x, const _Tp& __y) const
@@ -63,7 +57,7 @@ struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool>
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
template <> template <>
struct _LIBCPP_TYPE_VIS_ONLY less<void> struct _LIBCPP_TEMPLATE_VIS less<void>
{ {
template <class _T1, class _T2> template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
@@ -382,7 +376,7 @@ struct __invoke_void_return_wrapper<void>
}; };
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY reference_wrapper class _LIBCPP_TEMPLATE_VIS reference_wrapper
: public __weak_result_type<_Tp> : public __weak_result_type<_Tp>
{ {
public: public:
@@ -552,23 +546,10 @@ cref(reference_wrapper<_Tp> __t) _NOEXCEPT
return cref(__t.get()); return cref(__t.get());
} }
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_CXX03_LANG
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
template <class _Tp> void ref(const _Tp&&) = delete; template <class _Tp> void ref(const _Tp&&) = delete;
template <class _Tp> void cref(const _Tp&&) = delete; template <class _Tp> void cref(const _Tp&&) = delete;
#endif
#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
template <class _Tp> void ref(const _Tp&&);// = delete;
template <class _Tp> void cref(const _Tp&&);// = delete;
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#endif // _LIBCPP_HAS_NO_VARIADICS
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
template <class _Tp1, class _Tp2 = void> template <class _Tp1, class _Tp2 = void>
@@ -585,7 +566,7 @@ public:
// allocator_arg_t // allocator_arg_t
struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { }; struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY)
extern const allocator_arg_t allocator_arg; extern const allocator_arg_t allocator_arg;
@@ -620,11 +601,16 @@ struct __uses_allocator<_Tp, _Alloc, false>
}; };
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator struct _LIBCPP_TEMPLATE_VIS uses_allocator
: public __uses_allocator<_Tp, _Alloc> : public __uses_allocator<_Tp, _Alloc>
{ {
}; };
#if _LIBCPP_STD_VER > 14
template <class _Tp, class _Alloc>
constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
#endif
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
// allocator construction // allocator construction
@@ -632,7 +618,8 @@ struct _LIBCPP_TYPE_VIS_ONLY uses_allocator
template <class _Tp, class _Alloc, class ..._Args> template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp struct __uses_alloc_ctor_imp
{ {
static const bool __ua = uses_allocator<_Tp, _Alloc>::value; typedef typename __uncvref<_Alloc>::type _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic = static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
static const int value = __ua ? 2 - __ic : 0; static const int value = __ua ? 2 - __ic : 0;
@@ -650,6 +637,7 @@ void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, con
new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); new (__storage) _Tp (_VSTD::forward<_Args>(__args)...);
} }
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args> template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
@@ -657,6 +645,7 @@ void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, con
new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...);
} }
// FIXME: This should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args> template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args )
@@ -664,6 +653,7 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con
new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a);
} }
// FIXME: Theis should have a version which takes a non-const alloc.
template <class _Tp, class _Allocator, class... _Args> template <class _Tp, class _Allocator, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args) void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args)

File diff suppressed because it is too large Load Diff

1
include/__libcpp_version Normal file
View File

@@ -0,0 +1 @@
5000

View File

@@ -165,10 +165,9 @@ template <class _Facet>
locale locale
locale::combine(const locale& __other) const locale::combine(const locale& __other) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!_VSTD::has_facet<_Facet>(__other)) if (!_VSTD::has_facet<_Facet>(__other))
throw runtime_error("locale::combine: locale missing facet"); __throw_runtime_error("locale::combine: locale missing facet");
#endif // _LIBCPP_NO_EXCEPTIONS
return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other))); return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
} }
@@ -191,7 +190,7 @@ use_facet(const locale& __l)
// template <class _CharT> class collate; // template <class _CharT> class collate;
template <class _CharT> template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY collate class _LIBCPP_TEMPLATE_VIS collate
: public locale::facet : public locale::facet
{ {
public: public:
@@ -270,12 +269,12 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const
return static_cast<long>(__h); return static_cast<long>(__h);
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>)
// template <class CharT> class collate_byname; // template <class CharT> class collate_byname;
template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY collate_byname; template <class _CharT> class _LIBCPP_TEMPLATE_VIS collate_byname;
template <> template <>
class _LIBCPP_TYPE_VIS collate_byname<char> class _LIBCPP_TYPE_VIS collate_byname<char>
@@ -343,7 +342,7 @@ public:
static const mask punct = _ISpunct; static const mask punct = _ISpunct;
static const mask xdigit = _ISxdigit; static const mask xdigit = _ISxdigit;
static const mask blank = _ISblank; static const mask blank = _ISblank;
#elif defined(_WIN32) #elif defined(_LIBCPP_MSVCRT)
typedef unsigned short mask; typedef unsigned short mask;
static const mask space = _SPACE; static const mask space = _SPACE;
static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT; static const mask print = _BLANK|_PUNCT|_ALPHA|_DIGIT;
@@ -426,7 +425,7 @@ public:
_LIBCPP_ALWAYS_INLINE ctype_base() {} _LIBCPP_ALWAYS_INLINE ctype_base() {}
}; };
template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype; template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype;
template <> template <>
class _LIBCPP_TYPE_VIS ctype<wchar_t> class _LIBCPP_TYPE_VIS ctype<wchar_t>
@@ -653,7 +652,7 @@ protected:
// template <class CharT> class ctype_byname; // template <class CharT> class ctype_byname;
template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype_byname; template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype_byname;
template <> template <>
class _LIBCPP_TYPE_VIS ctype_byname<char> class _LIBCPP_TYPE_VIS ctype_byname<char>
@@ -814,7 +813,7 @@ public:
// template <class internT, class externT, class stateT> class codecvt; // template <class internT, class externT, class stateT> class codecvt;
template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt; template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TEMPLATE_VIS codecvt;
// template <> class codecvt<char, char, mbstate_t> // template <> class codecvt<char, char, mbstate_t>
@@ -1160,7 +1159,7 @@ protected:
// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname // template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
template <class _InternT, class _ExternT, class _StateT> template <class _InternT, class _ExternT, class _StateT>
class _LIBCPP_TYPE_VIS_ONLY codecvt_byname class _LIBCPP_TEMPLATE_VIS codecvt_byname
: public codecvt<_InternT, _ExternT, _StateT> : public codecvt<_InternT, _ExternT, _StateT>
{ {
public: public:
@@ -1179,12 +1178,12 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname()
{ {
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
template <size_t _Np> template <size_t _Np>
struct __narrow_to_utf8 struct __narrow_to_utf8
@@ -1368,7 +1367,7 @@ struct __widen_from_utf8<32>
// template <class charT> class numpunct // template <class charT> class numpunct
template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct; template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct;
template <> template <>
class _LIBCPP_TYPE_VIS numpunct<char> class _LIBCPP_TYPE_VIS numpunct<char>
@@ -1434,7 +1433,7 @@ protected:
// template <class charT> class numpunct_byname // template <class charT> class numpunct_byname
template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; template <class _CharT> class _LIBCPP_TEMPLATE_VIS numpunct_byname;
template <> template <>
class _LIBCPP_TYPE_VIS numpunct_byname<char> class _LIBCPP_TYPE_VIS numpunct_byname<char>

View File

@@ -34,12 +34,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
{ {
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
#else
__libcpp_mutex_t __m_; __libcpp_mutex_t __m_;
#endif
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR #ifndef _LIBCPP_HAS_NO_CONSTEXPR
constexpr mutex() _NOEXCEPT : __m_(_LIBCPP_MUTEX_INITIALIZER) {} constexpr mutex() _NOEXCEPT = default;
#else #else
mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;} mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
#endif #endif
@@ -76,8 +80,21 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
#endif #endif
// Forward declare lock_guard as a variadic template even in C++03 to keep
// the mangling consistent between dialects.
#if defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
template <class ..._Mutexes>
class _LIBCPP_TEMPLATE_VIS lock_guard;
#endif
template <class _Mutex> template <class _Mutex>
class _LIBCPP_TYPE_VIS_ONLY _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) lock_guard class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
#if !defined(_LIBCPP_ABI_VARIADIC_LOCK_GUARD)
lock_guard
#else
lock_guard<_Mutex>
#endif
{ {
public: public:
typedef _Mutex mutex_type; typedef _Mutex mutex_type;
@@ -96,12 +113,12 @@ public:
~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();} ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
private: private:
lock_guard(lock_guard const&);// = delete; lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE;
lock_guard& operator=(lock_guard const&);// = delete; lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE;
}; };
template <class _Mutex> template <class _Mutex>
class _LIBCPP_TYPE_VIS_ONLY unique_lock class _LIBCPP_TEMPLATE_VIS unique_lock
{ {
public: public:
typedef _Mutex mutex_type; typedef _Mutex mutex_type;
@@ -274,13 +291,18 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
class _LIBCPP_TYPE_VIS condition_variable class _LIBCPP_TYPE_VIS condition_variable
{ {
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
#else
__libcpp_condvar_t __cv_; __libcpp_condvar_t __cv_;
#endif
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_CONSTEXPR #ifndef _LIBCPP_HAS_NO_CONSTEXPR
constexpr condition_variable() : __cv_(_LIBCPP_CONDVAR_INITIALIZER) {} constexpr condition_variable() _NOEXCEPT = default;
#else #else
condition_variable() {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;} condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
#endif #endif
~condition_variable(); ~condition_variable();
@@ -388,8 +410,8 @@ condition_variable::wait_for(unique_lock<mutex>& __lk,
typedef time_point<system_clock, duration<long double, nano> > __sys_tpf; typedef time_point<system_clock, duration<long double, nano> > __sys_tpf;
typedef time_point<system_clock, nanoseconds> __sys_tpi; typedef time_point<system_clock, nanoseconds> __sys_tpi;
__sys_tpf _Max = __sys_tpi::max(); __sys_tpf _Max = __sys_tpi::max();
system_clock::time_point __s_now = system_clock::now();
steady_clock::time_point __c_now = steady_clock::now(); steady_clock::time_point __c_now = steady_clock::now();
system_clock::time_point __s_now = system_clock::now();
if (_Max - __d > __s_now) if (_Max - __d > __s_now)
__do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d)); __do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d));
else else

View File

@@ -21,7 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TYPE_VIS_ONLY nullptr_t struct _LIBCPP_TEMPLATE_VIS nullptr_t
{ {
void* __lx; void* __lx;
@@ -42,10 +42,6 @@ struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;}
}; };
inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);}

View File

@@ -11,6 +11,7 @@
#define _LIBCPP___REFSTRING #define _LIBCPP___REFSTRING
#include <__config> #include <__config>
#include <stdexcept>
#include <cstddef> #include <cstddef>
#include <cstring> #include <cstring>
#ifdef __APPLE__ #ifdef __APPLE__
@@ -20,39 +21,28 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_HIDDEN __libcpp_refstring namespace __refstring_imp { namespace {
{
private:
const char* str_;
typedef int count_t; typedef int count_t;
struct _Rep_base struct _Rep_base {
{
std::size_t len; std::size_t len;
std::size_t cap; std::size_t cap;
count_t count; count_t count;
}; };
static inline _Rep_base* rep_from_data(const char *data_) noexcept {
_Rep_base*
rep_from_data(const char *data_) _NOEXCEPT
{
char *data = const_cast<char *>(data_); char *data = const_cast<char *>(data_);
return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base)); return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
} }
static
char * inline char * data_from_rep(_Rep_base *rep) noexcept {
data_from_rep(_Rep_base *rep) _NOEXCEPT
{
char *data = reinterpret_cast<char *>(rep); char *data = reinterpret_cast<char *>(rep);
return data + sizeof(*rep); return data + sizeof(*rep);
} }
#ifdef __APPLE__ #if defined(__APPLE__)
static inline
const char* const char* compute_gcc_empty_string_storage() _NOEXCEPT
compute_gcc_empty_string_storage() _NOEXCEPT
{ {
void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD); void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
if (handle == nullptr) if (handle == nullptr)
@@ -63,29 +53,21 @@ private:
return data_from_rep(reinterpret_cast<_Rep_base *>(sym)); return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
} }
static inline
const char* const char*
get_gcc_empty_string_storage() _NOEXCEPT get_gcc_empty_string_storage() _NOEXCEPT
{ {
static const char* p = compute_gcc_empty_string_storage(); static const char* p = compute_gcc_empty_string_storage();
return p; return p;
} }
bool
uses_refcount() const
{
return str_ != get_gcc_empty_string_storage();
}
#else
bool
uses_refcount() const
{
return true;
}
#endif #endif
public: }} // namespace __refstring_imp
explicit __libcpp_refstring(const char* msg) {
using namespace __refstring_imp;
inline
__libcpp_refstring::__libcpp_refstring(const char* msg) {
std::size_t len = strlen(msg); std::size_t len = strlen(msg);
_Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1)); _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
rep->len = len; rep->len = len;
@@ -93,22 +75,24 @@ public:
rep->count = 0; rep->count = 0;
char *data = data_from_rep(rep); char *data = data_from_rep(rep);
std::memcpy(data, msg, len + 1); std::memcpy(data, msg, len + 1);
str_ = data; __imp_ = data;
} }
__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_) inline
__libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT
: __imp_(s.__imp_)
{ {
if (uses_refcount()) if (__uses_refcount())
__sync_add_and_fetch(&rep_from_data(str_)->count, 1); __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
} }
__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT inline
{ __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) _NOEXCEPT {
bool adjust_old_count = uses_refcount(); bool adjust_old_count = __uses_refcount();
struct _Rep_base *old_rep = rep_from_data(str_); struct _Rep_base *old_rep = rep_from_data(__imp_);
str_ = s.str_; __imp_ = s.__imp_;
if (uses_refcount()) if (__uses_refcount())
__sync_add_and_fetch(&rep_from_data(str_)->count, 1); __sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
if (adjust_old_count) if (adjust_old_count)
{ {
if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0) if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
@@ -119,20 +103,24 @@ public:
return *this; return *this;
} }
~__libcpp_refstring() inline
{ __libcpp_refstring::~__libcpp_refstring() {
if (uses_refcount()) if (__uses_refcount()) {
{ _Rep_base* rep = rep_from_data(__imp_);
_Rep_base* rep = rep_from_data(str_); if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0)
{
::operator delete(rep); ::operator delete(rep);
} }
} }
} }
const char* c_str() const _NOEXCEPT {return str_;} inline
}; bool __libcpp_refstring::__uses_refcount() const {
#ifdef __APPLE__
return __imp_ != get_gcc_empty_string_storage();
#else
return true;
#endif
}
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@@ -15,8 +15,6 @@
#include <type_traits> #include <type_traits>
#include <new> #include <new>
#include <__undef___deallocate>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
#endif #endif
@@ -64,7 +62,7 @@ public:
if (__p == (pointer)&buf_) if (__p == (pointer)&buf_)
__allocated_ = false; __allocated_ = false;
else else
_VSTD::__deallocate(__p); _VSTD::__libcpp_deallocate(__p);
} }
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);} _LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}

View File

@@ -297,7 +297,7 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
return traits_type::eof(); return traits_type::eof();
if (__r == codecvt_base::partial) if (__r == codecvt_base::partial)
{ {
pbase = (char_type*)__e; pbase = const_cast<char_type*>(__e);
} }
} }
else else

873
include/__string Normal file
View File

@@ -0,0 +1,873 @@
// -*- C++ -*-
//===-------------------------- __string ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___STRING
#define _LIBCPP___STRING
/*
string synopsis
namespace std
{
template <class charT>
struct char_traits
{
typedef charT char_type;
typedef ... int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
static constexpr bool eq(char_type c1, char_type c2) noexcept;
static constexpr bool lt(char_type c1, char_type c2) noexcept;
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
static constexpr size_t length(const char_type* s);
static constexpr const char_type*
find(const char_type* s, size_t n, const char_type& a);
static char_type* move(char_type* s1, const char_type* s2, size_t n);
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
static char_type* assign(char_type* s, size_t n, char_type a);
static constexpr int_type not_eof(int_type c) noexcept;
static constexpr char_type to_char_type(int_type c) noexcept;
static constexpr int_type to_int_type(char_type c) noexcept;
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
static constexpr int_type eof() noexcept;
};
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;
} // std
*/
#include <__config>
#include <algorithm> // for search and min
#include <cstdio> // For EOF.
#include <memory> // for __murmur2_or_cityhash
#include <__undef_min_max>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
// char_traits
template <class _CharT>
struct _LIBCPP_TEMPLATE_VIS char_traits
{
typedef _CharT char_type;
typedef int int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14
assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;}
static _LIBCPP_CONSTEXPR_AFTER_CXX14
int compare(const char_type* __s1, const char_type* __s2, size_t __n);
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t length(const char_type* __s);
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
_LIBCPP_INLINE_VISIBILITY
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
_LIBCPP_INLINE_VISIBILITY
static char_type* assign(char_type* __s, size_t __n, char_type __a);
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);}
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);}
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(EOF);}
};
template <class _CharT>
_LIBCPP_CONSTEXPR_AFTER_CXX14 int
char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
}
template <class _CharT>
inline
_LIBCPP_CONSTEXPR_AFTER_CXX14 size_t
char_traits<_CharT>::length(const char_type* __s)
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
++__len;
return __len;
}
template <class _CharT>
inline
_LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT*
char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a)
{
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return 0;
}
template <class _CharT>
_CharT*
char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n)
{
char_type* __r = __s1;
if (__s1 < __s2)
{
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
}
else if (__s2 < __s1)
{
__s1 += __n;
__s2 += __n;
for (; __n; --__n)
assign(*--__s1, *--__s2);
}
return __r;
}
template <class _CharT>
inline
_CharT*
char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n)
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
char_type* __r = __s1;
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
return __r;
}
template <class _CharT>
inline
_CharT*
char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
{
char_type* __r = __s;
for (; __n; --__n, ++__s)
assign(*__s, __a);
return __r;
}
// char_traits<char>
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char>
{
typedef char char_type;
typedef int int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return (unsigned char)__c1 < (unsigned char)__c2;}
static _LIBCPP_CONSTEXPR_AFTER_CXX14
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14
length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);}
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
}
static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);}
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type((unsigned char)__c);}
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(EOF);}
};
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
int
char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
if (__n == 0)
return 0;
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_memcmp(__s1, __s2, __n);
#elif _LIBCPP_STD_VER <= 14
return memcmp(__s1, __s2, __n);
#else
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
#endif
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
const char*
char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
if (__n == 0)
return NULL;
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_char_memchr(__s, to_int_type(__a), __n);
#elif _LIBCPP_STD_VER <= 14
return (const char_type*) memchr(__s, to_int_type(__a), __n);
#else
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return NULL;
#endif
}
// char_traits<wchar_t>
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t>
{
typedef wchar_t char_type;
typedef wint_t int_type;
typedef streamoff off_type;
typedef streampos pos_type;
typedef mbstate_t state_type;
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;}
static _LIBCPP_CONSTEXPR_AFTER_CXX14
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
static _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t length(const char_type* __s) _NOEXCEPT;
static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
}
static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);}
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);}
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(WEOF);}
};
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
int
char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
if (__n == 0)
return 0;
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wmemcmp(__s1, __s2, __n);
#elif _LIBCPP_STD_VER <= 14
return wmemcmp(__s1, __s2, __n);
#else
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
#endif
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t
char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT
{
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wcslen(__s);
#elif _LIBCPP_STD_VER <= 14
return wcslen(__s);
#else
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
++__len;
return __len;
#endif
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
const wchar_t*
char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
if (__n == 0)
return NULL;
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_wmemchr(__s, __a, __n);
#elif _LIBCPP_STD_VER <= 14
return wmemchr(__s, __a, __n);
#else
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return NULL;
#endif
}
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
{
typedef char16_t char_type;
typedef uint_least16_t int_type;
typedef streamoff off_type;
typedef u16streampos pos_type;
typedef mbstate_t state_type;
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);}
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);}
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(0xFFFF);}
};
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
int
char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t
char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
++__len;
return __len;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
const char16_t*
char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return 0;
}
inline
char16_t*
char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
char_type* __r = __s1;
if (__s1 < __s2)
{
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
}
else if (__s2 < __s1)
{
__s1 += __n;
__s2 += __n;
for (; __n; --__n)
assign(*--__s1, *--__s2);
}
return __r;
}
inline
char16_t*
char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
char_type* __r = __s1;
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
return __r;
}
inline
char16_t*
char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
char_type* __r = __s;
for (; __n; --__n, ++__s)
assign(*__s, __a);
return __r;
}
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
{
typedef char32_t char_type;
typedef uint_least32_t int_type;
typedef streamoff off_type;
typedef u32streampos pos_type;
typedef mbstate_t state_type;
static inline _LIBCPP_CONSTEXPR_AFTER_CXX14
void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;}
static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT
{return char_type(__c);}
static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT
{return int_type(__c);}
static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT
{return __c1 == __c2;}
static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT
{return int_type(0xFFFFFFFF);}
};
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
int
char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
size_t
char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
++__len;
return __len;
}
inline _LIBCPP_CONSTEXPR_AFTER_CXX14
const char32_t*
char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return 0;
}
inline
char32_t*
char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
char_type* __r = __s1;
if (__s1 < __s2)
{
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
}
else if (__s2 < __s1)
{
__s1 += __n;
__s2 += __n;
for (; __n; --__n)
assign(*--__s1, *--__s2);
}
return __r;
}
inline
char32_t*
char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
char_type* __r = __s1;
for (; __n; --__n, ++__s1, ++__s2)
assign(*__s1, *__s2);
return __r;
}
inline
char32_t*
char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
char_type* __r = __s;
for (; __n; --__n, ++__s)
assign(*__s, __a);
return __r;
}
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
// helper fns for basic_string and string_view
// __str_find
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos >= __sz)
return __npos;
const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
if (__r == 0)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
template <class _CharT, class _Traits>
inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT *
__search_substring(const _CharT *__first1, const _CharT *__last1,
const _CharT *__first2, const _CharT *__last2) {
// Take advantage of knowing source and pattern lengths.
// Stop short when source is smaller than pattern.
const ptrdiff_t __len2 = __last2 - __first2;
if (__len2 == 0)
return __first1;
ptrdiff_t __len1 = __last1 - __first1;
if (__len1 < __len2)
return __last1;
// First element of __first2 is loop invariant.
_CharT __f2 = *__first2;
while (true) {
__len1 = __last1 - __first1;
// Check whether __first1 still has at least __len2 bytes.
if (__len1 < __len2)
return __last1;
// Find __f2 the first byte matching in __first1.
__first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2);
if (__first1 == 0)
return __last1;
// It is faster to compare from the first byte of __first1 even if we
// already know that it matches the first byte of __first2: this is because
// __first2 is most likely aligned, as it is user's "pattern" string, and
// __first1 + 1 is most likely not aligned, as the match is in the middle of
// the string.
if (_Traits::compare(__first1, __first2, __len2) == 0)
return __first1;
++__first1;
}
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos > __sz)
return __npos;
if (__n == 0) // There is nothing to search, just return __pos.
return __pos;
const _CharT *__r = __search_substring<_CharT, _Traits>(
__p + __pos, __p + __sz, __s, __s + __n);
if (__r == __p + __sz)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
// __str_rfind
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__sz < 1)
return __npos;
if (__pos < __sz)
++__pos;
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
{
if (_Traits::eq(*--__ps, __c))
return static_cast<_SizeT>(__ps - __p);
}
return __npos;
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_rfind(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
__pos = _VSTD::min(__pos, __sz);
if (__n < __sz - __pos)
__pos += __n;
else
__pos = __sz;
const _CharT* __r = _VSTD::__find_end(
__p, __p + __pos, __s, __s + __n, _Traits::eq,
random_access_iterator_tag(), random_access_iterator_tag());
if (__n > 0 && __r == __p + __pos)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
// __str_find_first_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_first_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos >= __sz || __n == 0)
return __npos;
const _CharT* __r = _VSTD::__find_first_of_ce
(__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq );
if (__r == __p + __sz)
return __npos;
return static_cast<_SizeT>(__r - __p);
}
// __str_find_last_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_last_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__n != 0)
{
if (__pos < __sz)
++__pos;
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
{
const _CharT* __r = _Traits::find(__s, __n, *--__ps);
if (__r)
return static_cast<_SizeT>(__ps - __p);
}
}
return __npos;
}
// __str_find_first_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos < __sz)
{
const _CharT* __pe = __p + __sz;
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
if (_Traits::find(__s, __n, *__ps) == 0)
return static_cast<_SizeT>(__ps - __p);
}
return __npos;
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_first_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos < __sz)
{
const _CharT* __pe = __p + __sz;
for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps)
if (!_Traits::eq(*__ps, __c))
return static_cast<_SizeT>(__ps - __p);
}
return __npos;
}
// __str_find_last_not_of
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT
{
if (__pos < __sz)
++__pos;
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
if (_Traits::find(__s, __n, *--__ps) == 0)
return static_cast<_SizeT>(__ps - __p);
return __npos;
}
template<class _CharT, class _SizeT, class _Traits, _SizeT __npos>
inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
__str_find_last_not_of(const _CharT *__p, _SizeT __sz,
_CharT __c, _SizeT __pos) _NOEXCEPT
{
if (__pos < __sz)
++__pos;
else
__pos = __sz;
for (const _CharT* __ps = __p + __pos; __ps != __p;)
if (!_Traits::eq(*--__ps, __c))
return static_cast<_SizeT>(__ps - __p);
return __npos;
}
template<class _Ptr>
inline _LIBCPP_INLINE_VISIBILITY
size_t __do_string_hash(_Ptr __p, _Ptr __e)
{
typedef typename iterator_traits<_Ptr>::value_type value_type;
return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type));
}
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> >
struct __quoted_output_proxy
{
_Iter __first;
_Iter __last;
_CharT __delim;
_CharT __escape;
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
: __first(__f), __last(__l), __delim(__d), __escape(__e) {}
// This would be a nice place for a string_ref
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___STRING

View File

@@ -17,189 +17,580 @@
#pragma GCC system_header #pragma GCC system_header
#endif #endif
#ifndef _LIBCPP_HAS_NO_THREADS #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# include <__external_threading>
#elif !defined(_LIBCPP_HAS_NO_THREADS)
#if defined(_LIBCPP_THREAD_API_PTHREAD) #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h> # include <pthread.h>
# include <sched.h> # include <sched.h>
#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
#include <assert.h>
#include <Windows.h>
#include <process.h>
#include <fibersapi.h>
#include <chrono>
#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 #endif
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_LIBCPP_THREAD_API_PTHREAD) #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 // Mutex
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER _LIBCPP_THREAD_ABI_VISIBILITY
typedef pthread_mutex_t __libcpp_mutex_t; int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m);
inline _LIBCPP_ALWAYS_INLINE _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m) 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();
// 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; pthread_mutexattr_t attr;
int __ec = pthread_mutexattr_init(&attr); int __ec = pthread_mutexattr_init(&attr);
if (__ec) return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec) if (__ec)
{ return __ec;
__ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if (__ec) {
pthread_mutexattr_destroy(&attr); pthread_mutexattr_destroy(&attr);
return __ec; return __ec;
} }
__ec = pthread_mutex_init(__m, &attr); __ec = pthread_mutex_init(__m, &attr);
if (__ec) if (__ec) {
{
pthread_mutexattr_destroy(&attr); pthread_mutexattr_destroy(&attr);
return __ec; return __ec;
} }
__ec = pthread_mutexattr_destroy(&attr); __ec = pthread_mutexattr_destroy(&attr);
if (__ec) if (__ec) {
{
pthread_mutex_destroy(__m); pthread_mutex_destroy(__m);
return __ec; return __ec;
} }
return 0; return 0;
} }
inline _LIBCPP_ALWAYS_INLINE 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) int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
{ {
return pthread_mutex_lock(__m); return pthread_mutex_lock(__m);
} }
inline _LIBCPP_ALWAYS_INLINE bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
int __libcpp_mutex_trylock(__libcpp_mutex_t* __m)
{ {
return pthread_mutex_trylock(__m); return pthread_mutex_trylock(__m) == 0;
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m) int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
{ {
return pthread_mutex_unlock(__m); return pthread_mutex_unlock(__m);
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m) int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
{ {
return pthread_mutex_destroy(__m); return pthread_mutex_destroy(__m);
} }
// Condition variable // Condition Variable
#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
typedef pthread_cond_t __libcpp_condvar_t;
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv) int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
{ {
return pthread_cond_signal(__cv); return pthread_cond_signal(__cv);
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv) int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
{ {
return pthread_cond_broadcast(__cv); return pthread_cond_broadcast(__cv);
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m) int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
{ {
return pthread_cond_wait(__cv, __m); return pthread_cond_wait(__cv, __m);
} }
inline _LIBCPP_ALWAYS_INLINE int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) timespec *__ts)
{ {
return pthread_cond_timedwait(__cv, __m, __ts); return pthread_cond_timedwait(__cv, __m, __ts);
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
{ {
return pthread_cond_destroy(__cv); return pthread_cond_destroy(__cv);
} }
// Thread id // Execute once
typedef pthread_t __libcpp_thread_id; 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 // Returns non-zero if the thread ids are equal, otherwise 0
inline _LIBCPP_ALWAYS_INLINE
bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
{ {
return pthread_equal(t1, t2) != 0; return pthread_equal(t1, t2) != 0;
} }
// Returns non-zero if t1 < t2, otherwise 0 // Returns non-zero if t1 < t2, otherwise 0
inline _LIBCPP_ALWAYS_INLINE
bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2)
{ {
return t1 < t2; return t1 < t2;
} }
// Thread // Thread
typedef pthread_t __libcpp_thread_t; bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
return *__t == 0;
}
inline _LIBCPP_ALWAYS_INLINE int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) void *__arg)
{ {
return pthread_create(__t, 0, __func, __arg); return pthread_create(__t, 0, __func, __arg);
} }
inline _LIBCPP_ALWAYS_INLINE
__libcpp_thread_id __libcpp_thread_get_current_id() __libcpp_thread_id __libcpp_thread_get_current_id()
{ {
return pthread_self(); return pthread_self();
} }
inline _LIBCPP_ALWAYS_INLINE
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t) __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
{ {
return *__t; return *__t;
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_thread_join(__libcpp_thread_t *__t) int __libcpp_thread_join(__libcpp_thread_t *__t)
{ {
return pthread_join(*__t, 0); return pthread_join(*__t, 0);
} }
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_thread_detach(__libcpp_thread_t *__t) int __libcpp_thread_detach(__libcpp_thread_t *__t)
{ {
return pthread_detach(*__t); return pthread_detach(*__t);
} }
inline _LIBCPP_ALWAYS_INLINE
void __libcpp_thread_yield() void __libcpp_thread_yield()
{ {
sched_yield(); sched_yield();
} }
// Thread local storage // Thread local storage
typedef pthread_key_t __libcpp_tl_key; int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
inline _LIBCPP_ALWAYS_INLINE
int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit)(void*))
{ {
return pthread_key_create(__key, __at_exit); return pthread_key_create(__key, __at_exit);
} }
inline _LIBCPP_ALWAYS_INLINE void *__libcpp_tls_get(__libcpp_tls_key __key)
void* __libcpp_tl_get(__libcpp_tl_key __key)
{ {
return pthread_getspecific(__key); return pthread_getspecific(__key);
} }
inline _LIBCPP_ALWAYS_INLINE int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
void __libcpp_tl_set(__libcpp_tl_key __key, void* __p)
{ {
pthread_setspecific(__key, __p); return pthread_setspecific(__key, __p);
} }
#else // !_LIBCPP_THREAD_API_PTHREAD #elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
#error "No thread API selected."
#endif // 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<void>(__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<system_clock::duration>(duration));
auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
if (!SleepConditionVariableSRW(__cv, __m,
timeout_ms.count() > 0 ? timeout_ms.count()
: 0,
0))
return GetLastError();
return 0;
}
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
{
static_cast<void>(__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<void>(__init_once);
static_cast<void>(__context);
void (*init_routine)(void) = reinterpret_cast<void (*)(void)>(__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<void *>(__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<unsigned>(reinterpret_cast<uintptr_t>(__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<HANDLE>(_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();
}
// 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 _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_HAS_NO_THREADS #endif // !_LIBCPP_HAS_NO_THREADS
#endif // _LIBCPP_THREADING_SUPPORT #endif // _LIBCPP_THREADING_SUPPORT

File diff suppressed because it is too large Load Diff

View File

@@ -22,38 +22,56 @@
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size; template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size;
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Tp, class...>
using __enable_if_tuple_size_imp = _Tp;
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
: public tuple_size<_Tp> {}; const _Tp,
typename enable_if<!is_volatile<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<volatile _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
: public tuple_size<_Tp> {}; volatile _Tp,
typename enable_if<!is_const<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const volatile _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
: public tuple_size<_Tp> {}; const volatile _Tp,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element; #else
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
#endif
template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
template <size_t _Ip, class _Tp> template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
{ {
public: public:
typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
}; };
template <size_t _Ip, class _Tp> template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, volatile _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
{ {
public: public:
typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
}; };
template <size_t _Ip, class _Tp> template <size_t _Ip, class _Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const volatile _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
{ {
public: public:
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
@@ -68,10 +86,90 @@ template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_li
// tuple specializations // tuple specializations
#if !defined(_LIBCPP_HAS_NO_VARIADICS) #if !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
template <size_t...> struct __tuple_indices {};
template <class _IdxType, _IdxType... _Values>
struct __integer_sequence {
template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType>
using __convert = _ToIndexSeq<_ToIndexType, _Values...>;
template <size_t _Sp>
using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
};
#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
namespace __detail {
template<typename _Tp, size_t ..._Extra> struct __repeat;
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
typedef __integer_sequence<_Tp,
_Np...,
sizeof...(_Np) + _Np...,
2 * sizeof...(_Np) + _Np...,
3 * sizeof...(_Np) + _Np...,
4 * sizeof...(_Np) + _Np...,
5 * sizeof...(_Np) + _Np...,
6 * sizeof...(_Np) + _Np...,
7 * sizeof...(_Np) + _Np...,
_Extra...> type;
};
template<size_t _Np> struct __parity;
template<size_t _Np> struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
} // namespace detail
#endif // !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
#if __has_builtin(__make_integer_seq)
template <size_t _Ep, size_t _Sp>
using __make_indices_imp =
typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template
__to_tuple_indices<_Sp>;
#else
template <size_t _Ep, size_t _Sp>
using __make_indices_imp =
typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
#endif
template <size_t _Ep, size_t _Sp = 0>
struct __make_tuple_indices
{
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
typedef __make_indices_imp<_Ep, _Sp> type;
};
template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {}; template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
template <class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <size_t _Ip, class ..._Tp> template <size_t _Ip, class ..._Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type& typename tuple_element<_Ip, tuple<_Tp...> >::type&
@@ -121,7 +219,7 @@ get(const pair<_T1, _T2>&&) _NOEXCEPT;
// array specializations // array specializations
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array; template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {}; template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
@@ -149,66 +247,97 @@ get(const array<_Tp, _Size>&&) _NOEXCEPT;
#if !defined(_LIBCPP_HAS_NO_VARIADICS) #if !defined(_LIBCPP_HAS_NO_VARIADICS)
// __make_tuple_indices
template <size_t...> struct __tuple_indices {};
template <size_t _Sp, class _IntTuple, size_t _Ep>
struct __make_indices_imp;
template <size_t _Sp, size_t ..._Indices, size_t _Ep>
struct __make_indices_imp<_Sp, __tuple_indices<_Indices...>, _Ep>
{
typedef typename __make_indices_imp<_Sp+1, __tuple_indices<_Indices..., _Sp>, _Ep>::type type;
};
template <size_t _Ep, size_t ..._Indices>
struct __make_indices_imp<_Ep, __tuple_indices<_Indices...>, _Ep>
{
typedef __tuple_indices<_Indices...> type;
};
template <size_t _Ep, size_t _Sp = 0>
struct __make_tuple_indices
{
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
typedef typename __make_indices_imp<_Sp, __tuple_indices<>, _Ep>::type type;
};
// __tuple_types // __tuple_types
template <class ..._Tp> struct __tuple_types {}; template <class ..._Tp> struct __tuple_types {};
template <size_t _Ip> #if !__has_builtin(__type_pack_element)
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<> >
namespace __indexer_detail {
template <size_t _Idx, class _Tp>
struct __indexed { using type = _Tp; };
template <class _Types, class _Indexes> struct __indexer;
template <class ..._Types, size_t ..._Idx>
struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>>
: __indexed<_Idx, _Types>...
{};
template <size_t _Idx, class _Tp>
__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
} // namespace __indexer_detail
template <size_t _Idx, class ..._Types>
using __type_pack_element = typename decltype(
__indexer_detail::__at_index<_Idx>(
__indexer_detail::__indexer<
__tuple_types<_Types...>,
typename __make_tuple_indices<sizeof...(_Types)>::type
>{})
)::type;
#endif
template <size_t _Ip, class ..._Types>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
{ {
public: public:
static_assert(_Ip == 0, "tuple_element index out of range"); static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
static_assert(_Ip != 0, "tuple_element index out of range"); typedef __type_pack_element<_Ip, _Types...> type;
}; };
template <class _Hp, class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, __tuple_types<_Hp, _Tp...> >
{
public:
typedef _Hp type;
};
template <size_t _Ip, class _Hp, class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Hp, _Tp...> >
{
public:
typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...> >::type type;
};
template <class ..._Tp> template <class ..._Tp>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> > class _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)> : public integral_constant<size_t, sizeof...(_Tp)>
{ {
}; };
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {}; template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type {};
template <bool _ApplyLV, bool _ApplyConst, bool _ApplyVolatile>
struct __apply_cv_mf;
template <>
struct __apply_cv_mf<false, false, false> {
template <class _Tp> using __apply = _Tp;
};
template <>
struct __apply_cv_mf<false, true, false> {
template <class _Tp> using __apply = const _Tp;
};
template <>
struct __apply_cv_mf<false, false, true> {
template <class _Tp> using __apply = volatile _Tp;
};
template <>
struct __apply_cv_mf<false, true, true> {
template <class _Tp> using __apply = const volatile _Tp;
};
template <>
struct __apply_cv_mf<true, false, false> {
template <class _Tp> using __apply = _Tp&;
};
template <>
struct __apply_cv_mf<true, true, false> {
template <class _Tp> using __apply = const _Tp&;
};
template <>
struct __apply_cv_mf<true, false, true> {
template <class _Tp> using __apply = volatile _Tp&;
};
template <>
struct __apply_cv_mf<true, true, true> {
template <class _Tp> using __apply = const volatile _Tp&;
};
template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
using __apply_cv_t = __apply_cv_mf<
is_lvalue_reference<_Tp>::value,
is_const<_RawTp>::value,
is_volatile<_RawTp>::value>;
// __make_tuple_types // __make_tuple_types
// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a // __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
@@ -216,59 +345,73 @@ template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...> > : true_type
// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a // _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
// lvalue_reference type, then __tuple_types<_Types&...> is the result. // lvalue_reference type, then __tuple_types<_Types&...> is the result.
template <class _TupleTypes, class _Tp, size_t _Sp, size_t _Ep> template <class _TupleTypes, class _TupleIndices>
struct __make_tuple_types_imp; struct __make_tuple_types_flat;
template <class ..._Types, class _Tp, size_t _Sp, size_t _Ep> template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Sp, _Ep> struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
{ // Specialization for pair, tuple, and __tuple_types
typedef typename remove_reference<_Tp>::type _Tpr; template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
typedef typename __make_tuple_types_imp<__tuple_types<_Types..., using __apply_quals = __tuple_types<
typename conditional<is_lvalue_reference<_Tp>::value, typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
typename tuple_element<_Sp, _Tpr>::type&, >;
typename tuple_element<_Sp, _Tpr>::type>::type>,
_Tp, _Sp+1, _Ep>::type type;
}; };
template <class ..._Types, class _Tp, size_t _Ep> template <class _Vt, size_t _Np, size_t ..._Idx>
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Ep, _Ep> struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
{ template <size_t>
typedef __tuple_types<_Types...> type; using __value_type = _Vt;
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
using __apply_quals = __tuple_types<
typename _ApplyFn::template __apply<__value_type<_Idx>>...
>;
}; };
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, size_t _Sp = 0> template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value,
size_t _Sp = 0,
bool _SameSize = (_Ep == tuple_size<typename remove_reference<_Tp>::type>::value)>
struct __make_tuple_types struct __make_tuple_types
{ {
static_assert(_Sp <= _Ep, "__make_tuple_types input error"); static_assert(_Sp <= _Ep, "__make_tuple_types input error");
typedef typename __make_tuple_types_imp<__tuple_types<>, _Tp, _Sp, _Ep>::type type; using _RawTp = typename remove_cv<typename remove_reference<_Tp>::type>::type;
using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
using type = typename _Maker::template __apply_quals<_Tp>;
};
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
typedef __tuple_types<_Types...> type;
};
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
typedef __tuple_types<_Types...> type;
};
template <bool ..._Preds>
struct __all_dummy;
template <bool ..._Pred>
using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
class ..._LArgs, class ..._RArgs>
static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
template <template <class...> class>
static auto __do_test(...) -> false_type;
template <class _FromArgs, class _ToArgs>
using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
template <class _FromArgs, class _ToArgs>
using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
template <class _FromArgs, class _ToArgs>
using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
}; };
// __tuple_convertible // __tuple_convertible
template <class, class>
struct __tuple_convertible_imp : public false_type {};
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
struct __tuple_convertible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
: public integral_constant<bool,
is_convertible<_Tp0, _Up0>::value &&
__tuple_convertible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
template <>
struct __tuple_convertible_imp<__tuple_types<>, __tuple_types<> >
: public true_type {};
template <bool, class, class>
struct __tuple_convertible_apply : public false_type {};
template <class _Tp, class _Up>
struct __tuple_convertible_apply<true, _Tp, _Up>
: public __tuple_convertible_imp<
typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up>::type
>
{};
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value> bool = __tuple_like<_Up>::value>
struct __tuple_convertible struct __tuple_convertible
@@ -276,36 +419,14 @@ struct __tuple_convertible
template <class _Tp, class _Up> template <class _Tp, class _Up>
struct __tuple_convertible<_Tp, _Up, true, true> struct __tuple_convertible<_Tp, _Up, true, true>
: public __tuple_convertible_apply<tuple_size<typename remove_reference<_Tp>::type>::value == : public __tuple_sfinae_base::__convertible<
tuple_size<_Up>::value, _Tp, _Up>
{};
// __tuple_constructible
template <class, class>
struct __tuple_constructible_imp : public false_type {};
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
struct __tuple_constructible_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
: public integral_constant<bool,
is_constructible<_Up0, _Tp0>::value &&
__tuple_constructible_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
template <>
struct __tuple_constructible_imp<__tuple_types<>, __tuple_types<> >
: public true_type {};
template <bool _SameSize, class, class>
struct __tuple_constructible_apply : public false_type {};
template <class _Tp, class _Up>
struct __tuple_constructible_apply<true, _Tp, _Up>
: public __tuple_constructible_imp<
typename __make_tuple_types<_Tp>::type typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up>::type , typename __make_tuple_types<_Up>::type
> >
{}; {};
// __tuple_constructible
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value> bool = __tuple_like<_Up>::value>
struct __tuple_constructible struct __tuple_constructible
@@ -313,36 +434,14 @@ struct __tuple_constructible
template <class _Tp, class _Up> template <class _Tp, class _Up>
struct __tuple_constructible<_Tp, _Up, true, true> struct __tuple_constructible<_Tp, _Up, true, true>
: public __tuple_constructible_apply<tuple_size<typename remove_reference<_Tp>::type>::value == : public __tuple_sfinae_base::__constructible<
tuple_size<_Up>::value, _Tp, _Up>
{};
// __tuple_assignable
template <class, class>
struct __tuple_assignable_imp : public false_type {};
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
struct __tuple_assignable_imp<__tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> >
: public integral_constant<bool,
is_assignable<_Up0&, _Tp0>::value &&
__tuple_assignable_imp<__tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {};
template <>
struct __tuple_assignable_imp<__tuple_types<>, __tuple_types<> >
: public true_type {};
template <bool, class, class>
struct __tuple_assignable_apply : public false_type {};
template <class _Tp, class _Up>
struct __tuple_assignable_apply<true, _Tp, _Up>
: __tuple_assignable_imp<
typename __make_tuple_types<_Tp>::type typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up>::type , typename __make_tuple_types<_Up>::type
> >
{}; {};
// __tuple_assignable
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value> bool = __tuple_like<_Up>::value>
struct __tuple_assignable struct __tuple_assignable
@@ -350,12 +449,111 @@ struct __tuple_assignable
template <class _Tp, class _Up> template <class _Tp, class _Up>
struct __tuple_assignable<_Tp, _Up, true, true> struct __tuple_assignable<_Tp, _Up, true, true>
: public __tuple_assignable_apply<tuple_size<typename remove_reference<_Tp>::type>::value == : public __tuple_sfinae_base::__assignable<
tuple_size<_Up>::value, _Tp, _Up> typename __make_tuple_types<_Tp>::type
, typename __make_tuple_types<_Up&>::type
>
{}; {};
template <size_t _Ip, class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
{
public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
#if _LIBCPP_STD_VER > 11
template <size_t _Ip, class ..._Tp>
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
#endif
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_CXX03_LANG
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp : false_type {};
template <class _SizeTrait, size_t _Expected>
struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
: integral_constant<bool, _SizeTrait::value == _Expected> {};
template <class _Tuple, size_t _ExpectedSize,
class _RawTuple = typename __uncvref<_Tuple>::type>
using __tuple_like_with_size = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
>;
struct _LIBCPP_TYPE_VIS __check_tuple_constructor_fail {
template <class ...>
static constexpr bool __enable_default() { return false; }
template <class ...>
static constexpr bool __enable_explicit() { return false; }
template <class ...>
static constexpr bool __enable_implicit() { return false; }
template <class ...>
static constexpr bool __enable_assign() { return false; }
};
#endif
#if _LIBCPP_STD_VER > 14
template <bool _CanCopy, bool _CanMove>
struct __sfinae_ctor_base {};
template <>
struct __sfinae_ctor_base<false, false> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <>
struct __sfinae_ctor_base<true, false> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base(__sfinae_ctor_base &&) = delete;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <>
struct __sfinae_ctor_base<false, true> {
__sfinae_ctor_base() = default;
__sfinae_ctor_base(__sfinae_ctor_base const&) = delete;
__sfinae_ctor_base(__sfinae_ctor_base &&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base const&) = default;
__sfinae_ctor_base& operator=(__sfinae_ctor_base&&) = default;
};
template <bool _CanCopy, bool _CanMove>
struct __sfinae_assign_base {};
template <>
struct __sfinae_assign_base<false, false> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
};
template <>
struct __sfinae_assign_base<true, false> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = delete;
};
template <>
struct __sfinae_assign_base<false, true> {
__sfinae_assign_base() = default;
__sfinae_assign_base(__sfinae_assign_base const&) = default;
__sfinae_assign_base(__sfinae_assign_base &&) = default;
__sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
__sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
};
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TUPLE #endif // _LIBCPP___TUPLE

View File

@@ -9,21 +9,25 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifdef min #ifdef min
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_MSC_VER) && ! defined(__clang__) #if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " _LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing min") "before any Windows header. #undefing min")
#else #else
#warning: macro min is incompatible with C++. #undefing min #warning: macro min is incompatible with C++. #undefing min
#endif #endif
#endif
#undef min #undef min
#endif #endif
#ifdef max #ifdef max
#if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS)
#if defined(_MSC_VER) && ! defined(__clang__) #if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " _LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX "
"before any Windows header. #undefing max") "before any Windows header. #undefing max")
#else #else
#warning: macro max is incompatible with C++. #undefing max #warning: macro max is incompatible with C++. #undefing max
#endif #endif
#endif
#undef max #undef max
#endif #endif

View File

@@ -288,6 +288,12 @@ template <class RandomAccessIterator, class RandomNumberGenerator>
random_shuffle(RandomAccessIterator first, RandomAccessIterator last, random_shuffle(RandomAccessIterator first, RandomAccessIterator last,
RandomNumberGenerator& rand); // deprecated in C++14 RandomNumberGenerator& rand); // deprecated in C++14
template<class PopulationIterator, class SampleIterator,
class Distance, class UniformRandomBitGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomBitGenerator&& g); // C++17
template<class RandomAccessIterator, class UniformRandomNumberGenerator> template<class RandomAccessIterator, class UniformRandomNumberGenerator>
void shuffle(RandomAccessIterator first, RandomAccessIterator last, void shuffle(RandomAccessIterator first, RandomAccessIterator last,
UniformRandomNumberGenerator&& g); UniformRandomNumberGenerator&& g);
@@ -749,14 +755,28 @@ struct __debug_less
{ {
_Compare __comp_; _Compare __comp_;
__debug_less(_Compare& __c) : __comp_(__c) {} __debug_less(_Compare& __c) : __comp_(__c) {}
template <class _Tp, class _Up> template <class _Tp, class _Up>
bool operator()(const _Tp& __x, const _Up& __y) bool operator()(const _Tp& __x, const _Up& __y)
{ {
bool __r = __comp_(__x, __y); bool __r = __comp_(__x, __y);
if (__r) if (__r)
_LIBCPP_ASSERT(!__comp_(__y, __x), "Comparator does not induce a strict weak ordering"); __do_compare_assert(0, __y, __x);
return __r; return __r;
} }
template <class _LHS, class _RHS>
inline _LIBCPP_INLINE_VISIBILITY
decltype((void)_VSTD::declval<_Compare&>()(
_VSTD::declval<_LHS const&>(), _VSTD::declval<_RHS const&>()))
__do_compare_assert(int, _LHS const& __l, _RHS const& __r) {
_LIBCPP_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
}
template <class _LHS, class _RHS>
inline _LIBCPP_INLINE_VISIBILITY
void __do_compare_assert(long, _LHS const&, _RHS const&) {}
}; };
#endif // _LIBCPP_DEBUG #endif // _LIBCPP_DEBUG
@@ -857,7 +877,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
{ {
for (; __first != __last; ++__first) for (; __first != __last; ++__first)
__f(*__first); __f(*__first);
return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03 return __f;
} }
// find // find
@@ -1474,9 +1494,9 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
if (__len1 < __len2) if (__len1 < __len2)
return make_pair(__last1, __last1); return make_pair(__last1, __last1);
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
while (true) while (true)
{ {
#if !_LIBCPP_UNROLL_LOOPS
while (true) while (true)
{ {
if (__first1 == __s) if (__first1 == __s)
@@ -1485,40 +1505,9 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
break; break;
++__first1; ++__first1;
} }
#else // !_LIBCPP_UNROLL_LOOPS
for (_D1 __loop_unroll = (__s - __first1) / 4; __loop_unroll > 0; --__loop_unroll)
{
if (__pred(*__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
if (__pred(*++__first1, *__first2))
goto __phase2;
++__first1;
}
switch (__s - __first1)
{
case 3:
if (__pred(*__first1, *__first2))
break;
++__first1;
case 2:
if (__pred(*__first1, *__first2))
break;
++__first1;
case 1:
if (__pred(*__first1, *__first2))
break;
case 0:
return make_pair(__last1, __last1);
}
__phase2:
#endif // !_LIBCPP_UNROLL_LOOPS
_RandomAccessIterator1 __m1 = __first1; _RandomAccessIterator1 __m1 = __first1;
_RandomAccessIterator2 __m2 = __first2; _RandomAccessIterator2 __m2 = __first2;
#if !_LIBCPP_UNROLL_LOOPS
while (true) while (true)
{ {
if (++__m2 == __last2) if (++__m2 == __last2)
@@ -1530,43 +1519,6 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
break; break;
} }
} }
#else // !_LIBCPP_UNROLL_LOOPS
++__m2;
++__m1;
for (_D2 __loop_unroll = (__last2 - __m2) / 4; __loop_unroll > 0; --__loop_unroll)
{
if (!__pred(*__m1, *__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
if (!__pred(*++__m1, *++__m2))
goto __continue;
++__m1;
++__m2;
}
switch (__last2 - __m2)
{
case 3:
if (!__pred(*__m1, *__m2))
break;
++__m1;
++__m2;
case 2:
if (!__pred(*__m1, *__m2))
break;
++__m1;
++__m2;
case 1:
if (!__pred(*__m1, *__m2))
break;
case 0:
return make_pair(__first1, __first1 + __len2);
}
__continue:
++__first1;
#endif // !_LIBCPP_UNROLL_LOOPS
} }
} }
@@ -1729,6 +1681,20 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
return __i.base(); return __i.base();
} }
#else
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_trivially_copy_assignable<_Tp>::value,
__wrap_iter<_Tp*>
>::type
__unwrap_iter(__wrap_iter<_Tp*> __i)
{
return __i;
}
#endif // _LIBCPP_DEBUG_LEVEL < 2 #endif // _LIBCPP_DEBUG_LEVEL < 2
template <class _InputIterator, class _OutputIterator> template <class _InputIterator, class _OutputIterator>
@@ -1802,7 +1768,9 @@ _BidirectionalIterator2
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
_BidirectionalIterator2 __result) _BidirectionalIterator2 __result)
{ {
return _VSTD::__copy_backward(__unwrap_iter(__first), __unwrap_iter(__last), __unwrap_iter(__result)); return _VSTD::__copy_backward(__unwrap_iter(__first),
__unwrap_iter(__last),
__unwrap_iter(__result));
} }
// copy_if // copy_if
@@ -2417,7 +2385,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
template<typename _Integral> template<typename _Integral>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
_Integral _Integral
__gcd(_Integral __x, _Integral __y) __algo_gcd(_Integral __x, _Integral __y)
{ {
do do
{ {
@@ -2442,7 +2410,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
_VSTD::swap_ranges(__first, __middle, __middle); _VSTD::swap_ranges(__first, __middle, __middle);
return __middle; return __middle;
} }
const difference_type __g = _VSTD::__gcd(__m1, __m2); const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;) for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{ {
value_type __t(_VSTD::move(*--__p)); value_type __t(_VSTD::move(*--__p));
@@ -3128,6 +3096,78 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
} }
} }
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output,
_Distance __n,
_UniformRandomNumberGenerator & __g,
input_iterator_tag) {
_Distance __k = 0;
for (; __first != __last && __k < __n; ++__first, (void)++__k)
__output[__k] = *__first;
_Distance __sz = __k;
for (; __first != __last; ++__first, (void)++__k) {
_Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
if (__r < __sz)
__output[__r] = *__first;
}
return __output + _VSTD::min(__n, __k);
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output,
_Distance __n,
_UniformRandomNumberGenerator& __g,
forward_iterator_tag) {
_Distance __unsampled_sz = _VSTD::distance(__first, __last);
for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
_Distance __r =
_VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
if (__r < __n) {
*__output++ = *__first;
--__n;
}
}
return __output;
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output,
_Distance __n, _UniformRandomNumberGenerator& __g) {
typedef typename iterator_traits<_PopulationIterator>::iterator_category
_PopCategory;
typedef typename iterator_traits<_PopulationIterator>::difference_type
_Difference;
static_assert(__is_forward_iterator<_PopulationIterator>::value ||
__is_random_access_iterator<_SampleIterator>::value,
"SampleIterator must meet the requirements of RandomAccessIterator");
typedef typename common_type<_Distance, _Difference>::type _CommonType;
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
return _VSTD::__sample(
__first, __last, __output, _CommonType(__n),
__g, _PopCategory());
}
#if _LIBCPP_STD_VER > 14
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
inline _LIBCPP_INLINE_VISIBILITY
_SampleIterator sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output,
_Distance __n, _UniformRandomNumberGenerator&& __g) {
return _VSTD::__sample(__first, __last, __output, __n, __g);
}
#endif // _LIBCPP_STD_VER > 14
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -4871,7 +4911,8 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
template <class _Compare, class _RandomAccessIterator> template <class _Compare, class _RandomAccessIterator>
void void
__sift_down(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
_Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len, typename iterator_traits<_RandomAccessIterator>::difference_type __len,
_RandomAccessIterator __start) _RandomAccessIterator __start)
{ {

663
include/any Normal file
View File

@@ -0,0 +1,663 @@
// -*- C++ -*-
//===------------------------------ any -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_ANY
#define _LIBCPP_ANY
/*
any synopsis
namespace std {
class bad_any_cast : public bad_cast
{
public:
virtual const char* what() const noexcept;
};
class any
{
public:
// 6.3.1 any construct/destruct
any() noexcept;
any(const any& other);
any(any&& other) noexcept;
template <class ValueType>
any(ValueType&& value);
~any();
// 6.3.2 any assignments
any& operator=(const any& rhs);
any& operator=(any&& rhs) noexcept;
template <class ValueType>
any& operator=(ValueType&& rhs);
// 6.3.3 any modifiers
void reset() noexcept;
void swap(any& rhs) noexcept;
// 6.3.4 any observers
bool has_value() const noexcept;
const type_info& type() const noexcept;
};
// 6.4 Non-member functions
void swap(any& x, any& y) noexcept;
template <class T, class ...Args>
any make_any(Args&& ...args);
template <class T, class U, class ...Args>
any make_any(initializer_list<U>, Args&& ...args);
template<class ValueType>
ValueType any_cast(const any& operand);
template<class ValueType>
ValueType any_cast(any& operand);
template<class ValueType>
ValueType any_cast(any&& operand);
template<class ValueType>
const ValueType* any_cast(const any* operand) noexcept;
template<class ValueType>
ValueType* any_cast(any* operand) noexcept;
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <memory>
#include <new>
#include <typeinfo>
#include <type_traits>
#include <cstdlib>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
namespace std {
class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
{
public:
virtual const char* what() const _NOEXCEPT;
};
} // namespace std
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_any_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_any_cast();
#else
_VSTD::abort();
#endif
}
// Forward declarations
class _LIBCPP_TEMPLATE_VIS any;
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
add_pointer_t<add_const_t<_ValueType>>
any_cast(any const *) _NOEXCEPT;
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
namespace __any_imp
{
using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
template <class _Tp>
using _IsSmallObject = integral_constant<bool
, sizeof(_Tp) <= sizeof(_Buffer)
&& alignment_of<_Buffer>::value
% alignment_of<_Tp>::value == 0
&& is_nothrow_move_constructible<_Tp>::value
>;
enum class _Action {
_Destroy,
_Copy,
_Move,
_Get,
_TypeInfo
};
template <class _Tp> struct _SmallHandler;
template <class _Tp> struct _LargeHandler;
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; };
template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
constexpr const void* __get_fallback_typeid() {
return &__unique_typeinfo<decay_t<_Tp>>::__id;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool __compare_typeid(type_info const* __id, const void* __fallback_id)
{
#if !defined(_LIBCPP_NO_RTTI)
if (__id && *__id == typeid(_Tp))
return true;
#endif
if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
return true;
return false;
}
template <class _Tp>
using _Handler = conditional_t<
_IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
} // namespace __any_imp
class _LIBCPP_TEMPLATE_VIS any
{
public:
// construct/destruct
_LIBCPP_INLINE_VISIBILITY
constexpr any() _NOEXCEPT : __h(nullptr) {}
_LIBCPP_INLINE_VISIBILITY
any(any const & __other) : __h(nullptr)
{
if (__other.__h) __other.__call(_Action::_Copy, this);
}
_LIBCPP_INLINE_VISIBILITY
any(any && __other) _NOEXCEPT : __h(nullptr)
{
if (__other.__h) __other.__call(_Action::_Move, this);
}
template <
class _ValueType
, class _Tp = decay_t<_ValueType>
, class = enable_if_t<
!is_same<_Tp, any>::value &&
!__is_inplace_type<_ValueType>::value &&
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
any(_ValueType && __value);
template <class _ValueType, class ..._Args,
class _Tp = decay_t<_ValueType>,
class = enable_if_t<
is_constructible<_Tp, _Args...>::value &&
is_copy_constructible<_Tp>::value
>
>
_LIBCPP_INLINE_VISIBILITY
explicit any(in_place_type_t<_ValueType>, _Args&&... __args);
template <class _ValueType, class _Up, class ..._Args,
class _Tp = decay_t<_ValueType>,
class = enable_if_t<
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
_LIBCPP_INLINE_VISIBILITY
~any() { this->reset(); }
// assignments
_LIBCPP_INLINE_VISIBILITY
any & operator=(any const & __rhs) {
any(__rhs).swap(*this);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
any & operator=(any && __rhs) _NOEXCEPT {
any(_VSTD::move(__rhs)).swap(*this);
return *this;
}
template <
class _ValueType
, class _Tp = decay_t<_ValueType>
, class = enable_if_t<
!is_same<_Tp, any>::value
&& is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
any & operator=(_ValueType && __rhs);
template <class _ValueType, class ..._Args,
class _Tp = decay_t<_ValueType>,
class = enable_if_t<
is_constructible<_Tp, _Args...>::value &&
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
void emplace(_Args&&... args);
template <class _ValueType, class _Up, class ..._Args,
class _Tp = decay_t<_ValueType>,
class = enable_if_t<
is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
is_copy_constructible<_Tp>::value>
>
_LIBCPP_INLINE_VISIBILITY
void emplace(initializer_list<_Up>, _Args&&...);
// 6.3.3 any modifiers
_LIBCPP_INLINE_VISIBILITY
void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
_LIBCPP_INLINE_VISIBILITY
void swap(any & __rhs) _NOEXCEPT;
// 6.3.4 any observers
_LIBCPP_INLINE_VISIBILITY
bool has_value() const _NOEXCEPT { return __h != nullptr; }
#if !defined(_LIBCPP_NO_RTTI)
_LIBCPP_INLINE_VISIBILITY
const type_info & type() const _NOEXCEPT {
if (__h) {
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
} else {
return typeid(void);
}
}
#endif
private:
typedef __any_imp::_Action _Action;
using _HandleFuncPtr = void* (*)(_Action, any const *, any *, const type_info *,
const void* __fallback_info);
union _Storage {
constexpr _Storage() : __ptr(nullptr) {}
void * __ptr;
__any_imp::_Buffer __buf;
};
_LIBCPP_ALWAYS_INLINE
void * __call(_Action __a, any * __other = nullptr,
type_info const * __info = nullptr,
const void* __fallback_info = nullptr) const
{
return __h(__a, this, __other, __info, __fallback_info);
}
_LIBCPP_ALWAYS_INLINE
void * __call(_Action __a, any * __other = nullptr,
type_info const * __info = nullptr,
const void* __fallback_info = nullptr)
{
return __h(__a, this, __other, __info, __fallback_info);
}
template <class>
friend struct __any_imp::_SmallHandler;
template <class>
friend struct __any_imp::_LargeHandler;
template <class _ValueType>
friend add_pointer_t<add_const_t<_ValueType>>
any_cast(any const *) _NOEXCEPT;
template <class _ValueType>
friend add_pointer_t<_ValueType>
any_cast(any *) _NOEXCEPT;
_HandleFuncPtr __h = nullptr;
_Storage __s;
};
namespace __any_imp
{
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS _SmallHandler
{
_LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this, any * __other,
type_info const * __info, const void* __fallback_info)
{
switch (__act)
{
case _Action::_Destroy:
__destroy(const_cast<any &>(*__this));
return nullptr;
case _Action::_Copy:
__copy(*__this, *__other);
return nullptr;
case _Action::_Move:
__move(const_cast<any &>(*__this), *__other);
return nullptr;
case _Action::_Get:
return __get(const_cast<any &>(*__this), __info, __fallback_info);
case _Action::_TypeInfo:
return __type_info();
}
}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
static void __create(any & __dest, _Args&&... __args) {
::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Args>(__args)...);
__dest.__h = &_SmallHandler::__handle;
}
private:
_LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this) {
_Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
__value.~_Tp();
__this.__h = nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void __copy(any const & __this, any & __dest) {
_SmallHandler::__create(__dest, *static_cast<_Tp const *>(
static_cast<void const *>(&__this.__s.__buf)));
}
_LIBCPP_INLINE_VISIBILITY
static void __move(any & __this, any & __dest) {
_SmallHandler::__create(__dest, _VSTD::move(
*static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
__destroy(__this);
}
_LIBCPP_INLINE_VISIBILITY
static void* __get(any & __this,
type_info const * __info,
const void* __fallback_id)
{
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
return static_cast<void*>(&__this.__s.__buf);
return nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void* __type_info()
{
#if !defined(_LIBCPP_NO_RTTI)
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
#else
return nullptr;
#endif
}
};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS _LargeHandler
{
_LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this,
any * __other, type_info const * __info,
void const* __fallback_info)
{
switch (__act)
{
case _Action::_Destroy:
__destroy(const_cast<any &>(*__this));
return nullptr;
case _Action::_Copy:
__copy(*__this, *__other);
return nullptr;
case _Action::_Move:
__move(const_cast<any &>(*__this), *__other);
return nullptr;
case _Action::_Get:
return __get(const_cast<any &>(*__this), __info, __fallback_info);
case _Action::_TypeInfo:
return __type_info();
}
}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY
static void __create(any & __dest, _Args&&... __args) {
typedef allocator<_Tp> _Alloc;
typedef __allocator_destructor<_Alloc> _Dp;
_Alloc __a;
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Args>(__args)...);
__dest.__s.__ptr = __hold.release();
__dest.__h = &_LargeHandler::__handle;
}
private:
_LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this){
delete static_cast<_Tp*>(__this.__s.__ptr);
__this.__h = nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void __copy(any const & __this, any & __dest) {
_LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
}
_LIBCPP_INLINE_VISIBILITY
static void __move(any & __this, any & __dest) {
__dest.__s.__ptr = __this.__s.__ptr;
__dest.__h = &_LargeHandler::__handle;
__this.__h = nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void* __get(any & __this, type_info const * __info,
void const* __fallback_info)
{
if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
return static_cast<void*>(__this.__s.__ptr);
return nullptr;
}
_LIBCPP_INLINE_VISIBILITY
static void* __type_info()
{
#if !defined(_LIBCPP_NO_RTTI)
return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
#else
return nullptr;
#endif
}
};
} // namespace __any_imp
template <class _ValueType, class _Tp, class>
any::any(_ValueType && __v) : __h(nullptr)
{
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
}
template <class _ValueType, class ..._Args, class _Tp, class>
any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
};
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
__any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
}
template <class _ValueType, class, class>
inline _LIBCPP_INLINE_VISIBILITY
any & any::operator=(_ValueType && __v)
{
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
return *this;
}
template <class _ValueType, class ..._Args, class _Tp, class>
inline _LIBCPP_INLINE_VISIBILITY
void any::emplace(_Args&&... __args) {
reset();
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
}
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
inline _LIBCPP_INLINE_VISIBILITY
void any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
reset();
__any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
}
inline _LIBCPP_INLINE_VISIBILITY
void any::swap(any & __rhs) _NOEXCEPT
{
if (this == &__rhs)
return;
if (__h && __rhs.__h) {
any __tmp;
__rhs.__call(_Action::_Move, &__tmp);
this->__call(_Action::_Move, &__rhs);
__tmp.__call(_Action::_Move, this);
}
else if (__h) {
this->__call(_Action::_Move, &__rhs);
}
else if (__rhs.__h) {
__rhs.__call(_Action::_Move, this);
}
}
// 6.4 Non-member functions
inline _LIBCPP_INLINE_VISIBILITY
void swap(any & __lhs, any & __rhs) _NOEXCEPT
{
__lhs.swap(__rhs);
}
template <class _Tp, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
any make_any(_Args&&... __args) {
return any(in_place_type<_Tp>, _VSTD::forward<_Args>(__args)...);
}
template <class _Tp, class _Up, class ..._Args>
inline _LIBCPP_INLINE_VISIBILITY
any make_any(initializer_list<_Up> __il, _Args&&... __args) {
return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any const & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
"ValueType is required to be a const lvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return static_cast<_ValueType>(*__tmp);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any & __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType &>::value,
"ValueType is required to be an lvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return static_cast<_ValueType>(*__tmp);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any && __v)
{
using _RawValueType = __uncvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType>::value,
"ValueType is required to be an rvalue reference "
"or a CopyConstructible type");
auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return static_cast<_ValueType>(_VSTD::move(*__tmp));
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
add_pointer_t<add_const_t<_ValueType>>
any_cast(any const * __any) _NOEXCEPT
{
static_assert(!is_reference<_ValueType>::value,
"_ValueType may not be a reference.");
return _VSTD::any_cast<_ValueType>(const_cast<any *>(__any));
}
template <class _RetType>
inline _LIBCPP_INLINE_VISIBILITY
_RetType __pointer_or_func_cast(void* __p, /*IsFunction*/false_type) noexcept {
return static_cast<_RetType>(__p);
}
template <class _RetType>
inline _LIBCPP_INLINE_VISIBILITY
_RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
return nullptr;
}
template <class _ValueType>
add_pointer_t<_ValueType>
any_cast(any * __any) _NOEXCEPT
{
using __any_imp::_Action;
static_assert(!is_reference<_ValueType>::value,
"_ValueType may not be a reference.");
typedef typename add_pointer<_ValueType>::type _ReturnType;
if (__any && __any->__h) {
void *__p = __any->__call(_Action::_Get, nullptr,
#if !defined(_LIBCPP_NO_RTTI)
&typeid(_ValueType),
#else
nullptr,
#endif
__any_imp::__get_fallback_typeid<_ValueType>());
return _VSTD::__pointer_or_func_cast<_ReturnType>(
__p, is_function<_ValueType>{});
}
return nullptr;
}
#endif // _LIBCPP_STD_VER > 14
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_ANY

View File

@@ -108,9 +108,6 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
#include <iterator> #include <iterator>
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -119,7 +116,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
struct _LIBCPP_TYPE_VIS_ONLY array struct _LIBCPP_TEMPLATE_VIS array
{ {
// types: // types:
typedef array __self; typedef array __self;
@@ -152,31 +149,31 @@ struct _LIBCPP_TYPE_VIS_ONLY array
{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);} { _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators: // iterators:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
iterator begin() _NOEXCEPT {return iterator(__elems_);} iterator begin() _NOEXCEPT {return iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);} const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);} iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);} const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator cbegin() const _NOEXCEPT {return begin();} const_iterator cbegin() const _NOEXCEPT {return begin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_iterator cend() const _NOEXCEPT {return end();} const_iterator cend() const _NOEXCEPT {return end();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const_reverse_iterator crend() const _NOEXCEPT {return rend();} const_reverse_iterator crend() const _NOEXCEPT {return rend();}
// capacity: // capacity:
@@ -188,32 +185,33 @@ struct _LIBCPP_TYPE_VIS_ONLY array
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;} _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
// element access: // element access:
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference operator[](size_type __n) const {return __elems_[__n];} reference operator[](size_type __n) {return __elems_[__n];}
reference at(size_type __n); _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const_reference operator[](size_type __n) const {return __elems_[__n];}
_LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n);
_LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
_LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
value_type* data() _NOEXCEPT {return __elems_;} value_type* data() _NOEXCEPT {return __elems_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
const value_type* data() const _NOEXCEPT {return __elems_;} const value_type* data() const _NOEXCEPT {return __elems_;}
}; };
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
_LIBCPP_CONSTEXPR_AFTER_CXX14
typename array<_Tp, _Size>::reference typename array<_Tp, _Size>::reference
array<_Tp, _Size>::at(size_type __n) array<_Tp, _Size>::at(size_type __n)
{ {
if (__n >= _Size) if (__n >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("array::at");
throw out_of_range("array::at");
#else
assert(!"array::at out_of_range");
#endif
return __elems_[__n]; return __elems_[__n];
} }
@@ -223,11 +221,7 @@ typename array<_Tp, _Size>::const_reference
array<_Tp, _Size>::at(size_type __n) const array<_Tp, _Size>::at(size_type __n) const
{ {
if (__n >= _Size) if (__n >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("array::at");
throw out_of_range("array::at");
#else
assert(!"array::at out_of_range");
#endif
return __elems_[__n]; return __elems_[__n];
} }
@@ -294,11 +288,11 @@ swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
} }
template <class _Tp, size_t _Size> template <class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<array<_Tp, _Size> > class _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {}; : public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size> template <size_t _Ip, class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> > class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
{ {
public: public:
typedef _Tp type; typedef _Tp type;

View File

@@ -515,6 +515,15 @@ typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef atomic<int_fast64_t> atomic_int_fast64_t; typedef atomic<int_fast64_t> atomic_int_fast64_t;
typedef atomic<uint_fast64_t> atomic_uint_fast64_t; typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
typedef atomic<int8_t> atomic_int8_t;
typedef atomic<uint8_t> atomic_uint8_t;
typedef atomic<int16_t> atomic_int16_t;
typedef atomic<uint16_t> atomic_uint16_t;
typedef atomic<int32_t> atomic_int32_t;
typedef atomic<uint32_t> atomic_uint32_t;
typedef atomic<int64_t> atomic_int64_t;
typedef atomic<uint64_t> atomic_uint64_t;
typedef atomic<intptr_t> atomic_intptr_t; typedef atomic<intptr_t> atomic_intptr_t;
typedef atomic<uintptr_t> atomic_uintptr_t; typedef atomic<uintptr_t> atomic_uintptr_t;
typedef atomic<size_t> atomic_size_t; typedef atomic<size_t> atomic_size_t;
@@ -548,10 +557,25 @@ void atomic_signal_fence(memory_order m) noexcept;
#endif #endif
#if _LIBCPP_STD_VER > 14 #if _LIBCPP_STD_VER > 14
// FIXME: use the right feature test macro value as chose by SG10.
# define __cpp_lib_atomic_is_always_lock_free 201603L # define __cpp_lib_atomic_is_always_lock_free 201603L
#endif #endif
#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
_LIBCPP_DIAGNOSE_WARNING(__m == memory_order_consume || \
__m == memory_order_acquire || \
__m == memory_order_acq_rel, \
"memory order argument to atomic operation is invalid")
#define _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) \
_LIBCPP_DIAGNOSE_WARNING(__m == memory_order_release || \
__m == memory_order_acq_rel, \
"memory order argument to atomic operation is invalid")
#define _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__m, __f) \
_LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || \
__f == memory_order_acq_rel, \
"memory order argument to atomic operation is invalid")
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
typedef enum memory_order typedef enum memory_order
@@ -571,11 +595,11 @@ struct __gcc_atomic_t {
#endif #endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__gcc_atomic_t() _NOEXCEPT = default; __gcc_atomic_t() _NOEXCEPT = default;
#else #else
__gcc_atomic_t() _NOEXCEPT : __a_value() {} __gcc_atomic_t() _NOEXCEPT : __a_value() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // _LIBCPP_CXX03_LANG
_LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
: __a_value(value) {} : __a_value(value) {}
_Tp __a_value; _Tp __a_value;
@@ -873,15 +897,19 @@ struct __atomic_base // false
{return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{__c11_atomic_store(&__a_, __d, __m);} {__c11_atomic_store(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{__c11_atomic_store(&__a_, __d, __m);} {__c11_atomic_store(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
_Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
{return __c11_atomic_load(&__a_, __m);} {return __c11_atomic_load(&__a_, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
_Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
{return __c11_atomic_load(&__a_, __m);} {return __c11_atomic_load(&__a_, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
operator _Tp() const volatile _NOEXCEPT {return load();} operator _Tp() const volatile _NOEXCEPT {return load();}
@@ -896,18 +924,22 @@ struct __atomic_base // false
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d, bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) volatile _NOEXCEPT memory_order __s, memory_order __f) volatile _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d, bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);} {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d, bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) volatile _NOEXCEPT memory_order __s, memory_order __f) volatile _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d, bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);} {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d, bool compare_exchange_weak(_Tp& __e, _Tp __d,
@@ -927,24 +959,24 @@ struct __atomic_base // false
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);} {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__atomic_base() _NOEXCEPT = default; __atomic_base() _NOEXCEPT = default;
#else #else
__atomic_base() _NOEXCEPT : __a_() {} __atomic_base() _NOEXCEPT : __a_() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
__atomic_base(const __atomic_base&) = delete; __atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete; __atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete; __atomic_base& operator=(const __atomic_base&) volatile = delete;
#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS #else
private: private:
__atomic_base(const __atomic_base&); __atomic_base(const __atomic_base&);
__atomic_base& operator=(const __atomic_base&); __atomic_base& operator=(const __atomic_base&);
__atomic_base& operator=(const __atomic_base&) volatile; __atomic_base& operator=(const __atomic_base&) volatile;
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS #endif
}; };
#if defined(__cpp_lib_atomic_is_always_lock_free) #if defined(__cpp_lib_atomic_is_always_lock_free)
@@ -1173,6 +1205,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void void
atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{ {
__o->store(__d, __m); __o->store(__d, __m);
} }
@@ -1181,6 +1214,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
void void
atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
{ {
__o->store(__d, __m); __o->store(__d, __m);
} }
@@ -1209,6 +1243,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
_Tp _Tp
atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
{ {
return __o->load(__m); return __o->load(__m);
} }
@@ -1217,6 +1252,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
_Tp _Tp
atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
{ {
return __o->load(__m); return __o->load(__m);
} }
@@ -1301,6 +1337,7 @@ bool
atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e, atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
_Tp __d, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{ {
return __o->compare_exchange_weak(*__e, __d, __s, __f); return __o->compare_exchange_weak(*__e, __d, __s, __f);
} }
@@ -1310,6 +1347,7 @@ inline _LIBCPP_INLINE_VISIBILITY
bool bool
atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d, atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{ {
return __o->compare_exchange_weak(*__e, __d, __s, __f); return __o->compare_exchange_weak(*__e, __d, __s, __f);
} }
@@ -1322,6 +1360,7 @@ bool
atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o, atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
_Tp* __e, _Tp __d, _Tp* __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{ {
return __o->compare_exchange_strong(*__e, __d, __s, __f); return __o->compare_exchange_strong(*__e, __d, __s, __f);
} }
@@ -1332,6 +1371,7 @@ bool
atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e, atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
_Tp __d, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
{ {
return __o->compare_exchange_strong(*__e, __d, __s, __f); return __o->compare_exchange_strong(*__e, __d, __s, __f);
} }
@@ -1682,25 +1722,25 @@ typedef struct atomic_flag
{__c11_atomic_store(&__a_, false, __m);} {__c11_atomic_store(&__a_, false, __m);}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
atomic_flag() _NOEXCEPT = default; atomic_flag() _NOEXCEPT = default;
#else #else
atomic_flag() _NOEXCEPT : __a_() {} atomic_flag() _NOEXCEPT : __a_() {}
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
atomic_flag(const atomic_flag&) = delete; atomic_flag(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) = delete; atomic_flag& operator=(const atomic_flag&) = delete;
atomic_flag& operator=(const atomic_flag&) volatile = delete; atomic_flag& operator=(const atomic_flag&) volatile = delete;
#else // _LIBCPP_HAS_NO_DELETED_FUNCTIONS #else
private: private:
atomic_flag(const atomic_flag&); atomic_flag(const atomic_flag&);
atomic_flag& operator=(const atomic_flag&); atomic_flag& operator=(const atomic_flag&);
atomic_flag& operator=(const atomic_flag&) volatile; atomic_flag& operator=(const atomic_flag&) volatile;
#endif // _LIBCPP_HAS_NO_DELETED_FUNCTIONS #endif
} atomic_flag; } atomic_flag;
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
@@ -1811,6 +1851,15 @@ typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef atomic<int_fast64_t> atomic_int_fast64_t; typedef atomic<int_fast64_t> atomic_int_fast64_t;
typedef atomic<uint_fast64_t> atomic_uint_fast64_t; typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
typedef atomic< int8_t> atomic_int8_t;
typedef atomic<uint8_t> atomic_uint8_t;
typedef atomic< int16_t> atomic_int16_t;
typedef atomic<uint16_t> atomic_uint16_t;
typedef atomic< int32_t> atomic_int32_t;
typedef atomic<uint32_t> atomic_uint32_t;
typedef atomic< int64_t> atomic_int64_t;
typedef atomic<uint64_t> atomic_uint64_t;
typedef atomic<intptr_t> atomic_intptr_t; typedef atomic<intptr_t> atomic_intptr_t;
typedef atomic<uintptr_t> atomic_uintptr_t; typedef atomic<uintptr_t> atomic_uintptr_t;
typedef atomic<size_t> atomic_size_t; typedef atomic<size_t> atomic_size_t;

View File

@@ -125,9 +125,6 @@ template <size_t N> struct hash<std::bitset<N>>;
#include <stdexcept> #include <stdexcept>
#include <iosfwd> #include <iosfwd>
#include <__functional_base> #include <__functional_base>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#include <__undef_min_max> #include <__undef_min_max>
@@ -262,7 +259,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
#if __SIZEOF_SIZE_T__ == 8 #if __SIZEOF_SIZE_T__ == 8
: __first_{__v} : __first_{__v}
#elif __SIZEOF_SIZE_T__ == 4 #elif __SIZEOF_SIZE_T__ == 4
: __first_{__v, __v >> __bits_per_word} : __first_{static_cast<__storage_type>(__v), static_cast<__storage_type>(__v >> __bits_per_word)}
#else #else
#error This constructor has not been ported to this platform #error This constructor has not been ported to this platform
#endif #endif
@@ -326,11 +323,8 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
const_iterator __e = __make_iter(_Size); const_iterator __e = __make_iter(_Size);
const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
if (__i != __e) if (__i != __e)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_overflow_error("bitset to_ulong overflow error");
throw overflow_error("bitset to_ulong overflow error");
#else
assert(!"bitset to_ulong overflow error");
#endif
return __first_[0]; return __first_[0];
} }
@@ -349,11 +343,8 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
const_iterator __e = __make_iter(_Size); const_iterator __e = __make_iter(_Size);
const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
if (__i != __e) if (__i != __e)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_overflow_error("bitset to_ullong overflow error");
throw overflow_error("bitset to_ullong overflow error");
#else
assert(!"bitset to_ullong overflow error");
#endif
return to_ullong(true_type()); return to_ullong(true_type());
} }
@@ -655,11 +646,11 @@ __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT
{ {
} }
template <size_t _Size> class _LIBCPP_TYPE_VIS_ONLY bitset; template <size_t _Size> class _LIBCPP_TEMPLATE_VIS bitset;
template <size_t _Size> struct hash<bitset<_Size> >; template <size_t _Size> struct hash<bitset<_Size> >;
template <size_t _Size> template <size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY bitset class _LIBCPP_TEMPLATE_VIS bitset
: private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size>
{ {
public: public:
@@ -763,11 +754,8 @@ bitset<_Size>::bitset(const _CharT* __str,
size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str)); size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str));
for (size_t __i = 0; __i < __rlen; ++__i) for (size_t __i = 0; __i < __rlen; ++__i)
if (__str[__i] != __zero && __str[__i] != __one) if (__str[__i] != __zero && __str[__i] != __one)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_invalid_argument("bitset string ctor has invalid argument");
throw invalid_argument("bitset string ctor has invalid argument");
#else
assert(!"bitset string ctor has invalid argument");
#endif
size_t _Mp = _VSTD::min(__rlen, _Size); size_t _Mp = _VSTD::min(__rlen, _Size);
size_t __i = 0; size_t __i = 0;
for (; __i < _Mp; ++__i) for (; __i < _Mp; ++__i)
@@ -789,19 +777,13 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
_CharT __zero, _CharT __one) _CharT __zero, _CharT __one)
{ {
if (__pos > __str.size()) if (__pos > __str.size())
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("bitset string pos out of range");
throw out_of_range("bitset string pos out of range");
#else
assert(!"bitset string pos out of range");
#endif
size_t __rlen = _VSTD::min(__n, __str.size() - __pos); size_t __rlen = _VSTD::min(__n, __str.size() - __pos);
for (size_t __i = __pos; __i < __pos + __rlen; ++__i) for (size_t __i = __pos; __i < __pos + __rlen; ++__i)
if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one)) if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_invalid_argument("bitset string ctor has invalid argument");
throw invalid_argument("bitset string ctor has invalid argument");
#else
assert(!"bitset string ctor has invalid argument");
#endif
size_t _Mp = _VSTD::min(__rlen, _Size); size_t _Mp = _VSTD::min(__rlen, _Size);
size_t __i = 0; size_t __i = 0;
for (; __i < _Mp; ++__i) for (; __i < _Mp; ++__i)
@@ -876,11 +858,8 @@ bitset<_Size>&
bitset<_Size>::set(size_t __pos, bool __val) bitset<_Size>::set(size_t __pos, bool __val)
{ {
if (__pos >= _Size) if (__pos >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("bitset set argument out of range");
throw out_of_range("bitset set argument out of range");
#else
assert(!"bitset set argument out of range");
#endif
(*this)[__pos] = __val; (*this)[__pos] = __val;
return *this; return *this;
} }
@@ -899,11 +878,8 @@ bitset<_Size>&
bitset<_Size>::reset(size_t __pos) bitset<_Size>::reset(size_t __pos)
{ {
if (__pos >= _Size) if (__pos >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("bitset reset argument out of range");
throw out_of_range("bitset reset argument out of range");
#else
assert(!"bitset reset argument out of range");
#endif
(*this)[__pos] = false; (*this)[__pos] = false;
return *this; return *this;
} }
@@ -932,11 +908,8 @@ bitset<_Size>&
bitset<_Size>::flip(size_t __pos) bitset<_Size>::flip(size_t __pos)
{ {
if (__pos >= _Size) if (__pos >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("bitset flip argument out of range");
throw out_of_range("bitset flip argument out of range");
#else
assert(!"bitset flip argument out of range");
#endif
reference r = base::__make_ref(__pos); reference r = base::__make_ref(__pos);
r = ~r; r = ~r;
return *this; return *this;
@@ -1027,11 +1000,8 @@ bool
bitset<_Size>::test(size_t __pos) const bitset<_Size>::test(size_t __pos) const
{ {
if (__pos >= _Size) if (__pos >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS __throw_out_of_range("bitset test argument out of range");
throw out_of_range("bitset test argument out of range");
#else
assert(!"bitset test argument out of range");
#endif
return (*this)[__pos]; return (*this)[__pos];
} }
@@ -1102,7 +1072,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT
} }
template <size_t _Size> template <size_t _Size>
struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> > struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> >
: public unary_function<bitset<_Size>, size_t> : public unary_function<bitset<_Size>, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY

View File

@@ -77,13 +77,13 @@ public:
constexpr duration operator+() const; constexpr duration operator+() const;
constexpr duration operator-() const; constexpr duration operator-() const;
duration& operator++(); constexpr duration& operator++();
duration operator++(int); constexpr duration operator++(int);
duration& operator--(); constexpr duration& operator--();
duration operator--(int); constexpr duration operator--(int);
duration& operator+=(const duration& d); constexpr duration& operator+=(const duration& d);
duration& operator-=(const duration& d); constexpr duration& operator-=(const duration& d);
duration& operator*=(const rep& rhs); duration& operator*=(const rep& rhs);
duration& operator/=(const rep& rhs); duration& operator/=(const rep& rhs);
@@ -316,7 +316,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono namespace chrono
{ {
template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS_ONLY duration; template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration;
template <class _Tp> template <class _Tp>
struct __is_duration : false_type {}; struct __is_duration : false_type {};
@@ -336,7 +336,7 @@ struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};
} // chrono } // chrono
template <class _Rep1, class _Period1, class _Rep2, class _Period2> template <class _Rep1, class _Period1, class _Rep2, class _Period2>
struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::duration<_Rep1, _Period1>, struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>,
chrono::duration<_Rep2, _Period2> > chrono::duration<_Rep2, _Period2> >
{ {
typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
@@ -414,7 +414,7 @@ duration_cast(const duration<_Rep, _Period>& __fd)
} }
template <class _Rep> template <class _Rep>
struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {}; struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
@@ -422,7 +422,7 @@ template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
#endif #endif
template <class _Rep> template <class _Rep>
struct _LIBCPP_TYPE_VIS_ONLY duration_values struct _LIBCPP_TEMPLATE_VIS duration_values
{ {
public: public:
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);}
@@ -485,7 +485,7 @@ round(const duration<_Rep, _Period>& __d)
// duration // duration
template <class _Rep, class _Period> template <class _Rep, class _Period>
class _LIBCPP_TYPE_VIS_ONLY duration class _LIBCPP_TEMPLATE_VIS duration
{ {
static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
@@ -529,7 +529,7 @@ private:
public: public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #ifndef _LIBCPP_CXX03_LANG
duration() = default; duration() = default;
#else #else
duration() {} duration() {}
@@ -567,18 +567,18 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator+() const {return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator+() const {return *this;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator-() const {return duration(-__rep_);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR duration operator-() const {return duration(-__rep_);}
_LIBCPP_INLINE_VISIBILITY duration& operator++() {++__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;}
_LIBCPP_INLINE_VISIBILITY duration operator++(int) {return duration(__rep_++);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);}
_LIBCPP_INLINE_VISIBILITY duration& operator--() {--__rep_; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;}
_LIBCPP_INLINE_VISIBILITY duration operator--(int) {return duration(__rep_--);} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);}
_LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
// special values // special values
@@ -828,7 +828,7 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
template <class _Clock, class _Duration = typename _Clock::duration> template <class _Clock, class _Duration = typename _Clock::duration>
class _LIBCPP_TYPE_VIS_ONLY time_point class _LIBCPP_TEMPLATE_VIS time_point
{ {
static_assert(__is_duration<_Duration>::value, static_assert(__is_duration<_Duration>::value,
"Second template parameter of time_point must be a std::chrono::duration"); "Second template parameter of time_point must be a std::chrono::duration");
@@ -872,7 +872,7 @@ public:
} // chrono } // chrono
template <class _Clock, class _Duration1, class _Duration2> template <class _Clock, class _Duration1, class _Duration2>
struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::time_point<_Clock, _Duration1>, struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>,
chrono::time_point<_Clock, _Duration2> > chrono::time_point<_Clock, _Duration2> >
{ {
typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
@@ -1026,7 +1026,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{ {
return __lhs + (-__rhs); typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
return _Ret(__lhs.time_since_epoch() -__rhs);
} }
// duration operator-(time_point x, time_point y); // duration operator-(time_point x, time_point y);

View File

@@ -331,7 +331,6 @@ using ::double_t;
using ::abs; using ::abs;
#endif #endif
#ifndef __sun__
using ::acos; using ::acos;
using ::acosf; using ::acosf;
using ::asin; using ::asin;
@@ -346,58 +345,47 @@ using ::cos;
using ::cosf; using ::cosf;
using ::cosh; using ::cosh;
using ::coshf; using ::coshf;
#endif // __sun__
using ::exp; using ::exp;
using ::expf; using ::expf;
#ifndef __sun__
using ::fabs; using ::fabs;
using ::fabsf; using ::fabsf;
using ::floor; using ::floor;
using ::floorf; using ::floorf;
#endif //__sun__
using ::fmod; using ::fmod;
using ::fmodf; using ::fmodf;
#ifndef __sun__
using ::frexp; using ::frexp;
using ::frexpf; using ::frexpf;
using ::ldexp; using ::ldexp;
using ::ldexpf; using ::ldexpf;
#endif // __sun__
using ::log; using ::log;
using ::logf; using ::logf;
#ifndef __sun__
using ::log10; using ::log10;
using ::log10f; using ::log10f;
using ::modf; using ::modf;
using ::modff; using ::modff;
#endif // __sun__
using ::pow; using ::pow;
using ::powf; using ::powf;
#ifndef __sun__
using ::sin; using ::sin;
using ::sinf; using ::sinf;
using ::sinh; using ::sinh;
using ::sinhf; using ::sinhf;
#endif // __sun__
using ::sqrt; using ::sqrt;
using ::sqrtf; using ::sqrtf;
using ::tan; using ::tan;
using ::tanf; using ::tanf;
#ifndef __sun__
using ::tanh; using ::tanh;
using ::tanhf; using ::tanhf;
#ifndef _LIBCPP_MSVCRT
using ::acosh; using ::acosh;
using ::acoshf; using ::acoshf;
using ::asinh; using ::asinh;
@@ -406,7 +394,6 @@ using ::atanh;
using ::atanhf; using ::atanhf;
using ::cbrt; using ::cbrt;
using ::cbrtf; using ::cbrtf;
#endif
using ::copysign; using ::copysign;
using ::copysignf; using ::copysignf;
@@ -449,14 +436,10 @@ using ::lrintf;
using ::lround; using ::lround;
using ::lroundf; using ::lroundf;
#endif // _LIBCPP_MSVCRT #endif // _LIBCPP_MSVCRT
#endif // __sun__
#ifndef _LIBCPP_MSVCRT
using ::nan; using ::nan;
using ::nanf; using ::nanf;
#endif // _LIBCPP_MSVCRT
#ifndef __sun__
#ifndef _LIBCPP_MSVCRT #ifndef _LIBCPP_MSVCRT
using ::nearbyint; using ::nearbyint;
using ::nearbyintf; using ::nearbyintf;
@@ -504,13 +487,11 @@ using ::sinhl;
using ::sqrtl; using ::sqrtl;
using ::tanl; using ::tanl;
#ifndef _LIBCPP_MSVCRT
using ::tanhl; using ::tanhl;
using ::acoshl; using ::acoshl;
using ::asinhl; using ::asinhl;
using ::atanhl; using ::atanhl;
using ::cbrtl; using ::cbrtl;
#endif // !_LIBCPP_MSVCRT
using ::copysignl; using ::copysignl;
@@ -547,11 +528,6 @@ using ::tgammal;
using ::truncl; using ::truncl;
#endif // !_LIBCPP_MSVCRT #endif // !_LIBCPP_MSVCRT
#else
using ::lgamma;
using ::lgammaf;
#endif // __sun__
#if _LIBCPP_STD_VER > 14 #if _LIBCPP_STD_VER > 14
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); } inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); } inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); }
@@ -559,23 +535,83 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y
template <class _A1, class _A2, class _A3> template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename std::__lazy_enable_if typename __lazy_enable_if
< <
std::is_arithmetic<_A1>::value && is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value && is_arithmetic<_A2>::value &&
std::is_arithmetic<_A3>::value, is_arithmetic<_A3>::value,
std::__promote<_A1, _A2, _A3> __promote<_A1, _A2, _A3>
>::type >::type
hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
{ {
typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; typedef typename __promote<_A1, _A2, _A3>::type __result_type;
static_assert((!(std::is_same<_A1, __result_type>::value && static_assert((!(is_same<_A1, __result_type>::value &&
std::is_same<_A2, __result_type>::value && is_same<_A2, __result_type>::value &&
std::is_same<_A3, __result_type>::value)), ""); is_same<_A3, __result_type>::value)), "");
return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
} }
#endif #endif
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isnan)
return __builtin_isnan(__lcpp_x);
#else
return isnan(__lcpp_x);
#endif
}
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
{
return isnan(__lcpp_x);
}
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isinf)
return __builtin_isinf(__lcpp_x);
#else
return isinf(__lcpp_x);
#endif
}
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
{
return isinf(__lcpp_x);
}
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
{
#if __has_builtin(__builtin_isfinite)
return __builtin_isfinite(__lcpp_x);
#else
return isfinite(__lcpp_x);
#endif
}
template <class _A1>
_LIBCPP_ALWAYS_INLINE
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
{
return isfinite(__lcpp_x);
}
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CMATH #endif // _LIBCPP_CMATH

View File

@@ -182,7 +182,7 @@ protected:
template <class _Elem, unsigned long _Maxcode = 0x10ffff, template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0> codecvt_mode _Mode = (codecvt_mode)0>
class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8 class _LIBCPP_TEMPLATE_VIS codecvt_utf8
: public __codecvt_utf8<_Elem> : public __codecvt_utf8<_Elem>
{ {
public: public:
@@ -410,7 +410,7 @@ protected:
template <class _Elem, unsigned long _Maxcode = 0x10ffff, template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0> codecvt_mode _Mode = (codecvt_mode)0>
class _LIBCPP_TYPE_VIS_ONLY codecvt_utf16 class _LIBCPP_TEMPLATE_VIS codecvt_utf16
: public __codecvt_utf16<_Elem, _Mode & little_endian> : public __codecvt_utf16<_Elem, _Mode & little_endian>
{ {
public: public:
@@ -533,7 +533,7 @@ protected:
template <class _Elem, unsigned long _Maxcode = 0x10ffff, template <class _Elem, unsigned long _Maxcode = 0x10ffff,
codecvt_mode _Mode = (codecvt_mode)0> codecvt_mode _Mode = (codecvt_mode)0>
class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8_utf16 class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16
: public __codecvt_utf8_utf16<_Elem> : public __codecvt_utf8_utf16<_Elem>
{ {
public: public:

View File

@@ -245,9 +245,6 @@ template<class T, class charT, class traits>
#include <stdexcept> #include <stdexcept>
#include <cmath> #include <cmath>
#include <sstream> #include <sstream>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -255,13 +252,13 @@ template<class T, class charT, class traits>
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY complex; template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template<class _Tp> template<class _Tp>
class _LIBCPP_TYPE_VIS_ONLY complex class _LIBCPP_TEMPLATE_VIS complex
{ {
public: public:
typedef _Tp value_type; typedef _Tp value_type;
@@ -319,11 +316,11 @@ public:
} }
}; };
template<> class _LIBCPP_TYPE_VIS_ONLY complex<double>; template<> class _LIBCPP_TEMPLATE_VIS complex<double>;
template<> class _LIBCPP_TYPE_VIS_ONLY complex<long double>; template<> class _LIBCPP_TEMPLATE_VIS complex<long double>;
template<> template<>
class _LIBCPP_TYPE_VIS_ONLY complex<float> class _LIBCPP_TEMPLATE_VIS complex<float>
{ {
float __re_; float __re_;
float __im_; float __im_;
@@ -381,7 +378,7 @@ public:
}; };
template<> template<>
class _LIBCPP_TYPE_VIS_ONLY complex<double> class _LIBCPP_TEMPLATE_VIS complex<double>
{ {
double __re_; double __re_;
double __im_; double __im_;
@@ -439,7 +436,7 @@ public:
}; };
template<> template<>
class _LIBCPP_TYPE_VIS_ONLY complex<long double> class _LIBCPP_TEMPLATE_VIS complex<long double>
{ {
long double __re_; long double __re_;
long double __im_; long double __im_;
@@ -602,39 +599,39 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __bc = __b * __c; _Tp __bc = __b * __c;
_Tp __x = __ac - __bd; _Tp __x = __ac - __bd;
_Tp __y = __ad + __bc; _Tp __y = __ad + __bc;
if (isnan(__x) && isnan(__y)) if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
{ {
bool __recalc = false; bool __recalc = false;
if (isinf(__a) || isinf(__b)) if (__libcpp_isinf(__a) || __libcpp_isinf(__b))
{ {
__a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a); __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
__b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b); __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
if (isnan(__c)) if (__libcpp_isnan(__c))
__c = copysign(_Tp(0), __c); __c = copysign(_Tp(0), __c);
if (isnan(__d)) if (__libcpp_isnan(__d))
__d = copysign(_Tp(0), __d); __d = copysign(_Tp(0), __d);
__recalc = true; __recalc = true;
} }
if (isinf(__c) || isinf(__d)) if (__libcpp_isinf(__c) || __libcpp_isinf(__d))
{ {
__c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c); __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
__d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d); __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
if (isnan(__a)) if (__libcpp_isnan(__a))
__a = copysign(_Tp(0), __a); __a = copysign(_Tp(0), __a);
if (isnan(__b)) if (__libcpp_isnan(__b))
__b = copysign(_Tp(0), __b); __b = copysign(_Tp(0), __b);
__recalc = true; __recalc = true;
} }
if (!__recalc && (isinf(__ac) || isinf(__bd) || if (!__recalc && (__libcpp_isinf(__ac) || __libcpp_isinf(__bd) ||
isinf(__ad) || isinf(__bc))) __libcpp_isinf(__ad) || __libcpp_isinf(__bc)))
{ {
if (isnan(__a)) if (__libcpp_isnan(__a))
__a = copysign(_Tp(0), __a); __a = copysign(_Tp(0), __a);
if (isnan(__b)) if (__libcpp_isnan(__b))
__b = copysign(_Tp(0), __b); __b = copysign(_Tp(0), __b);
if (isnan(__c)) if (__libcpp_isnan(__c))
__c = copysign(_Tp(0), __c); __c = copysign(_Tp(0), __c);
if (isnan(__d)) if (__libcpp_isnan(__d))
__d = copysign(_Tp(0), __d); __d = copysign(_Tp(0), __d);
__recalc = true; __recalc = true;
} }
@@ -677,7 +674,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __c = __w.real(); _Tp __c = __w.real();
_Tp __d = __w.imag(); _Tp __d = __w.imag();
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d))); _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
if (isfinite(__logbw)) if (__libcpp_isfinite(__logbw))
{ {
__ilogbw = static_cast<int>(__logbw); __ilogbw = static_cast<int>(__logbw);
__c = scalbn(__c, -__ilogbw); __c = scalbn(__c, -__ilogbw);
@@ -686,24 +683,24 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __denom = __c * __c + __d * __d; _Tp __denom = __c * __c + __d * __d;
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw); _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw); _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
if (isnan(__x) && isnan(__y)) if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
{ {
if ((__denom == _Tp(0)) && (!isnan(__a) || !isnan(__b))) if ((__denom == _Tp(0)) && (!__libcpp_isnan(__a) || !__libcpp_isnan(__b)))
{ {
__x = copysign(_Tp(INFINITY), __c) * __a; __x = copysign(_Tp(INFINITY), __c) * __a;
__y = copysign(_Tp(INFINITY), __c) * __b; __y = copysign(_Tp(INFINITY), __c) * __b;
} }
else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d)) else if ((__libcpp_isinf(__a) || __libcpp_isinf(__b)) && __libcpp_isfinite(__c) && __libcpp_isfinite(__d))
{ {
__a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a); __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
__b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b); __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
__x = _Tp(INFINITY) * (__a * __c + __b * __d); __x = _Tp(INFINITY) * (__a * __c + __b * __d);
__y = _Tp(INFINITY) * (__b * __c - __a * __d); __y = _Tp(INFINITY) * (__b * __c - __a * __d);
} }
else if (isinf(__logbw) && __logbw > _Tp(0) && isfinite(__a) && isfinite(__b)) else if (__libcpp_isinf(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite(__a) && __libcpp_isfinite(__b))
{ {
__c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c); __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
__d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d); __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d); __x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d); __y = _Tp(0) * (__b * __c - __a * __d);
} }
@@ -795,6 +792,27 @@ operator!=(const _Tp& __x, const complex<_Tp>& __y)
// 26.3.7 values: // 26.3.7 values:
template <class _Tp, bool = is_integral<_Tp>::value,
bool = is_floating_point<_Tp>::value
>
struct __libcpp_complex_overload_traits {};
// Integral Types
template <class _Tp>
struct __libcpp_complex_overload_traits<_Tp, true, false>
{
typedef double _ValueType;
typedef complex<double> _ComplexType;
};
// Floating point types
template <class _Tp>
struct __libcpp_complex_overload_traits<_Tp, false, true>
{
typedef _Tp _ValueType;
typedef complex<_Tp> _ComplexType;
};
// real // real
template<class _Tp> template<class _Tp>
@@ -805,39 +823,14 @@ real(const complex<_Tp>& __c)
return __c.real(); return __c.real();
} }
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
long double
real(long double __re)
{
return __re;
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
double
real(double __re)
{
return __re;
}
template <class _Tp> template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename enable_if typename __libcpp_complex_overload_traits<_Tp>::_ValueType
<
is_integral<_Tp>::value,
double
>::type
real(_Tp __re) real(_Tp __re)
{ {
return __re; return __re;
} }
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
float
real(float __re)
{
return __re;
}
// imag // imag
template<class _Tp> template<class _Tp>
@@ -848,35 +841,10 @@ imag(const complex<_Tp>& __c)
return __c.imag(); return __c.imag();
} }
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
long double
imag(long double __re)
{
return 0;
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
double
imag(double __re)
{
return 0;
}
template <class _Tp> template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename enable_if typename __libcpp_complex_overload_traits<_Tp>::_ValueType
< imag(_Tp)
is_integral<_Tp>::value,
double
>::type
imag(_Tp __re)
{
return 0;
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
float
imag(float __re)
{ {
return 0; return 0;
} }
@@ -901,25 +869,22 @@ arg(const complex<_Tp>& __c)
return atan2(__c.imag(), __c.real()); return atan2(__c.imag(), __c.real());
} }
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename enable_if<
is_same<_Tp, long double>::value,
long double long double
arg(long double __re) >::type
arg(_Tp __re)
{ {
return atan2l(0.L, __re); return atan2l(0.L, __re);
} }
inline _LIBCPP_INLINE_VISIBILITY
double
arg(double __re)
{
return atan2(0., __re);
}
template<class _Tp> template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename enable_if typename enable_if
< <
is_integral<_Tp>::value, is_integral<_Tp>::value || is_same<_Tp, double>::value,
double double
>::type >::type
arg(_Tp __re) arg(_Tp __re)
@@ -927,9 +892,13 @@ arg(_Tp __re)
return atan2(0., __re); return atan2(0., __re);
} }
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename enable_if<
is_same<_Tp, float>::value,
float float
arg(float __re) >::type
arg(_Tp __re)
{ {
return atan2f(0.F, __re); return atan2f(0.F, __re);
} }
@@ -941,44 +910,20 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp _Tp
norm(const complex<_Tp>& __c) norm(const complex<_Tp>& __c)
{ {
if (isinf(__c.real())) if (__libcpp_isinf(__c.real()))
return abs(__c.real()); return abs(__c.real());
if (isinf(__c.imag())) if (__libcpp_isinf(__c.imag()))
return abs(__c.imag()); return abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag(); return __c.real() * __c.real() + __c.imag() * __c.imag();
} }
inline _LIBCPP_INLINE_VISIBILITY
long double
norm(long double __re)
{
return __re * __re;
}
inline _LIBCPP_INLINE_VISIBILITY
double
norm(double __re)
{
return __re * __re;
}
template <class _Tp> template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename enable_if typename __libcpp_complex_overload_traits<_Tp>::_ValueType
<
is_integral<_Tp>::value,
double
>::type
norm(_Tp __re) norm(_Tp __re)
{ {
return (double)__re * __re; typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType;
} return static_cast<_ValueType>(__re) * __re;
inline _LIBCPP_INLINE_VISIBILITY
float
norm(float __re)
{
return __re * __re;
} }
// conj // conj
@@ -991,38 +936,16 @@ conj(const complex<_Tp>& __c)
return complex<_Tp>(__c.real(), -__c.imag()); return complex<_Tp>(__c.real(), -__c.imag());
} }
inline _LIBCPP_INLINE_VISIBILITY
complex<long double>
conj(long double __re)
{
return complex<long double>(__re);
}
inline _LIBCPP_INLINE_VISIBILITY
complex<double>
conj(double __re)
{
return complex<double>(__re);
}
template <class _Tp> template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename enable_if typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
<
is_integral<_Tp>::value,
complex<double>
>::type
conj(_Tp __re) conj(_Tp __re)
{ {
return complex<double>(__re); typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
return _ComplexType(__re);
} }
inline _LIBCPP_INLINE_VISIBILITY
complex<float>
conj(float __re)
{
return complex<float>(__re);
}
// proj // proj
@@ -1032,27 +955,23 @@ complex<_Tp>
proj(const complex<_Tp>& __c) proj(const complex<_Tp>& __c)
{ {
std::complex<_Tp> __r = __c; std::complex<_Tp> __r = __c;
if (isinf(__c.real()) || isinf(__c.imag())) if (__libcpp_isinf(__c.real()) || __libcpp_isinf(__c.imag()))
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag())); __r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
return __r; return __r;
} }
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
complex<long double> typename enable_if
proj(long double __re) <
is_floating_point<_Tp>::value,
typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
>::type
proj(_Tp __re)
{ {
if (isinf(__re)) if (__libcpp_isinf(__re))
__re = abs(__re); __re = abs(__re);
return complex<long double>(__re); return complex<_Tp>(__re);
}
inline _LIBCPP_INLINE_VISIBILITY
complex<double>
proj(double __re)
{
if (isinf(__re))
__re = abs(__re);
return complex<double>(__re);
} }
template <class _Tp> template <class _Tp>
@@ -1060,20 +979,12 @@ inline _LIBCPP_INLINE_VISIBILITY
typename enable_if typename enable_if
< <
is_integral<_Tp>::value, is_integral<_Tp>::value,
complex<double> typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
>::type >::type
proj(_Tp __re) proj(_Tp __re)
{ {
return complex<double>(__re); typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
} return _ComplexType(__re);
inline _LIBCPP_INLINE_VISIBILITY
complex<float>
proj(float __re)
{
if (isinf(__re))
__re = abs(__re);
return complex<float>(__re);
} }
// polar // polar
@@ -1082,25 +993,25 @@ template<class _Tp>
complex<_Tp> complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0)) polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
{ {
if (isnan(__rho) || signbit(__rho)) if (__libcpp_isnan(__rho) || signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN)); return complex<_Tp>(_Tp(NAN), _Tp(NAN));
if (isnan(__theta)) if (__libcpp_isnan(__theta))
{ {
if (isinf(__rho)) if (__libcpp_isinf(__rho))
return complex<_Tp>(__rho, __theta); return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta); return complex<_Tp>(__theta, __theta);
} }
if (isinf(__theta)) if (__libcpp_isinf(__theta))
{ {
if (isinf(__rho)) if (__libcpp_isinf(__rho))
return complex<_Tp>(__rho, _Tp(NAN)); return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN)); return complex<_Tp>(_Tp(NAN), _Tp(NAN));
} }
_Tp __x = __rho * cos(__theta); _Tp __x = __rho * cos(__theta);
if (isnan(__x)) if (__libcpp_isnan(__x))
__x = 0; __x = 0;
_Tp __y = __rho * sin(__theta); _Tp __y = __rho * sin(__theta);
if (isnan(__y)) if (__libcpp_isnan(__y))
__y = 0; __y = 0;
return complex<_Tp>(__x, __y); return complex<_Tp>(__x, __y);
} }
@@ -1131,13 +1042,13 @@ template<class _Tp>
complex<_Tp> complex<_Tp>
sqrt(const complex<_Tp>& __x) sqrt(const complex<_Tp>& __x)
{ {
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag()); return complex<_Tp>(_Tp(INFINITY), __x.imag());
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (__x.real() > _Tp(0)) if (__x.real() > _Tp(0))
return complex<_Tp>(__x.real(), isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag())); return complex<_Tp>(__x.real(), __libcpp_isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
return complex<_Tp>(isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag())); return complex<_Tp>(__libcpp_isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
} }
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2)); return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
} }
@@ -1149,21 +1060,21 @@ complex<_Tp>
exp(const complex<_Tp>& __x) exp(const complex<_Tp>& __x)
{ {
_Tp __i = __x.imag(); _Tp __i = __x.imag();
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (__x.real() < _Tp(0)) if (__x.real() < _Tp(0))
{ {
if (!isfinite(__i)) if (!__libcpp_isfinite(__i))
__i = _Tp(1); __i = _Tp(1);
} }
else if (__i == 0 || !isfinite(__i)) else if (__i == 0 || !__libcpp_isfinite(__i))
{ {
if (isinf(__i)) if (__libcpp_isinf(__i))
__i = _Tp(NAN); __i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i); return complex<_Tp>(__x.real(), __i);
} }
} }
else if (isnan(__x.real()) && __x.imag() == 0) else if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
return __x; return __x;
_Tp __e = exp(__x.real()); _Tp __e = exp(__x.real());
return complex<_Tp>(__e * cos(__i), __e * sin(__i)); return complex<_Tp>(__e * cos(__i), __e * sin(__i));
@@ -1221,23 +1132,23 @@ complex<_Tp>
asinh(const complex<_Tp>& __x) asinh(const complex<_Tp>& __x)
{ {
const _Tp __pi(atan2(+0., -0.)); const _Tp __pi(atan2(+0., -0.));
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (isnan(__x.imag())) if (__libcpp_isnan(__x.imag()))
return __x; return __x;
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag())); return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
} }
if (isnan(__x.real())) if (__libcpp_isnan(__x.real()))
{ {
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real()); return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0) if (__x.imag() == 0)
return __x; return __x;
return complex<_Tp>(__x.real(), __x.real()); return complex<_Tp>(__x.real(), __x.real());
} }
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag())); return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1))); complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag())); return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
@@ -1250,11 +1161,11 @@ complex<_Tp>
acosh(const complex<_Tp>& __x) acosh(const complex<_Tp>& __x)
{ {
const _Tp __pi(atan2(+0., -0.)); const _Tp __pi(atan2(+0., -0.));
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (isnan(__x.imag())) if (__libcpp_isnan(__x.imag()))
return complex<_Tp>(abs(__x.real()), __x.imag()); return complex<_Tp>(abs(__x.real()), __x.imag());
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
{ {
if (__x.real() > 0) if (__x.real() > 0)
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag())); return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
@@ -1265,13 +1176,13 @@ acosh(const complex<_Tp>& __x)
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag())); return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag())); return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
} }
if (isnan(__x.real())) if (__libcpp_isnan(__x.real()))
{ {
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(abs(__x.imag()), __x.real()); return complex<_Tp>(abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real()); return complex<_Tp>(__x.real(), __x.real());
} }
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag())); return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1))); complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag())); return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
@@ -1284,21 +1195,21 @@ complex<_Tp>
atanh(const complex<_Tp>& __x) atanh(const complex<_Tp>& __x)
{ {
const _Tp __pi(atan2(+0., -0.)); const _Tp __pi(atan2(+0., -0.));
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
{ {
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag())); return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
} }
if (isnan(__x.imag())) if (__libcpp_isnan(__x.imag()))
{ {
if (isinf(__x.real()) || __x.real() == 0) if (__libcpp_isinf(__x.real()) || __x.real() == 0)
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag()); return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag()); return complex<_Tp>(__x.imag(), __x.imag());
} }
if (isnan(__x.real())) if (__libcpp_isnan(__x.real()))
{ {
return complex<_Tp>(__x.real(), __x.real()); return complex<_Tp>(__x.real(), __x.real());
} }
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag())); return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
} }
@@ -1316,11 +1227,11 @@ template<class _Tp>
complex<_Tp> complex<_Tp>
sinh(const complex<_Tp>& __x) sinh(const complex<_Tp>& __x)
{ {
if (isinf(__x.real()) && !isfinite(__x.imag())) if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN)); return complex<_Tp>(__x.real(), _Tp(NAN));
if (__x.real() == 0 && !isfinite(__x.imag())) if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN)); return complex<_Tp>(__x.real(), _Tp(NAN));
if (__x.imag() == 0 && !isfinite(__x.real())) if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
return __x; return __x;
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag())); return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
} }
@@ -1331,13 +1242,13 @@ template<class _Tp>
complex<_Tp> complex<_Tp>
cosh(const complex<_Tp>& __x) cosh(const complex<_Tp>& __x)
{ {
if (isinf(__x.real()) && !isfinite(__x.imag())) if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(abs(__x.real()), _Tp(NAN)); return complex<_Tp>(abs(__x.real()), _Tp(NAN));
if (__x.real() == 0 && !isfinite(__x.imag())) if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real()); return complex<_Tp>(_Tp(NAN), __x.real());
if (__x.real() == 0 && __x.imag() == 0) if (__x.real() == 0 && __x.imag() == 0)
return complex<_Tp>(_Tp(1), __x.imag()); return complex<_Tp>(_Tp(1), __x.imag());
if (__x.imag() == 0 && !isfinite(__x.real())) if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
return complex<_Tp>(abs(__x.real()), __x.imag()); return complex<_Tp>(abs(__x.real()), __x.imag());
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag())); return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
} }
@@ -1348,19 +1259,19 @@ template<class _Tp>
complex<_Tp> complex<_Tp>
tanh(const complex<_Tp>& __x) tanh(const complex<_Tp>& __x)
{ {
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (!isfinite(__x.imag())) if (!__libcpp_isfinite(__x.imag()))
return complex<_Tp>(_Tp(1), _Tp(0)); return complex<_Tp>(_Tp(1), _Tp(0));
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
} }
if (isnan(__x.real()) && __x.imag() == 0) if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
return __x; return __x;
_Tp __2r(_Tp(2) * __x.real()); _Tp __2r(_Tp(2) * __x.real());
_Tp __2i(_Tp(2) * __x.imag()); _Tp __2i(_Tp(2) * __x.imag());
_Tp __d(cosh(__2r) + cos(__2i)); _Tp __d(cosh(__2r) + cos(__2i));
_Tp __2rsh(sinh(__2r)); _Tp __2rsh(sinh(__2r));
if (isinf(__2rsh) && isinf(__d)) if (__libcpp_isinf(__2rsh) && __libcpp_isinf(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); __2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
return complex<_Tp>(__2rsh/__d, sin(__2i)/__d); return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
@@ -1383,11 +1294,11 @@ complex<_Tp>
acos(const complex<_Tp>& __x) acos(const complex<_Tp>& __x)
{ {
const _Tp __pi(atan2(+0., -0.)); const _Tp __pi(atan2(+0., -0.));
if (isinf(__x.real())) if (__libcpp_isinf(__x.real()))
{ {
if (isnan(__x.imag())) if (__libcpp_isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real()); return complex<_Tp>(__x.imag(), __x.real());
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
{ {
if (__x.real() < _Tp(0)) if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
@@ -1397,13 +1308,13 @@ acos(const complex<_Tp>& __x)
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real()); return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real()); return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
} }
if (isnan(__x.real())) if (__libcpp_isnan(__x.real()))
{ {
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag()); return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real()); return complex<_Tp>(__x.real(), __x.real());
} }
if (isinf(__x.imag())) if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag()); return complex<_Tp>(__pi/_Tp(2), -__x.imag());
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag()))) if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
return complex<_Tp>(__pi/_Tp(2), -__x.imag()); return complex<_Tp>(__pi/_Tp(2), -__x.imag());

View File

@@ -98,6 +98,9 @@ void perror(const char* s);
#include <__config> #include <__config>
#include <stdio.h> #include <stdio.h>
#if defined(_LIBCPP_MSVCRT)
#include <crtversion.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -118,11 +121,9 @@ using ::fscanf;
using ::snprintf; using ::snprintf;
using ::sprintf; using ::sprintf;
using ::sscanf; using ::sscanf;
#ifndef _LIBCPP_MSVCRT
using ::vfprintf; using ::vfprintf;
using ::vfscanf; using ::vfscanf;
using ::vsscanf; using ::vsscanf;
#endif // _LIBCPP_MSVCRT
using ::vsnprintf; using ::vsnprintf;
using ::vsprintf; using ::vsprintf;
using ::fgetc; using ::fgetc;
@@ -155,7 +156,8 @@ using ::tmpnam;
#ifndef _LIBCPP_HAS_NO_STDIN #ifndef _LIBCPP_HAS_NO_STDIN
using ::getchar; using ::getchar;
#if _LIBCPP_STD_VER <= 11 #if _LIBCPP_STD_VER <= 11 && \
(!defined(_VC_CRT_MAJOR_VERSION) || _VC_CRT_MAJOR_VERSION < 14)
using ::gets; using ::gets;
#endif #endif
using ::scanf; using ::scanf;

View File

@@ -89,6 +89,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
#pragma GCC system_header #pragma GCC system_header
#endif #endif
#ifdef __GNUC__
#define _LIBCPP_UNREACHABLE() __builtin_unreachable()
#else
#define _LIBCPP_UNREACHABLE() _VSTD::abort()
#endif
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
using ::size_t; using ::size_t;
@@ -138,11 +144,9 @@ using ::ldiv;
#ifndef _LIBCPP_HAS_NO_LONG_LONG #ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::lldiv; using ::lldiv;
#endif // _LIBCPP_HAS_NO_LONG_LONG #endif // _LIBCPP_HAS_NO_LONG_LONG
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
using ::mblen; using ::mblen;
using ::mbtowc; using ::mbtowc;
using ::wctomb; using ::wctomb;
#endif
using ::mbstowcs; using ::mbstowcs;
using ::wcstombs; using ::wcstombs;
#ifdef _LIBCPP_HAS_QUICK_EXIT #ifdef _LIBCPP_HAS_QUICK_EXIT

View File

@@ -123,11 +123,9 @@ using ::fwscanf;
using ::swprintf; using ::swprintf;
using ::vfwprintf; using ::vfwprintf;
using ::vswprintf; using ::vswprintf;
#ifndef _LIBCPP_MSVCRT
using ::swscanf; using ::swscanf;
using ::vfwscanf; using ::vfwscanf;
using ::vswscanf; using ::vswscanf;
#endif // _LIBCPP_MSVCRT
using ::fgetwc; using ::fgetwc;
using ::fgetws; using ::fgetws;
using ::fputwc; using ::fputwc;
@@ -137,10 +135,8 @@ using ::getwc;
using ::putwc; using ::putwc;
using ::ungetwc; using ::ungetwc;
using ::wcstod; using ::wcstod;
#ifndef _LIBCPP_MSVCRT
using ::wcstof; using ::wcstof;
using ::wcstold; using ::wcstold;
#endif // _LIBCPP_MSVCRT
using ::wcstol; using ::wcstol;
#ifndef _LIBCPP_HAS_NO_LONG_LONG #ifndef _LIBCPP_HAS_NO_LONG_LONG
using ::wcstoll; using ::wcstoll;
@@ -182,9 +178,7 @@ using ::wcsrtombs;
#ifndef _LIBCPP_HAS_NO_STDIN #ifndef _LIBCPP_HAS_NO_STDIN
using ::getwchar; using ::getwchar;
#ifndef _LIBCPP_MSVCRT
using ::vwscanf; using ::vwscanf;
#endif // _LIBCPP_MSVCRT
using ::wscanf; using ::wscanf;
#endif #endif

View File

@@ -110,8 +110,8 @@ public:
void push_front(value_type&& v); void push_front(value_type&& v);
void push_back(const value_type& v); void push_back(const value_type& v);
void push_back(value_type&& v); void push_back(value_type&& v);
template <class... Args> void emplace_front(Args&&... args); template <class... Args> reference emplace_front(Args&&... args); // reference in C++17
template <class... Args> void emplace_back(Args&&... args); template <class... Args> reference emplace_back(Args&&... args); // reference in C++17
template <class... Args> iterator emplace(const_iterator p, Args&&... args); template <class... Args> iterator emplace(const_iterator p, Args&&... args);
iterator insert(const_iterator p, const value_type& v); iterator insert(const_iterator p, const value_type& v);
iterator insert(const_iterator p, value_type&& v); iterator insert(const_iterator p, value_type&& v);
@@ -167,11 +167,11 @@ template <class T, class Allocator>
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Allocator> class __deque_base; template <class _Tp, class _Allocator> class __deque_base;
template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY deque; template <class _Tp, class _Allocator = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS deque;
template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
class _DiffType, _DiffType _BlockSize> class _DiffType, _DiffType _BlockSize>
class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; class _LIBCPP_TEMPLATE_VIS __deque_iterator;
template <class _RAIter, template <class _RAIter,
class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2> class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
@@ -276,7 +276,7 @@ template <class _ValueType, class _Pointer, class _Reference, class _MapPointer,
__deque_block_size<_ValueType, _DiffType>::value __deque_block_size<_ValueType, _DiffType>::value
#endif #endif
> >
class _LIBCPP_TYPE_VIS_ONLY __deque_iterator class _LIBCPP_TEMPLATE_VIS __deque_iterator
{ {
typedef _MapPointer __map_iterator; typedef _MapPointer __map_iterator;
public: public:
@@ -428,9 +428,9 @@ private:
: __m_iter_(__m), __ptr_(__p) {} : __m_iter_(__m), __ptr_(__p) {}
template <class _Tp, class _Ap> friend class __deque_base; template <class _Tp, class _Ap> friend class __deque_base;
template <class _Tp, class _Ap> friend class _LIBCPP_TYPE_VIS_ONLY deque; template <class _Tp, class _Ap> friend class _LIBCPP_TEMPLATE_VIS deque;
template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp> template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
friend class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;
template <class _RAIter, template <class _RAIter,
class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2> class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2>
@@ -895,26 +895,22 @@ template <bool>
class __deque_base_common class __deque_base_common
{ {
protected: protected:
void __throw_length_error() const; _LIBCPP_NORETURN void __throw_length_error() const;
void __throw_out_of_range() const; _LIBCPP_NORETURN void __throw_out_of_range() const;
}; };
template <bool __b> template <bool __b>
void void
__deque_base_common<__b>::__throw_length_error() const __deque_base_common<__b>::__throw_length_error() const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS _VSTD::__throw_length_error("deque");
throw length_error("deque");
#endif
} }
template <bool __b> template <bool __b>
void void
__deque_base_common<__b>::__throw_out_of_range() const __deque_base_common<__b>::__throw_out_of_range() const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS _VSTD::__throw_out_of_range("deque");
throw out_of_range("deque");
#endif
} }
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
@@ -1187,7 +1183,7 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT
} }
template <class _Tp, class _Allocator /*= allocator<_Tp>*/> template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY deque class _LIBCPP_TEMPLATE_VIS deque
: private __deque_base<_Tp, _Allocator> : private __deque_base<_Tp, _Allocator>
{ {
public: public:
@@ -1314,7 +1310,9 @@ public:
size_type size() const _NOEXCEPT {return __base::size();} size_type size() const _NOEXCEPT {return __base::size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT size_type max_size() const _NOEXCEPT
{return __alloc_traits::max_size(__base::__alloc());} {return std::min<size_type>(
__alloc_traits::max_size(__base::__alloc()),
numeric_limits<difference_type>::max());}
void resize(size_type __n); void resize(size_type __n);
void resize(size_type __n, const value_type& __v); void resize(size_type __n, const value_type& __v);
void shrink_to_fit() _NOEXCEPT; void shrink_to_fit() _NOEXCEPT;
@@ -1344,8 +1342,13 @@ public:
void push_back(const value_type& __v); void push_back(const value_type& __v);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
#if _LIBCPP_STD_VER > 14
template <class... _Args> reference emplace_front(_Args&&... __args);
template <class... _Args> reference emplace_back (_Args&&... __args);
#else
template <class... _Args> void emplace_front(_Args&&... __args); template <class... _Args> void emplace_front(_Args&&... __args);
template <class... _Args> void emplace_back (_Args&&... __args); template <class... _Args> void emplace_back (_Args&&... __args);
#endif
template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args); template <class... _Args> iterator emplace(const_iterator __p, _Args&&... __args);
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
void push_front(value_type&& __v); void push_front(value_type&& __v);
@@ -1824,15 +1827,23 @@ deque<_Tp, _Allocator>::push_back(value_type&& __v)
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
typename deque<_Tp, _Allocator>::reference
#else
void void
#endif
deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) deque<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{ {
allocator_type& __a = __base::__alloc(); allocator_type& __a = __base::__alloc();
if (__back_spare() == 0) if (__back_spare() == 0)
__add_back_capacity(); __add_back_capacity();
// __back_spare() >= 1 // __back_spare() >= 1
__alloc_traits::construct(__a, _VSTD::addressof(*__base::end()), _VSTD::forward<_Args>(__args)...); __alloc_traits::construct(__a, _VSTD::addressof(*__base::end()),
_VSTD::forward<_Args>(__args)...);
++__base::size(); ++__base::size();
#if _LIBCPP_STD_VER > 14
return *--__base::end();
#endif
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
@@ -1870,7 +1881,11 @@ deque<_Tp, _Allocator>::push_front(value_type&& __v)
template <class _Tp, class _Allocator> template <class _Tp, class _Allocator>
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
typename deque<_Tp, _Allocator>::reference
#else
void void
#endif
deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
{ {
allocator_type& __a = __base::__alloc(); allocator_type& __a = __base::__alloc();
@@ -1880,6 +1895,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args)
__alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...); __alloc_traits::construct(__a, _VSTD::addressof(*--__base::begin()), _VSTD::forward<_Args>(__args)...);
--__base::__start_; --__base::__start_;
++__base::size(); ++__base::size();
#if _LIBCPP_STD_VER > 14
return *__base::begin();
#endif
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
@@ -2026,7 +2044,7 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
} }
else else
{ {
value_type __tmp(_VSTD::forward<_Args>(__args)...); __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
iterator __b = __base::begin(); iterator __b = __base::begin();
iterator __bm1 = _VSTD::prev(__b); iterator __bm1 = _VSTD::prev(__b);
__alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b)); __alloc_traits::construct(__a, _VSTD::addressof(*__bm1), _VSTD::move(*__b));
@@ -2034,7 +2052,7 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
++__base::size(); ++__base::size();
if (__pos > 1) if (__pos > 1)
__b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b); __b = _VSTD::move(_VSTD::next(__b), __b + __pos, __b);
*__b = _VSTD::move(__tmp); *__b = _VSTD::move(__tmp.get());
} }
} }
else else
@@ -2050,14 +2068,14 @@ deque<_Tp, _Allocator>::emplace(const_iterator __p, _Args&&... __args)
} }
else else
{ {
value_type __tmp(_VSTD::forward<_Args>(__args)...); __temp_value<value_type, _Allocator> __tmp(this->__alloc(), _VSTD::forward<_Args>(__args)...);
iterator __e = __base::end(); iterator __e = __base::end();
iterator __em1 = _VSTD::prev(__e); iterator __em1 = _VSTD::prev(__e);
__alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1)); __alloc_traits::construct(__a, _VSTD::addressof(*__e), _VSTD::move(*__em1));
++__base::size(); ++__base::size();
if (__de > 1) if (__de > 1)
__e = _VSTD::move_backward(__e - __de, __em1, __e); __e = _VSTD::move_backward(__e - __de, __em1, __e);
*--__e = _VSTD::move(__tmp); *--__e = _VSTD::move(__tmp.get());
} }
} }
return __base::begin() + __pos; return __base::begin() + __pos;
@@ -2734,7 +2752,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f)
difference_type __pos = __f - __b; difference_type __pos = __f - __b;
iterator __p = __b + __pos; iterator __p = __b + __pos;
allocator_type& __a = __base::__alloc(); allocator_type& __a = __base::__alloc();
if (__pos <= (__base::size() - 1) / 2) if (static_cast<size_t>(__pos) <= (__base::size() - 1) / 2)
{ // erase from front { // erase from front
_VSTD::move_backward(__b, __p, _VSTD::next(__p)); _VSTD::move_backward(__b, __p, _VSTD::next(__p));
__alloc_traits::destroy(__a, _VSTD::addressof(*__b)); __alloc_traits::destroy(__a, _VSTD::addressof(*__b));
@@ -2772,7 +2790,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
if (__n > 0) if (__n > 0)
{ {
allocator_type& __a = __base::__alloc(); allocator_type& __a = __base::__alloc();
if (__pos <= (__base::size() - __n) / 2) if (static_cast<size_t>(__pos) <= (__base::size() - __n) / 2)
{ // erase from front { // erase from front
iterator __i = _VSTD::move_backward(__b, __p, __p + __n); iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
for (; __b != __i; ++__b) for (; __b != __i; ++__b)

View File

@@ -79,11 +79,8 @@ template <class E> void rethrow_if_nested(const E& e);
#include <__config> #include <__config>
#include <cstddef> #include <cstddef>
#include <type_traits>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#endif #include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -165,7 +162,10 @@ make_exception_ptr(_Ep __e) _NOEXCEPT
{ {
return current_exception(); return current_exception();
} }
#endif // _LIBCPP_NO_EXCEPTIONS #else
((void)__e);
_VSTD::abort();
#endif
} }
// nested_exception // nested_exception
@@ -209,6 +209,9 @@ throw_with_nested (_Tp& __t, typename enable_if<
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
throw __nested<typename remove_reference<_Tp>::type>(_VSTD::forward<_Tp>(__t)); throw __nested<typename remove_reference<_Tp>::type>(_VSTD::forward<_Tp>(__t));
#else
((void)__t);
// FIXME: Make this abort.
#endif #endif
} }
@@ -229,6 +232,9 @@ throw_with_nested (_Tp& __t, typename enable_if<
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
throw _VSTD::forward<_Tp>(__t); throw _VSTD::forward<_Tp>(__t);
#else
((void)__t);
// FIXME: Make this abort
#endif #endif
} }
@@ -255,19 +261,4 @@ rethrow_if_nested(const _Ep&, typename enable_if<
} // std } // std
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Exception>
_LIBCPP_INLINE_VISIBILITY
inline void __libcpp_throw(_Exception const& __e) {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw __e;
#else
_VSTD::fprintf(stderr, "%s\n", __e.what());
_VSTD::abort();
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_EXCEPTION #endif // _LIBCPP_EXCEPTION

View File

@@ -25,6 +25,10 @@
#define _LIBCPP_END_NAMESPACE_LFTS } } } #define _LIBCPP_END_NAMESPACE_LFTS } } }
#define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1 #define _VSTD_LFTS _VSTD_EXPERIMENTAL::fundamentals_v1
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
#define _LIBCPP_END_NAMESPACE_LFTS_V2 } } }
#define _VSTD_LFTS_V2 _VSTD_EXPERIMENTAL::fundamentals_v2
#define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr { #define _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR _LIBCPP_BEGIN_NAMESPACE_LFTS namespace pmr {
#define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS } #define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS }
#define _VSTD_LFTS_PMR _VSTD_LFTS::pmr #define _VSTD_LFTS_PMR _VSTD_LFTS::pmr
@@ -33,4 +37,14 @@
namespace chrono { namespace experimental { inline namespace fundamentals_v1 { namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } } #define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \
inline namespace v1 {
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
} } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
#define _VSTD_FS ::std::experimental::filesystem::v1
#endif #endif

View File

@@ -58,61 +58,11 @@ _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searc
template <class _PopulationIterator, class _SampleIterator, class _Distance, template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator> class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first, _SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
_PopulationIterator __last, _SampleIterator __out, _SampleIterator __output, _Distance __n,
_Distance __n, _UniformRandomNumberGenerator &&__g) {
_UniformRandomNumberGenerator &&__g, return _VSTD::__sample(__first, __last, __output, __n, __g);
input_iterator_tag) {
_Distance __k = 0;
for (; __first != __last && __k < __n; ++__first, (void)++__k)
__out[__k] = *__first;
_Distance __sz = __k;
for (; __first != __last; ++__first, (void)++__k) {
_Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
if (__r < __sz)
__out[__r] = *__first;
}
return __out + _VSTD::min(__n, __k);
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n,
_UniformRandomNumberGenerator &&__g,
forward_iterator_tag) {
_Distance __unsampled_sz = _VSTD::distance(__first, __last);
for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
_Distance __r =
_VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
if (__r < __n) {
*__out++ = *__first;
--__n;
}
}
return __out;
}
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n, _UniformRandomNumberGenerator &&__g) {
typedef typename iterator_traits<_PopulationIterator>::iterator_category
_PopCategory;
typedef typename iterator_traits<_PopulationIterator>::difference_type
_Difference;
typedef typename common_type<_Distance, _Difference>::type _CommonType;
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
return _VSTD_LFTS::__sample(
__first, __last, __out, _CommonType(__n),
_VSTD::forward<_UniformRandomNumberGenerator>(__g),
_PopCategory());
} }
_LIBCPP_END_NAMESPACE_LFTS _LIBCPP_END_NAMESPACE_LFTS

View File

@@ -82,7 +82,6 @@ inline namespace fundamentals_v1 {
#include <typeinfo> #include <typeinfo>
#include <type_traits> #include <type_traits>
#include <cstdlib> #include <cstdlib>
#include <cassert>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
@@ -98,13 +97,13 @@ public:
#if _LIBCPP_STD_VER > 11 // C++ > 11 #if _LIBCPP_STD_VER > 11 // C++ > 11
_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
inline void __throw_bad_any_cast() void __throw_bad_any_cast()
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_any_cast(); throw bad_any_cast();
#else #else
assert(!"bad_any_cast"); _VSTD::abort();
#endif #endif
} }
@@ -293,7 +292,7 @@ namespace __any_imp
{ {
template <class _Tp> template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler struct _LIBCPP_TEMPLATE_VIS _SmallHandler
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this, any * __other, static void* __handle(_Action __act, any const * __this, any * __other,
@@ -374,7 +373,7 @@ namespace __any_imp
}; };
template <class _Tp> template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY _LargeHandler struct _LIBCPP_TEMPLATE_VIS _LargeHandler
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this, any * __other, static void* __handle(_Action __act, any const * __this, any * __other,

View File

@@ -11,9 +11,6 @@
#ifndef _LIBCPP_DYNARRAY #ifndef _LIBCPP_DYNARRAY
#define _LIBCPP_DYNARRAY #define _LIBCPP_DYNARRAY
#include <__config>
#if _LIBCPP_STD_VER > 11
/* /*
dynarray synopsis dynarray synopsis
@@ -96,6 +93,8 @@ public:
}} // std::experimental }} // std::experimental
*/ */
#include <__config>
#if _LIBCPP_STD_VER > 11
#include <__functional_base> #include <__functional_base>
#include <iterator> #include <iterator>
@@ -104,12 +103,6 @@ public:
#include <new> #include <new>
#include <algorithm> #include <algorithm>
#include <__undef___deallocate>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header #pragma GCC system_header
#endif #endif
@@ -117,7 +110,7 @@ public:
namespace std { namespace experimental { inline namespace __array_extensions_v1 { namespace std { namespace experimental { inline namespace __array_extensions_v1 {
template <class _Tp> template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY dynarray struct _LIBCPP_TEMPLATE_VIS dynarray
{ {
public: public:
// types: // types:
@@ -142,19 +135,14 @@ private:
static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
{ {
if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count ) if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
{ __throw_bad_array_length();
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_array_length();
#else
assert(!"dynarray::allocation");
#endif
}
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count)); return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
} }
static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept static inline _LIBCPP_INLINE_VISIBILITY void __deallocate_value( value_type* __ptr ) noexcept
{ {
_VSTD::__deallocate (static_cast<void *> (__ptr)); _VSTD::__libcpp_deallocate (static_cast<void *> (__ptr));
} }
public: public:
@@ -274,7 +262,7 @@ dynarray<_Tp>::~dynarray()
value_type *__data = data () + __size_; value_type *__data = data () + __size_;
for ( size_t i = 0; i < __size_; ++i ) for ( size_t i = 0; i < __size_; ++i )
(--__data)->value_type::~value_type(); (--__data)->value_type::~value_type();
__deallocate ( __base_ ); __deallocate_value( __base_ );
} }
template <class _Tp> template <class _Tp>
@@ -283,13 +271,8 @@ typename dynarray<_Tp>::reference
dynarray<_Tp>::at(size_type __n) dynarray<_Tp>::at(size_type __n)
{ {
if (__n >= __size_) if (__n >= __size_)
{ __throw_out_of_range("dynarray::at");
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("dynarray::at");
#else
assert(!"dynarray::at out_of_range");
#endif
}
return data()[__n]; return data()[__n];
} }
@@ -299,13 +282,8 @@ typename dynarray<_Tp>::const_reference
dynarray<_Tp>::at(size_type __n) const dynarray<_Tp>::at(size_type __n) const
{ {
if (__n >= __size_) if (__n >= __size_)
{ __throw_out_of_range("dynarray::at");
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("dynarray::at");
#else
assert(!"dynarray::at out_of_range");
#endif
}
return data()[__n]; return data()[__n];
} }
@@ -314,7 +292,7 @@ dynarray<_Tp>::at(size_type __n) const
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {}; struct _LIBCPP_TEMPLATE_VIS uses_allocator<std::experimental::dynarray<_Tp>, _Alloc> : true_type {};
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
#endif // if _LIBCPP_STD_VER > 11 #endif // if _LIBCPP_STD_VER > 11

File diff suppressed because it is too large Load Diff

View File

@@ -75,19 +75,19 @@ public:
typedef void reference; typedef void reference;
ostream_joiner(ostream_type& __os, _Delim&& __d) ostream_joiner(ostream_type& __os, _Delim&& __d)
: __out(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {} : __output(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
ostream_joiner(ostream_type& __os, const _Delim& __d) ostream_joiner(ostream_type& __os, const _Delim& __d)
: __out(_VSTD::addressof(__os)), __delim(__d), __first(true) {} : __output(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
template<typename _Tp> template<typename _Tp>
ostream_joiner& operator=(const _Tp& __v) ostream_joiner& operator=(const _Tp& __v)
{ {
if (!__first) if (!__first)
*__out << __delim; *__output << __delim;
__first = false; __first = false;
*__out << __v; *__output << __v;
return *this; return *this;
} }
@@ -96,7 +96,7 @@ public:
ostream_joiner& operator++(int) _NOEXCEPT { return *this; } ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
private: private:
ostream_type* __out; ostream_type* __output;
_Delim __delim; _Delim __delim;
bool __first; bool __first;
}; };

View File

@@ -93,7 +93,7 @@ size_t __aligned_allocation_size(size_t __s, size_t __a) _NOEXCEPT
} }
// 8.5, memory.resource // 8.5, memory.resource
class _LIBCPP_TYPE_VIS_ONLY memory_resource class _LIBCPP_TEMPLATE_VIS memory_resource
{ {
static const size_t __max_align = alignof(max_align_t); static const size_t __max_align = alignof(max_align_t);
@@ -151,7 +151,7 @@ memory_resource * set_default_resource(memory_resource * __new_res) _NOEXCEPT;
// 8.6.1, memory.polymorphic.allocator.overview // 8.6.1, memory.polymorphic.allocator.overview
template <class _ValueType> template <class _ValueType>
class _LIBCPP_TYPE_VIS_ONLY polymorphic_allocator class _LIBCPP_TEMPLATE_VIS polymorphic_allocator
{ {
public: public:
typedef _ValueType value_type; typedef _ValueType value_type;
@@ -176,15 +176,15 @@ public:
{} {}
polymorphic_allocator & polymorphic_allocator &
operator=(polymorphic_allocator const &) = default; operator=(polymorphic_allocator const &) = delete;
// 8.6.3, memory.polymorphic.allocator.mem // 8.6.3, memory.polymorphic.allocator.mem
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
_ValueType* allocate(size_t __n) { _ValueType* allocate(size_t __n) {
if (__n > max_size()) { if (__n > max_size()) {
__libcpp_throw(length_error( __throw_length_error(
"std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size")); " 'n' exceeds maximum supported size");
} }
return static_cast<_ValueType*>( return static_cast<_ValueType*>(
__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)) __res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))
@@ -334,7 +334,7 @@ bool operator!=(polymorphic_allocator<_Tp> const & __lhs,
// 8.7.1, memory.resource.adaptor.overview // 8.7.1, memory.resource.adaptor.overview
template <class _CharAlloc> template <class _CharAlloc>
class _LIBCPP_TYPE_VIS_ONLY __resource_adaptor_imp class _LIBCPP_TEMPLATE_VIS __resource_adaptor_imp
: public memory_resource : public memory_resource
{ {
using _CTraits = allocator_traits<_CharAlloc>; using _CTraits = allocator_traits<_CharAlloc>;
@@ -383,9 +383,9 @@ protected:
virtual void * do_allocate(size_t __bytes, size_t) virtual void * do_allocate(size_t __bytes, size_t)
{ {
if (__bytes > __max_size()) { if (__bytes > __max_size()) {
__libcpp_throw(length_error( __throw_length_error(
"std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)"
" 'bytes' exceeds maximum supported size")); " 'bytes' exceeds maximum supported size");
} }
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
return __alloc_.allocate(__s); return __alloc_.allocate(__s);

View File

@@ -0,0 +1,107 @@
// -*- C++ -*-
//===--------------------------- numeric ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
#define _LIBCPP_EXPERIMENTAL_NUMERIC
/*
experimental/numeric synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
// 13.1.2, Greatest common divisor
template<class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n);
// 13.1.3, Least common multiple
template<class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n);
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <numeric>
#include <type_traits> // is_integral
#include <limits> // numeric_limits
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 11
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
template <typename _Tp, bool _IsSigned = is_signed<_Tp>::value> struct __abs;
template <typename _Tp>
struct __abs<_Tp, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp operator()(_Tp __t) const noexcept { return __t >= 0 ? __t : -__t; }
};
template <typename _Tp>
struct __abs<_Tp, false> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp operator()(_Tp __t) const noexcept { return __t; }
};
template<class _Tp>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "" );
return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
common_type_t<_Tp,_Up>
gcd(_Tp __m, _Up __n)
{
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
using _Rp = common_type_t<_Tp,_Up>;
using _Wp = make_unsigned_t<_Rp>;
return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)),
static_cast<_Wp>(__abs<_Up>()(__n))));
}
template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
common_type_t<_Tp,_Up>
lcm(_Tp __m, _Up __n)
{
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
if (__m == 0 || __n == 0)
return 0;
using _Rp = common_type_t<_Tp,_Up>;
_Rp __val1 = __abs<_Tp>()(__m) / gcd(__m,__n);
_Up __val2 = __abs<_Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
}
_LIBCPP_END_NAMESPACE_LFTS_V2
#endif /* _LIBCPP_STD_VER > 11 */
#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */

View File

@@ -8,8 +8,8 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef _LIBCPP_OPTIONAL #ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
#define _LIBCPP_OPTIONAL #define _LIBCPP_EXPERIMENTAL_OPTIONAL
/* /*
optional synopsis optional synopsis
@@ -211,7 +211,7 @@ protected:
: __engaged_(__x.__engaged_) : __engaged_(__x.__engaged_)
{ {
if (__engaged_) if (__engaged_)
::new(_VSTD::addressof(__val_)) value_type(__x.__val_); ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -220,7 +220,7 @@ protected:
: __engaged_(__x.__engaged_) : __engaged_(__x.__engaged_)
{ {
if (__engaged_) if (__engaged_)
::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -262,7 +262,7 @@ protected:
: __engaged_(__x.__engaged_) : __engaged_(__x.__engaged_)
{ {
if (__engaged_) if (__engaged_)
::new(_VSTD::addressof(__val_)) value_type(__x.__val_); ::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -271,7 +271,7 @@ protected:
: __engaged_(__x.__engaged_) : __engaged_(__x.__engaged_)
{ {
if (__engaged_) if (__engaged_)
::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); ::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -368,7 +368,7 @@ public:
if (this->__engaged_) if (this->__engaged_)
this->__val_.~value_type(); this->__val_.~value_type();
else else
::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); ::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
this->__engaged_ = __opt.__engaged_; this->__engaged_ = __opt.__engaged_;
} }
return *this; return *this;
@@ -390,7 +390,8 @@ public:
if (this->__engaged_) if (this->__engaged_)
this->__val_.~value_type(); this->__val_.~value_type();
else else
::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); ::new((void*)_VSTD::addressof(this->__val_))
value_type(_VSTD::move(__opt.__val_));
this->__engaged_ = __opt.__engaged_; this->__engaged_ = __opt.__engaged_;
} }
return *this; return *this;
@@ -412,7 +413,7 @@ public:
this->__val_ = _VSTD::forward<_Up>(__v); this->__val_ = _VSTD::forward<_Up>(__v);
else else
{ {
::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); ::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
this->__engaged_ = true; this->__engaged_ = true;
} }
return *this; return *this;
@@ -429,7 +430,8 @@ public:
emplace(_Args&&... __args) emplace(_Args&&... __args)
{ {
*this = nullopt; *this = nullopt;
::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); ::new((void*)_VSTD::addressof(this->__val_))
value_type(_VSTD::forward<_Args>(__args)...);
this->__engaged_ = true; this->__engaged_ = true;
} }
@@ -444,7 +446,8 @@ public:
emplace(initializer_list<_Up> __il, _Args&&... __args) emplace(initializer_list<_Up> __il, _Args&&... __args)
{ {
*this = nullopt; *this = nullopt;
::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); ::new((void*)_VSTD::addressof(this->__val_))
value_type(__il, _VSTD::forward<_Args>(__args)...);
this->__engaged_ = true; this->__engaged_ = true;
} }
@@ -464,12 +467,14 @@ public:
{ {
if (this->__engaged_) if (this->__engaged_)
{ {
::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); ::new((void*)_VSTD::addressof(__opt.__val_))
value_type(_VSTD::move(this->__val_));
this->__val_.~value_type(); this->__val_.~value_type();
} }
else else
{ {
::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); ::new((void*)_VSTD::addressof(this->__val_))
value_type(_VSTD::move(__opt.__val_));
__opt.__val_.~value_type(); __opt.__val_.~value_type();
} }
swap(this->__engaged_, __opt.__engaged_); swap(this->__engaged_, __opt.__engaged_);
@@ -482,7 +487,11 @@ public:
operator->() const operator->() const
{ {
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); _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<value_type>{}); return __operator_arrow(__has_operator_addressof<value_type>{});
#endif
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -513,11 +522,21 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
constexpr explicit operator bool() const noexcept {return this->__engaged_;} constexpr explicit operator bool() const noexcept {return this->__engaged_;}
_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
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
constexpr value_type const& value() const constexpr value_type const& value() const
{ {
if (!this->__engaged_) if (!this->__engaged_)
throw bad_optional_access(); __throw_bad_optional_access();
return this->__val_; return this->__val_;
} }
@@ -525,7 +544,7 @@ public:
value_type& value() value_type& value()
{ {
if (!this->__engaged_) if (!this->__engaged_)
throw bad_optional_access(); __throw_bad_optional_access();
return this->__val_; return this->__val_;
} }
@@ -702,7 +721,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
constexpr constexpr
bool bool
operator<=(nullopt_t, const optional<_Tp>& __x) noexcept operator<=(nullopt_t, const optional<_Tp>&) noexcept
{ {
return true; return true;
} }
@@ -720,7 +739,7 @@ template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
constexpr constexpr
bool bool
operator>(nullopt_t, const optional<_Tp>& __x) noexcept operator>(nullopt_t, const optional<_Tp>&) noexcept
{ {
return false; return false;
} }
@@ -875,7 +894,7 @@ _LIBCPP_END_NAMESPACE_LFTS
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::optional<_Tp> > struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::optional<_Tp> >
{ {
typedef std::experimental::optional<_Tp> argument_type; typedef std::experimental::optional<_Tp> argument_type;
typedef size_t result_type; typedef size_t result_type;
@@ -891,4 +910,4 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 11 #endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_OPTIONAL #endif // _LIBCPP_EXPERIMENTAL_OPTIONAL

View File

@@ -0,0 +1,580 @@
// -*- C++ -*-
//===------------------------ propagate_const -----------------------------===//
//
// 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_PROPAGATE_CONST
#define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
/*
propagate_const synopsis
namespace std { namespace experimental { inline namespace fundamentals_v2 {
// [propagate_const]
template <class T> class propagate_const;
// [propagate_const.underlying], underlying pointer access
constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept;
constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept;
// [propagate_const.relational], relational operators
template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);
template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu);
template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);
template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu);
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u);
template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu);
template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu);
// [propagate_const.algorithms], specialized algorithms
template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below);
template <class T>
class propagate_const
{
public:
typedef remove_reference_t<decltype(*declval<T&>())> element_type;
// [propagate_const.ctor], constructors
constexpr propagate_const() = default;
propagate_const(const propagate_const& p) = delete;
constexpr propagate_const(propagate_const&& p) = default;
template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below
template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below
// [propagate_const.assignment], assignment
propagate_const& operator=(const propagate_const& p) = delete;
constexpr propagate_const& operator=(propagate_const&& p) = default;
template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu);
template <class U> constexpr propagate_const& operator=(U&& u); // see below
// [propagate_const.const_observers], const observers
explicit constexpr operator bool() const;
constexpr const element_type* operator->() const;
constexpr operator const element_type*() const; // Not always defined
constexpr const element_type& operator*() const;
constexpr const element_type* get() const;
// [propagate_const.non_const_observers], non-const observers
constexpr element_type* operator->();
constexpr operator element_type*(); // Not always defined
constexpr element_type& operator*();
constexpr element_type* get();
// [propagate_const.modifiers], modifiers
constexpr void swap(propagate_const& pt) noexcept(see below)
private:
T t_; // exposition only
};
} // namespace fundamentals_v2
} // namespace experimental
// [propagate_const.hash], hash support
template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>;
// [propagate_const.comparison_function_objects], comparison function objects
template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>;
template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>;
template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>;
template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>;
template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>;
template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>;
} // namespace std
*/
#include <experimental/__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#if _LIBCPP_STD_VER > 11
#include <type_traits>
#include <utility>
#include <functional>
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
template <class _Tp>
class propagate_const;
template <class _Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Up>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
_Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Tp>
class propagate_const
{
public:
typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type;
static_assert(!is_array<_Tp>::value,
"Instantiation of propagate_const with an array type is ill-formed.");
static_assert(!is_reference<_Tp>::value,
"Instantiation of propagate_const with a reference type is ill-formed.");
static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value),
"Instantiation of propagate_const with a function-pointer type is ill-formed.");
static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value),
"Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
private:
template <class _Up>
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u)
{
return __u;
}
template <class _Up>
static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u)
{
return __get_pointer(__u.get());
}
template <class _Up>
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u)
{
return __u;
}
template <class _Up>
static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u)
{
return __get_pointer(__u.get());
}
template <class _Up>
struct __is_propagate_const : false_type
{
};
template <class _Up>
struct __is_propagate_const<propagate_const<_Up>> : true_type
{
};
_Tp __t_;
public:
template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
_LIBCPP_CONSTEXPR propagate_const() = default;
propagate_const(const propagate_const&) = delete;
_LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default;
template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value &&
is_constructible<_Tp, _Up&&>::value,bool> = true>
explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
{
}
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
is_constructible<_Tp, _Up&&>::value,bool> = false>
_LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
: __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu)))
{
}
template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value &&
is_constructible<_Tp, _Up&&>::value &&
!__is_propagate_const<decay_t<_Up>>::value,bool> = true>
explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
: __t_(std::forward<_Up>(__u))
{
}
template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value &&
is_constructible<_Tp, _Up&&>::value &&
!__is_propagate_const<decay_t<_Up>>::value,bool> = false>
_LIBCPP_CONSTEXPR propagate_const(_Up&& __u)
: __t_(std::forward<_Up>(__u))
{
}
propagate_const& operator=(const propagate_const&) = delete;
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default;
template <class _Up>
_LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu)
{
__t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu));
return *this;
}
template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>>
_LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u)
{
__t_ = std::forward<_Up>(__u);
return *this;
}
_LIBCPP_CONSTEXPR const element_type* get() const
{
return __get_pointer(__t_);
}
_LIBCPP_CONSTEXPR element_type* get()
{
return __get_pointer(__t_);
}
explicit _LIBCPP_CONSTEXPR operator bool() const
{
return get() != nullptr;
}
_LIBCPP_CONSTEXPR const element_type* operator->() const
{
return get();
}
template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible<
const _Tp_, const element_type *>::value>>
_LIBCPP_CONSTEXPR operator const element_type *() const {
return get();
}
_LIBCPP_CONSTEXPR const element_type& operator*() const
{
return *get();
}
_LIBCPP_CONSTEXPR element_type* operator->()
{
return get();
}
template <class _Tp_ = _Tp, class _Up = enable_if_t<
is_convertible<_Tp_, element_type *>::value>>
_LIBCPP_CONSTEXPR operator element_type *() {
return get();
}
_LIBCPP_CONSTEXPR element_type& operator*()
{
return *get();
}
_LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
{
using _VSTD::swap;
swap(__t_, __pt.__t_);
}
};
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t)
{
return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr;
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt)
{
return nullptr == _VSTD_LFTS_V2::get_underlying(__pt);
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t)
{
return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr;
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt)
{
return nullptr != _VSTD_LFTS_V2::get_underlying(__pt);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt,
const propagate_const<_Up>& __pu)
{
return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) == __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) != __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) < __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) > __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) <= __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u)
{
return _VSTD_LFTS_V2::get_underlying(__pt) >= __u;
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t == _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t != _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t < _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t > _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t <= _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu)
{
return __t >= _VSTD_LFTS_V2::get_underlying(__pu);
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value)
{
using _VSTD::swap;
swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
template <class _Tp>
_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT
{
return __pt.__t_;
}
template <class _Tp>
_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT
{
return __pt.__t_;
}
_LIBCPP_END_NAMESPACE_LFTS_V2
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
struct hash<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef size_t result_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type;
size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const
{
return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1));
}
};
template <class _Tp>
struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
template <class _Tp>
struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
template <class _Tp>
struct less<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
template <class _Tp>
struct greater<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
template <class _Tp>
struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
template <class _Tp>
struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>>
{
typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type;
typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type;
bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1,
const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const
{
return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2));
}
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER > 11
#endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST

View File

@@ -180,6 +180,7 @@ namespace std {
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <ostream> #include <ostream>
#include <stdexcept>
#include <iomanip> #include <iomanip>
#include <__debug> #include <__debug>
@@ -191,7 +192,7 @@ namespace std {
_LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_LFTS
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> > template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_string_view { class _LIBCPP_TEMPLATE_VIS basic_string_view {
public: public:
// types // types
typedef _Traits traits_type; typedef _Traits traits_type;
@@ -280,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
const_reference at(size_type __pos) const const_reference at(size_type __pos) const
{ {
return __pos >= size() return __pos >= size()
? (throw out_of_range("string_view::at"), __data[0]) ? (__throw_out_of_range("string_view::at"), __data[0])
: __data[__pos]; : __data[__pos];
} }
@@ -351,7 +352,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{ {
if ( __pos > size()) if ( __pos > size())
throw out_of_range("string_view::copy"); __throw_out_of_range("string_view::copy");
size_type __rlen = _VSTD::min( __n, size() - __pos ); size_type __rlen = _VSTD::min( __n, size() - __pos );
_VSTD::copy_n(begin() + __pos, __rlen, __s ); _VSTD::copy_n(begin() + __pos, __rlen, __s );
return __rlen; return __rlen;
@@ -361,11 +362,11 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
{ {
// if (__pos > size()) // if (__pos > size())
// throw out_of_range("string_view::substr"); // __throw_out_of_range("string_view::substr");
// size_type __rlen = _VSTD::min( __n, size() - __pos ); // size_type __rlen = _VSTD::min( __n, size() - __pos );
// return basic_string_view(data() + __pos, __rlen); // return basic_string_view(data() + __pos, __rlen);
return __pos > size() return __pos > size()
? throw out_of_range("string_view::substr") ? (__throw_out_of_range("string_view::substr"), basic_string_view())
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
} }
@@ -782,7 +783,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [string.view.hash] // [string.view.hash]
// Shamelessly stolen from <string> // Shamelessly stolen from <string>
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
struct _LIBCPP_TYPE_VIS_ONLY hash<std::experimental::basic_string_view<_CharT, _Traits> > struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::basic_string_view<_CharT, _Traits> >
: public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t> : public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
{ {
size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT; size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;

View File

@@ -172,6 +172,45 @@ inline namespace fundamentals_v1 {
template <class T> template <class T>
using raw_invocation_type_t = typename raw_invocation_type<T>::type; using raw_invocation_type_t = typename raw_invocation_type<T>::type;
// 3.3.3, Logical operator traits
template<class... B> struct conjunction;
template<class... B> constexpr bool conjunction_v = conjunction<B...>::value;
template<class... B> struct disjunction;
template<class... B> constexpr bool disjunction_v = disjunction<B...>::value;
template<class B> struct negation;
template<class B> constexpr bool negation_v = negation<B>::value;
// 3.3.4, Detection idiom
template <class...> using void_t = void;
struct nonesuch {
nonesuch() = delete;
~nonesuch() = delete;
nonesuch(nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
};
template <template<class...> class Op, class... Args>
using is_detected = see below;
template <template<class...> class Op, class... Args>
constexpr bool is_detected_v = is_detected<Op, Args...>::value;
template <template<class...> class Op, class... Args>
using detected_t = see below;
template <class Default, template<class...> class Op, class... Args>
using detected_or = see below;
template <class Default, template<class...> class Op, class... Args>
using detected_or_t = typename detected_or<Default, Op, Args...>::type;
template <class Expected, template<class...> class Op, class... Args>
using is_detected_exact = is_same<Expected, detected_t<Op, Args...>>;
template <class Expected, template<class...> class Op, class... Args>
constexpr bool is_detected_exact_v
= is_detected_exact<Expected, Op, Args...>::value;
template <class To, template<class...> class Op, class... Args>
using is_detected_convertible = is_convertible<detected_t<Op, Args...>, To>;
template <class To, template<class...> class Op, class... Args>
constexpr bool is_detected_convertible_v
= is_detected_convertible<To, Op, Args...>::value;
} // namespace fundamentals_v1 } // namespace fundamentals_v1
} // namespace experimental } // namespace experimental
} // namespace std } // namespace std
@@ -402,16 +441,16 @@ template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
// 3.3.2, Other type transformations // 3.3.2, Other type transformations
/* /*
template <class> template <class>
class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type; class _LIBCPP_TEMPLATE_VIS raw_invocation_type;
template <class _Fn, class ..._Args> template <class _Fn, class ..._Args>
class _LIBCPP_TYPE_VIS_ONLY raw_invocation_type<_Fn(_Args...)>; class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>;
template <class> template <class>
class _LIBCPP_TYPE_VIS_ONLY invokation_type; class _LIBCPP_TEMPLATE_VIS invokation_type;
template <class _Fn, class ..._Args> template <class _Fn, class ..._Args>
class _LIBCPP_TYPE_VIS_ONLY invokation_type<_Fn(_Args...)>; class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>;
template <class _Tp> template <class _Tp>
using invokation_type_t = typename invokation_type<_Tp>::type; using invokation_type_t = typename invokation_type<_Tp>::type;
@@ -420,6 +459,70 @@ template <class _Tp>
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type; using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
*/ */
// 3.3.3, Logical operator traits
template <class...> using void_t = void;
template <class... _Args>
struct conjunction : _VSTD::__and_<_Args...> {};
template <class... _Args>
_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value;
template <class... _Args>
struct disjunction : _VSTD::__or_<_Args...> {};
template <class... _Args>
_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value;
template <class _Tp>
struct negation : _VSTD::__not_<_Tp> {};
template<class _Tp>
_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value;
// 3.3.4, Detection idiom
template <class...> using void_t = void;
struct nonesuch {
nonesuch() = delete;
~nonesuch() = delete;
nonesuch (nonesuch const&) = delete;
void operator=(nonesuch const&) = delete;
};
template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
struct _DETECTOR {
using value_t = false_type;
using type = _Default;
};
template <class _Default, template <class...> class _Op, class... _Args>
struct _DETECTOR<_Default, void_t<_Op<_Args...>>, _Op, _Args...> {
using value_t = true_type;
using type = _Op<_Args...>;
};
template <template<class...> class _Op, class... _Args>
using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
template <template<class...> class _Op, class... _Args>
using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type;
template <template<class...> class _Op, class... _Args>
_LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value;
template <class Default, template<class...> class _Op, class... _Args>
using detected_or = _DETECTOR<Default, void, _Op, _Args...>;
template <class Default, template<class...> class _Op, class... _Args>
using detected_or_t = typename detected_or<Default, _Op, _Args...>::type;
template <class Expected, template<class...> class _Op, class... _Args>
using is_detected_exact = is_same<Expected, detected_t<_Op, _Args...>>;
template <class Expected, template<class...> class _Op, class... _Args>
_LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<Expected, _Op, _Args...>::value;
template <class To, template<class...> class _Op, class... _Args>
using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, To>;
template <class To, template<class...> class _Op, class... _Args>
_LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<To, _Op, _Args...>::value;
_LIBCPP_END_NAMESPACE_LFTS _LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_STD_VER > 11 */ #endif /* _LIBCPP_STD_VER > 11 */

View File

@@ -40,7 +40,7 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_LFTS
struct _LIBCPP_TYPE_VIS_ONLY erased_type { }; struct _LIBCPP_TEMPLATE_VIS erased_type { };
_LIBCPP_END_NAMESPACE_LFTS _LIBCPP_END_NAMESPACE_LFTS

View File

@@ -19,9 +19,9 @@
namespace __gnu_cxx { namespace __gnu_cxx {
using namespace std; using namespace std;
template <typename _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash { }; template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*> template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
: public unary_function<const char*, size_t> : public unary_function<const char*, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -31,7 +31,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *> template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
: public unary_function<char*, size_t> : public unary_function<char*, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -41,7 +41,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char> template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
: public unary_function<char, size_t> : public unary_function<char, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -51,7 +51,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<signed char> template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
: public unary_function<signed char, size_t> : public unary_function<signed char, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -61,7 +61,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<signed char>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
: public unary_function<unsigned char, size_t> : public unary_function<unsigned char, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -71,7 +71,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<short> template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
: public unary_function<short, size_t> : public unary_function<short, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -81,7 +81,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<short>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
: public unary_function<unsigned short, size_t> : public unary_function<unsigned short, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -91,7 +91,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<int> template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
: public unary_function<int, size_t> : public unary_function<int, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -101,7 +101,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<int>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
: public unary_function<unsigned int, size_t> : public unary_function<unsigned int, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -111,7 +111,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<long> template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
: public unary_function<long, size_t> : public unary_function<long, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -121,7 +121,7 @@ template <> struct _LIBCPP_TYPE_VIS_ONLY hash<long>
} }
}; };
template <> struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
: public unary_function<unsigned long, size_t> : public unary_function<unsigned long, size_t>
{ {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY

View File

@@ -364,7 +364,7 @@ public:
}; };
template <class _HashIterator> template <class _HashIterator>
class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator class _LIBCPP_TEMPLATE_VIS __hash_map_iterator
{ {
_HashIterator __i_; _HashIterator __i_;
@@ -401,15 +401,15 @@ public:
bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ != __y.__i_;} {return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;
}; };
template <class _HashIterator> template <class _HashIterator>
class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
{ {
_HashIterator __i_; _HashIterator __i_;
@@ -454,15 +454,15 @@ public:
bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
{return __x.__i_ != __y.__i_;} {return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_map;
template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS hash_multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
}; };
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > > class _Alloc = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY hash_map class _LIBCPP_TEMPLATE_VIS hash_map
{ {
public: public:
// types // types
@@ -736,7 +736,7 @@ operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > > class _Alloc = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY hash_multimap class _LIBCPP_TEMPLATE_VIS hash_multimap
{ {
public: public:
// types // types

View File

@@ -212,7 +212,7 @@ using namespace std;
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> > class _Alloc = allocator<_Value> >
class _LIBCPP_TYPE_VIS_ONLY hash_set class _LIBCPP_TEMPLATE_VIS hash_set
{ {
public: public:
// types // types
@@ -434,7 +434,7 @@ operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> > class _Alloc = allocator<_Value> >
class _LIBCPP_TYPE_VIS_ONLY hash_multiset class _LIBCPP_TEMPLATE_VIS hash_multiset
{ {
public: public:
// types // types

View File

@@ -87,7 +87,7 @@ public:
reference front(); reference front();
const_reference front() const; const_reference front() const;
template <class... Args> void emplace_front(Args&&... args); template <class... Args> reference emplace_front(Args&&... args); // reference in C++17
void push_front(const value_type& v); void push_front(const value_type& v);
void push_front(value_type&& v); void push_front(value_type&& v);
@@ -266,11 +266,11 @@ struct __forward_list_node
}; };
template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY forward_list; template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS forward_list;
template<class _NodeConstPtr> class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template<class _NodeConstPtr> class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;
template <class _NodePtr> template <class _NodePtr>
class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator class _LIBCPP_TEMPLATE_VIS __forward_list_iterator
{ {
typedef __forward_node_traits<_NodePtr> __traits; typedef __forward_node_traits<_NodePtr> __traits;
typedef typename __traits::__node_pointer __node_pointer; typedef typename __traits::__node_pointer __node_pointer;
@@ -302,8 +302,8 @@ class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator
explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
: __ptr_(__traits::__as_iter_node(__p)) {} : __ptr_(__traits::__as_iter_node(__p)) {}
template<class, class> friend class _LIBCPP_TYPE_VIS_ONLY forward_list; template<class, class> friend class _LIBCPP_TEMPLATE_VIS forward_list;
template<class> friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template<class> friend class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;
public: public:
typedef forward_iterator_tag iterator_category; typedef forward_iterator_tag iterator_category;
@@ -348,7 +348,7 @@ public:
}; };
template <class _NodeConstPtr> template <class _NodeConstPtr>
class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator
{ {
static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), ""); static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), "");
typedef _NodeConstPtr _NodePtr; typedef _NodeConstPtr _NodePtr;
@@ -531,7 +531,7 @@ private:
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__forward_list_base& __x, false_type) _NOEXCEPT void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT
{} {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__forward_list_base& __x, true_type) void __move_assign_alloc(__forward_list_base& __x, true_type)
@@ -604,7 +604,7 @@ __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT
} }
template <class _Tp, class _Alloc /*= allocator<_Tp>*/> template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY forward_list class _LIBCPP_TEMPLATE_VIS forward_list
: private __forward_list_base<_Tp, _Alloc> : private __forward_list_base<_Tp, _Alloc>
{ {
typedef __forward_list_base<_Tp, _Alloc> base; typedef __forward_list_base<_Tp, _Alloc> base;
@@ -734,8 +734,11 @@ public:
bool empty() const _NOEXCEPT bool empty() const _NOEXCEPT
{return base::__before_begin()->__next_ == nullptr;} {return base::__before_begin()->__next_ == nullptr;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT size_type max_size() const _NOEXCEPT {
{return numeric_limits<size_type>::max();} return std::min<size_type>(
__node_traits::max_size(base::__alloc()),
numeric_limits<difference_type>::max());
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
reference front() {return base::__before_begin()->__next_->__value_;} reference front() {return base::__before_begin()->__next_->__value_;}
@@ -744,7 +747,11 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
#if _LIBCPP_STD_VER > 14
template <class... _Args> reference emplace_front(_Args&&... __args);
#else
template <class... _Args> void emplace_front(_Args&&... __args); template <class... _Args> void emplace_front(_Args&&... __args);
#endif
#endif #endif
void push_front(value_type&& __v); void push_front(value_type&& __v);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -873,8 +880,9 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n)
#if _LIBCPP_STD_VER > 11 #if _LIBCPP_STD_VER > 11
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) forward_list<_Tp, _Alloc>::forward_list(size_type __n,
: base ( __a ) const allocator_type& __base_alloc)
: base ( __base_alloc )
{ {
if (__n > 0) if (__n > 0)
{ {
@@ -1099,7 +1107,11 @@ forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il)
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
typename forward_list<_Tp, _Alloc>::reference
#else
void void
#endif
forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
{ {
__node_allocator& __a = base::__alloc(); __node_allocator& __a = base::__alloc();
@@ -1109,6 +1121,9 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
_VSTD::forward<_Args>(__args)...); _VSTD::forward<_Args>(__args)...);
__h->__next_ = base::__before_begin()->__next_; __h->__next_ = base::__before_begin()->__next_;
base::__before_begin()->__next_ = __h.release(); base::__before_begin()->__next_ = __h.release();
#if _LIBCPP_STD_VER > 14
return base::__before_begin()->__next_->__value_;
#endif
} }
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
@@ -1421,7 +1436,7 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
void void
forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
forward_list& __x, forward_list& /*__other*/,
const_iterator __i) const_iterator __i)
{ {
const_iterator __lm1 = _VSTD::next(__i); const_iterator __lm1 = _VSTD::next(__i);
@@ -1436,7 +1451,7 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
void void
forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
forward_list& __x, forward_list& /*__other*/,
const_iterator __f, const_iterator __l) const_iterator __f, const_iterator __l)
{ {
if (__f != __l && __p != __f) if (__f != __l && __p != __f)

View File

@@ -180,7 +180,7 @@ typedef basic_fstream<wchar_t> wfstream;
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_filebuf class _LIBCPP_TEMPLATE_VIS basic_filebuf
: public basic_streambuf<_CharT, _Traits> : public basic_streambuf<_CharT, _Traits>
{ {
public: public:
@@ -606,6 +606,8 @@ basic_filebuf<_CharT, _Traits>::underflow()
} }
else else
{ {
_LIBCPP_ASSERT ( !(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
if (__extbufend_ != __extbufnext_)
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
@@ -616,10 +618,9 @@ basic_filebuf<_CharT, _Traits>::underflow()
size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_); size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
if (__nr != 0) if (__nr != 0)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_) if (!__cv_)
throw bad_cast(); __throw_bad_cast();
#endif
__extbufend_ = __extbufnext_ + __nr; __extbufend_ = __extbufnext_ + __nr;
char_type* __inext; char_type* __inext;
__r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_, __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
@@ -698,10 +699,9 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
codecvt_base::result __r; codecvt_base::result __r;
do do
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_) if (!__cv_)
throw bad_cast(); __throw_bad_cast();
#endif
const char_type* __e; const char_type* __e;
__r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
__extbuf_, __extbuf_ + __ebs_, __extbe); __extbuf_, __extbuf_ + __ebs_, __extbe);
@@ -791,10 +791,9 @@ typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode) ios_base::openmode)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_) if (!__cv_)
throw bad_cast(); __throw_bad_cast();
#endif
int __width = __cv_->encoding(); int __width = __cv_->encoding();
if (__file_ == 0 || (__width <= 0 && __off != 0) || sync()) if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
return pos_type(off_type(-1)); return pos_type(off_type(-1));
@@ -814,7 +813,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
default: default:
return pos_type(off_type(-1)); return pos_type(off_type(-1));
} }
#if defined(_WIN32) || defined(_NEWLIB_VERSION) #if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence))
return pos_type(off_type(-1)); return pos_type(off_type(-1));
pos_type __r = ftell(__file_); pos_type __r = ftell(__file_);
@@ -833,7 +832,7 @@ basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
{ {
if (__file_ == 0 || sync()) if (__file_ == 0 || sync())
return pos_type(off_type(-1)); return pos_type(off_type(-1));
#if defined(_WIN32) || defined(_NEWLIB_VERSION) #if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __sp, SEEK_SET)) if (fseek(__file_, __sp, SEEK_SET))
return pos_type(off_type(-1)); return pos_type(off_type(-1));
#else #else
@@ -850,10 +849,9 @@ basic_filebuf<_CharT, _Traits>::sync()
{ {
if (__file_ == 0) if (__file_ == 0)
return 0; return 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!__cv_) if (!__cv_)
throw bad_cast(); __throw_bad_cast();
#endif
if (__cm_ & ios_base::out) if (__cm_ & ios_base::out)
{ {
if (this->pptr() != this->pbase()) if (this->pptr() != this->pbase())
@@ -898,7 +896,7 @@ basic_filebuf<_CharT, _Traits>::sync()
} }
} }
} }
#if defined(_WIN32) || defined(_NEWLIB_VERSION) #if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, -__c, SEEK_CUR)) if (fseek(__file_, -__c, SEEK_CUR))
return -1; return -1;
#else #else
@@ -1001,7 +999,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode()
// basic_ifstream // basic_ifstream
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ifstream class _LIBCPP_TEMPLATE_VIS basic_ifstream
: public basic_istream<_CharT, _Traits> : public basic_istream<_CharT, _Traits>
{ {
public: public:
@@ -1163,7 +1161,7 @@ basic_ifstream<_CharT, _Traits>::close()
// basic_ofstream // basic_ofstream
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ofstream class _LIBCPP_TEMPLATE_VIS basic_ofstream
: public basic_ostream<_CharT, _Traits> : public basic_ostream<_CharT, _Traits>
{ {
public: public:
@@ -1323,7 +1321,7 @@ basic_ofstream<_CharT, _Traits>::close()
// basic_fstream // basic_fstream
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_fstream class _LIBCPP_TEMPLATE_VIS basic_fstream
: public basic_iostream<_CharT, _Traits> : public basic_iostream<_CharT, _Traits>
{ {
public: public:

File diff suppressed because it is too large Load Diff

View File

@@ -50,7 +50,7 @@ class future_error
{ {
public: public:
future_error(error_code ec); // exposition only future_error(error_code ec); // exposition only
explicit future_error(future_errc); // C++17
const error_code& code() const noexcept; const error_code& code() const noexcept;
const char* what() const noexcept; const char* what() const noexcept;
}; };
@@ -156,7 +156,7 @@ public:
~future(); ~future();
future& operator=(const future& rhs) = delete; future& operator=(const future& rhs) = delete;
future& operator=(future&&) noexcept; future& operator=(future&&) noexcept;
shared_future<R> share(); shared_future<R> share() noexcept;
// retrieving the value // retrieving the value
R get(); R get();
@@ -183,7 +183,7 @@ public:
~future(); ~future();
future& operator=(const future& rhs) = delete; future& operator=(const future& rhs) = delete;
future& operator=(future&&) noexcept; future& operator=(future&&) noexcept;
shared_future<R&> share(); shared_future<R&> share() noexcept;
// retrieving the value // retrieving the value
R& get(); R& get();
@@ -210,7 +210,7 @@ public:
~future(); ~future();
future& operator=(const future& rhs) = delete; future& operator=(const future& rhs) = delete;
future& operator=(future&&) noexcept; future& operator=(future&&) noexcept;
shared_future<void> share(); shared_future<void> share() noexcept;
// retrieving the value // retrieving the value
void get(); void get();
@@ -322,7 +322,7 @@ template <class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)> class packaged_task<R(ArgTypes...)>
{ {
public: public:
typedef R result_type; typedef R result_type; // extension
// construction and destruction // construction and destruction
packaged_task() noexcept; packaged_task() noexcept;
@@ -391,11 +391,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc)
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
template <> template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc> : public true_type {}; struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
template <> template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc::__lx> : public true_type { }; struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { };
#endif #endif
//enum class launch //enum class launch
@@ -505,20 +505,23 @@ class _LIBCPP_EXCEPTION_ABI future_error
error_code __ec_; error_code __ec_;
public: public:
future_error(error_code __ec); 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 _LIBCPP_INLINE_VISIBILITY
const error_code& code() const _NOEXCEPT {return __ec_;} const error_code& code() const _NOEXCEPT {return __ec_;}
virtual ~future_error() _NOEXCEPT; virtual ~future_error() _NOEXCEPT;
}; };
inline _LIBCPP_ALWAYS_INLINE _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_future_error(future_errc _Ev) void __throw_future_error(future_errc _Ev)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
throw future_error(make_error_code(_Ev)); throw future_error(make_error_code(_Ev));
#else #else
assert(!"future_error"); ((void)_Ev);
_VSTD::abort();
#endif #endif
} }
@@ -1048,12 +1051,12 @@ __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT
base::__on_zero_shared(); base::__on_zero_shared();
} }
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY promise; template <class _Rp> class _LIBCPP_TEMPLATE_VIS promise;
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY shared_future; template <class _Rp> class _LIBCPP_TEMPLATE_VIS shared_future;
// future // future
template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY future; template <class _Rp> class _LIBCPP_TEMPLATE_VIS future;
template <class _Rp, class _Fp> template <class _Rp, class _Fp>
future<_Rp> future<_Rp>
@@ -1072,7 +1075,7 @@ __make_async_assoc_state(_Fp __f);
#endif #endif
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY future class _LIBCPP_TEMPLATE_VIS future
{ {
__assoc_state<_Rp>* __state_; __assoc_state<_Rp>* __state_;
@@ -1116,7 +1119,7 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~future(); ~future();
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future<_Rp> share(); shared_future<_Rp> share() _NOEXCEPT;
// retrieving the value // retrieving the value
_Rp get(); _Rp get();
@@ -1175,7 +1178,7 @@ future<_Rp>::get()
} }
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY future<_Rp&> class _LIBCPP_TEMPLATE_VIS future<_Rp&>
{ {
__assoc_state<_Rp&>* __state_; __assoc_state<_Rp&>* __state_;
@@ -1219,7 +1222,7 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~future(); ~future();
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future<_Rp&> share(); shared_future<_Rp&> share() _NOEXCEPT;
// retrieving the value // retrieving the value
_Rp& get(); _Rp& get();
@@ -1317,7 +1320,7 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~future(); ~future();
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future<void> share(); shared_future<void> share() _NOEXCEPT;
// retrieving the value // retrieving the value
void get(); void get();
@@ -1356,7 +1359,7 @@ swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT
template <class _Callable> class packaged_task; template <class _Callable> class packaged_task;
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY promise class _LIBCPP_TEMPLATE_VIS promise
{ {
__assoc_state<_Rp>* __state_; __assoc_state<_Rp>* __state_;
@@ -1514,6 +1517,7 @@ template <class _Rp>
void void
promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) 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) if (__state_ == nullptr)
__throw_future_error(future_errc::no_state); __throw_future_error(future_errc::no_state);
__state_->set_exception_at_thread_exit(__p); __state_->set_exception_at_thread_exit(__p);
@@ -1522,7 +1526,7 @@ promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p)
// promise<R&> // promise<R&>
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY promise<_Rp&> class _LIBCPP_TEMPLATE_VIS promise<_Rp&>
{ {
__assoc_state<_Rp&>* __state_; __assoc_state<_Rp&>* __state_;
@@ -1649,6 +1653,7 @@ template <class _Rp>
void void
promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) 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) if (__state_ == nullptr)
__throw_future_error(future_errc::no_state); __throw_future_error(future_errc::no_state);
__state_->set_exception_at_thread_exit(__p); __state_->set_exception_at_thread_exit(__p);
@@ -1732,7 +1737,7 @@ swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT
} }
template <class _Rp, class _Alloc> template <class _Rp, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<promise<_Rp>, _Alloc> struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc>
: public true_type {}; : public true_type {};
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1993,10 +1998,10 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) cons
} }
template<class _Rp, class ..._ArgTypes> template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)> class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)>
{ {
public: public:
typedef _Rp result_type; typedef _Rp result_type; // extension
private: private:
__packaged_task_function<result_type(_ArgTypes...)> __f_; __packaged_task_function<result_type(_ArgTypes...)> __f_;
@@ -2122,10 +2127,10 @@ packaged_task<_Rp(_ArgTypes...)>::reset()
} }
template<class ..._ArgTypes> template<class ..._ArgTypes>
class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)> class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)>
{ {
public: public:
typedef void result_type; typedef void result_type; // extension
private: private:
__packaged_task_function<result_type(_ArgTypes...)> __f_; __packaged_task_function<result_type(_ArgTypes...)> __f_;
@@ -2261,7 +2266,7 @@ swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT
} }
template <class _Callable, class _Alloc> template <class _Callable, class _Alloc>
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<packaged_task<_Callable>, _Alloc> struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc>
: public true_type {}; : public true_type {};
template <class _Rp, class _Fp> template <class _Rp, class _Fp>
@@ -2362,7 +2367,7 @@ async(_Fp&& __f, _Args&&... __args)
// shared_future // shared_future
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY shared_future class _LIBCPP_TEMPLATE_VIS shared_future
{ {
__assoc_state<_Rp>* __state_; __assoc_state<_Rp>* __state_;
@@ -2370,7 +2375,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future() _NOEXCEPT : __state_(nullptr) {} shared_future() _NOEXCEPT : __state_(nullptr) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future(const shared_future& __rhs) : __state_(__rhs.__state_) shared_future(const shared_future& __rhs) _NOEXCEPT : __state_(__rhs.__state_)
{if (__state_) __state_->__add_shared();} {if (__state_) __state_->__add_shared();}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -2381,7 +2386,7 @@ public:
{__rhs.__state_ = nullptr;} {__rhs.__state_ = nullptr;}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
~shared_future(); ~shared_future();
shared_future& operator=(const shared_future& __rhs); shared_future& operator=(const shared_future& __rhs) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
shared_future& operator=(shared_future&& __rhs) _NOEXCEPT shared_future& operator=(shared_future&& __rhs) _NOEXCEPT
@@ -2425,7 +2430,7 @@ shared_future<_Rp>::~shared_future()
template <class _Rp> template <class _Rp>
shared_future<_Rp>& shared_future<_Rp>&
shared_future<_Rp>::operator=(const shared_future& __rhs) shared_future<_Rp>::operator=(const shared_future& __rhs) _NOEXCEPT
{ {
if (__rhs.__state_) if (__rhs.__state_)
__rhs.__state_->__add_shared(); __rhs.__state_->__add_shared();
@@ -2436,7 +2441,7 @@ shared_future<_Rp>::operator=(const shared_future& __rhs)
} }
template <class _Rp> template <class _Rp>
class _LIBCPP_TYPE_VIS_ONLY shared_future<_Rp&> class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&>
{ {
__assoc_state<_Rp&>* __state_; __assoc_state<_Rp&>* __state_;
@@ -2575,7 +2580,7 @@ swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT
template <class _Rp> template <class _Rp>
inline inline
shared_future<_Rp> shared_future<_Rp>
future<_Rp>::share() future<_Rp>::share() _NOEXCEPT
{ {
return shared_future<_Rp>(_VSTD::move(*this)); return shared_future<_Rp>(_VSTD::move(*this));
} }
@@ -2583,7 +2588,7 @@ future<_Rp>::share()
template <class _Rp> template <class _Rp>
inline inline
shared_future<_Rp&> shared_future<_Rp&>
future<_Rp&>::share() future<_Rp&>::share() _NOEXCEPT
{ {
return shared_future<_Rp&>(_VSTD::move(*this)); return shared_future<_Rp&>(_VSTD::move(*this));
} }
@@ -2592,7 +2597,7 @@ future<_Rp&>::share()
inline inline
shared_future<void> shared_future<void>
future<void>::share() future<void>::share() _NOEXCEPT
{ {
return shared_future<void>(_VSTD::move(*this)); return shared_future<void>(_VSTD::move(*this));
} }

View File

@@ -56,7 +56,7 @@ namespace std // purposefully not versioned
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
template<class _Ep> template<class _Ep>
class _LIBCPP_TYPE_VIS_ONLY initializer_list class _LIBCPP_TEMPLATE_VIS initializer_list
{ {
const _Ep* __begin_; const _Ep* __begin_;
size_t __size_; size_t __size_;

View File

@@ -237,6 +237,13 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
#pragma GCC system_header #pragma GCC system_header
#endif #endif
/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
for C++11 unless __STDC_FORMAT_MACROS is defined
*/
#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS
#endif
#include_next <inttypes.h> #include_next <inttypes.h>
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -44,6 +44,7 @@ template <class charT, class traits, class Allocator>
*/ */
#include <__config> #include <__config>
#include <__string>
#include <istream> #include <istream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -512,8 +513,6 @@ put_time(const tm* __tm, const _CharT* __fmt)
return __iom_t10<_CharT>(__tm, __fmt); return __iom_t10<_CharT>(__tm, __fmt);
} }
#if _LIBCPP_STD_VER > 11
template <class _CharT, class _Traits, class _ForwardIterator> template <class _CharT, class _Traits, class _ForwardIterator>
std::basic_ostream<_CharT, _Traits> & std::basic_ostream<_CharT, _Traits> &
__quoted_output ( basic_ostream<_CharT, _Traits> &__os, __quoted_output ( basic_ostream<_CharT, _Traits> &__os,
@@ -569,19 +568,6 @@ __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _Char
} }
template <class _CharT, class _Iter, class _Traits=char_traits<_CharT>>
struct __quoted_output_proxy
{
_Iter __first;
_Iter __last;
_CharT __delim;
_CharT __escape;
__quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e)
: __first(__f), __last(__l), __delim(__d), __escape(__e) {}
// This would be a nice place for a string_ref
};
template <class _CharT, class _Traits, class _Iter> template <class _CharT, class _Traits, class _Iter>
basic_ostream<_CharT, _Traits>& operator<<( basic_ostream<_CharT, _Traits>& operator<<(
basic_ostream<_CharT, _Traits>& __os, basic_ostream<_CharT, _Traits>& __os,
@@ -631,10 +617,11 @@ quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_Char
return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape );
} }
template <class _CharT, class _Traits, class _Allocator> template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) __quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{ {
return __quoted_output_proxy<_CharT, return __quoted_output_proxy<_CharT,
typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
@@ -642,10 +629,39 @@ quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim =
} }
template <class _CharT, class _Traits, class _Allocator> template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY
__quoted_proxy<_CharT, _Traits, _Allocator>
__quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{
return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape );
}
#if _LIBCPP_STD_VER > 11
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY
__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator>
quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{
return __quoted(__s, __delim, __escape);
}
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY
__quoted_proxy<_CharT, _Traits, _Allocator> __quoted_proxy<_CharT, _Traits, _Allocator>
quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{ {
return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); return __quoted(__s, __delim, __escape);
}
template <class _CharT, class _Traits>
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
quoted (basic_string_view <_CharT, _Traits> __sv,
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
} }
#endif #endif

View File

@@ -393,11 +393,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc)
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
template <> template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { }; struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { };
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
template <> template <>
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { }; struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { };
#endif #endif
_LIBCPP_FUNC_VIS _LIBCPP_FUNC_VIS
@@ -572,8 +572,15 @@ ios_base::exceptions(iostate __iostate)
clear(__rdstate_); clear(__rdstate_);
} }
#if defined(_LIBCPP_CXX03_LANG)
struct _LIBCPP_TYPE_VIS __cxx03_bool {
typedef void (__cxx03_bool::*__bool_type)();
void __true_value() {}
};
#endif
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_ios class _LIBCPP_TEMPLATE_VIS basic_ios
: public ios_base : public ios_base
{ {
public: public:
@@ -585,9 +592,19 @@ public:
typedef typename traits_type::pos_type pos_type; typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type; typedef typename traits_type::off_type off_type;
// __true_value will generate undefined references when linking unless
// we give it internal linkage.
#if defined(_LIBCPP_CXX03_LANG)
_LIBCPP_ALWAYS_INLINE _LIBCPP_ALWAYS_INLINE
_LIBCPP_EXPLICIT operator __cxx03_bool::__bool_type() const {
operator bool() const {return !fail();} return !fail() ? &__cxx03_bool::__true_value : nullptr;
}
#else
_LIBCPP_ALWAYS_INLINE
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
#endif
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}

View File

@@ -97,47 +97,47 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS ios_base; class _LIBCPP_TYPE_VIS ios_base;
template<class _CharT> struct _LIBCPP_TYPE_VIS_ONLY char_traits; template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY allocator; template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_ios; class _LIBCPP_TEMPLATE_VIS basic_ios;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_streambuf; class _LIBCPP_TEMPLATE_VIS basic_streambuf;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_istream; class _LIBCPP_TEMPLATE_VIS basic_istream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_ostream; class _LIBCPP_TEMPLATE_VIS basic_ostream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_iostream; class _LIBCPP_TEMPLATE_VIS basic_iostream;
template <class _CharT, class _Traits = char_traits<_CharT>, template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class _Allocator = allocator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf; class _LIBCPP_TEMPLATE_VIS basic_stringbuf;
template <class _CharT, class _Traits = char_traits<_CharT>, template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class _Allocator = allocator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_istringstream; class _LIBCPP_TEMPLATE_VIS basic_istringstream;
template <class _CharT, class _Traits = char_traits<_CharT>, template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class _Allocator = allocator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream; class _LIBCPP_TEMPLATE_VIS basic_ostringstream;
template <class _CharT, class _Traits = char_traits<_CharT>, template <class _CharT, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class _Allocator = allocator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_stringstream; class _LIBCPP_TEMPLATE_VIS basic_stringstream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_filebuf; class _LIBCPP_TEMPLATE_VIS basic_filebuf;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_ifstream; class _LIBCPP_TEMPLATE_VIS basic_ifstream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_ofstream; class _LIBCPP_TEMPLATE_VIS basic_ofstream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_fstream; class _LIBCPP_TEMPLATE_VIS basic_fstream;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator; class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
template <class _CharT, class _Traits = char_traits<_CharT> > template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator; class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;
typedef basic_ios<char> ios; typedef basic_ios<char> ios;
typedef basic_ios<wchar_t> wios; typedef basic_ios<wchar_t> wios;
@@ -172,7 +172,7 @@ typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream; typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream; typedef basic_fstream<wchar_t> wfstream;
template <class _State> class _LIBCPP_TYPE_VIS_ONLY fpos; template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
typedef fpos<mbstate_t> streampos; typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos; typedef fpos<mbstate_t> wstreampos;
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
@@ -190,14 +190,14 @@ typedef long long streamoff; // for char_traits in <string>
template <class _CharT, // for <stdexcept> template <class _CharT, // for <stdexcept>
class _Traits = char_traits<_CharT>, class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class _Allocator = allocator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY basic_string; class _LIBCPP_TEMPLATE_VIS basic_string;
typedef basic_string<char, char_traits<char>, allocator<char> > string; typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring; typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
// Include other forward declarations here // Include other forward declarations here
template <class _Tp, class _Alloc = allocator<_Tp> > template <class _Tp, class _Alloc = allocator<_Tp> >
class _LIBCPP_TYPE_VIS_ONLY vector; class _LIBCPP_TEMPLATE_VIS vector;
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@@ -171,7 +171,7 @@ template <class charT, class traits, class T>
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_istream class _LIBCPP_TEMPLATE_VIS basic_istream
: virtual public basic_ios<_CharT, _Traits> : virtual public basic_ios<_CharT, _Traits>
{ {
streamsize __gc_; streamsize __gc_;
@@ -184,39 +184,50 @@ public:
typedef typename traits_type::off_type off_type; typedef typename traits_type::off_type off_type;
// 27.7.1.1.1 Constructor/destructor: // 27.7.1.1.1 Constructor/destructor:
explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit basic_istream(basic_streambuf<char_type, traits_type>* __sb) : __gc_(0)
{ this->init(__sb); }
virtual ~basic_istream(); virtual ~basic_istream();
protected: protected:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
basic_istream(basic_istream&& __rhs); basic_istream(basic_istream&& __rhs);
#endif #endif
// 27.7.1.1.2 Assign/swap: // 27.7.1.1.2 Assign/swap:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
basic_istream& operator=(basic_istream&& __rhs); basic_istream& operator=(basic_istream&& __rhs);
#endif #endif
void swap(basic_istream& __rhs);
#if _LIBCPP_STD_VER > 11 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS void swap(basic_istream& __rhs) {
_VSTD::swap(__gc_, __rhs.__gc_);
basic_ios<char_type, traits_type>::swap(__rhs);
}
#ifndef _LIBCPP_CXX03_LANG
basic_istream (const basic_istream& __rhs) = delete; basic_istream (const basic_istream& __rhs) = delete;
basic_istream& operator=(const basic_istream& __rhs) = delete; basic_istream& operator=(const basic_istream& __rhs) = delete;
#else
basic_istream (const basic_istream& __rhs); // not defined
basic_istream& operator=(const basic_istream& __rhs); // not defined
#endif
#endif #endif
public: public:
// 27.7.1.1.3 Prefix/suffix: // 27.7.1.1.3 Prefix/suffix:
class _LIBCPP_TYPE_VIS_ONLY sentry; class _LIBCPP_TEMPLATE_VIS sentry;
// 27.7.1.2 Formatted input: // 27.7.1.2 Formatted input:
basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); 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<char_type, traits_type>& basic_istream& operator>>(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type, traits_type>&)); (*__pf)(basic_ios<char_type, traits_type>&))
basic_istream& operator>>(ios_base& (*__pf)(ios_base&)); { __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<char_type, traits_type>* __sb); basic_istream& operator>>(basic_streambuf<char_type, traits_type>* __sb);
basic_istream& operator>>(bool& __n); basic_istream& operator>>(bool& __n);
basic_istream& operator>>(short& __n); basic_istream& operator>>(short& __n);
@@ -236,13 +247,31 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
streamsize gcount() const {return __gc_;} streamsize gcount() const {return __gc_;}
int_type get(); int_type get();
basic_istream& get(char_type& __c);
basic_istream& get(char_type* __s, streamsize __n); 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); basic_istream& get(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb);
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb)
{ return get(__sb, this->widen('\n')); }
basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm); basic_istream& get(basic_streambuf<char_type, traits_type>& __sb, char_type __dlm);
basic_istream& getline(char_type* __s, streamsize __n); 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& getline(char_type* __s, streamsize __n, char_type __dlm);
basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof()); basic_istream& ignore(streamsize __n = 1, int_type __dlm = traits_type::eof());
@@ -260,7 +289,7 @@ public:
}; };
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry
{ {
bool __ok_; bool __ok_;
@@ -303,18 +332,9 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _
__is.setstate(ios_base::failbit); __is.setstate(ios_base::failbit);
} }
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf<char_type, traits_type>* __sb)
: __gc_(0)
{
this->init(__sb);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
: __gc_(__rhs.__gc_) : __gc_(__rhs.__gc_)
{ {
@@ -323,7 +343,6 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
} }
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
{ {
@@ -338,15 +357,6 @@ basic_istream<_CharT, _Traits>::~basic_istream()
{ {
} }
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
{
_VSTD::swap(__gc_, __rhs.__gc_);
basic_ios<char_type, traits_type>::swap(__rhs);
}
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n) basic_istream<_CharT, _Traits>::operator>>(unsigned short& __n)
@@ -724,33 +734,6 @@ basic_istream<_CharT, _Traits>::operator>>(int& __n)
return *this; return *this;
} }
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&))
{
return __pf(*this);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(basic_ios<char_type, traits_type>&
(*__pf)(basic_ios<char_type, traits_type>&))
{
__pf(*this);
return *this;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
{
__pf(*this);
return *this;
}
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s)
@@ -946,17 +929,6 @@ basic_istream<_CharT, _Traits>::get()
return __r; return __r;
} }
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type& __c)
{
int_type __ch = get();
if (__ch != traits_type::eof())
__c = traits_type::to_char_type(__ch);
return *this;
}
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm) basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
@@ -1005,14 +977,6 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
return *this; return *this;
} }
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
{
return get(__s, __n, this->widen('\n'));
}
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb, basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
@@ -1067,14 +1031,6 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
return *this; return *this;
} }
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb)
{
return get(__sb, this->widen('\n'));
}
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm) basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
@@ -1128,14 +1084,6 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
return *this; return *this;
} }
template<class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
{
return getline(__s, __n, this->widen('\n'));
}
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
@@ -1251,6 +1199,13 @@ streamsize
basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
{ {
__gc_ = 0; __gc_ = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
sentry __sen(*this, true);
if (__sen)
{
streamsize __c = this->rdbuf()->in_avail(); streamsize __c = this->rdbuf()->in_avail();
switch (__c) switch (__c)
{ {
@@ -1263,6 +1218,16 @@ basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
read(__s, _VSTD::min(__c, __n)); read(__s, _VSTD::min(__c, __n));
break; break;
} }
}
else
this->setstate(ios_base::failbit);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
this->__set_badbit_and_consider_rethrow();
}
#endif // _LIBCPP_NO_EXCEPTIONS
return __gc_; return __gc_;
} }
@@ -1464,16 +1429,16 @@ ws(basic_istream<_CharT, _Traits>& __is)
template <class _CharT, class _Traits, class _Tp> template <class _CharT, class _Traits, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x)
{ {
__is >> __x; __is >> _VSTD::forward<_Tp>(__x);
return __is; return __is;
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
class _LIBCPP_TYPE_VIS_ONLY basic_iostream class _LIBCPP_TEMPLATE_VIS basic_iostream
: public basic_istream<_CharT, _Traits>, : public basic_istream<_CharT, _Traits>,
public basic_ostream<_CharT, _Traits> public basic_ostream<_CharT, _Traits>
{ {
@@ -1486,41 +1451,38 @@ public:
typedef typename traits_type::off_type off_type; typedef typename traits_type::off_type off_type;
// constructor/destructor // constructor/destructor
explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
explicit basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
: basic_istream<_CharT, _Traits>(__sb)
{}
virtual ~basic_iostream(); virtual ~basic_iostream();
protected: protected:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
basic_iostream(basic_iostream&& __rhs); basic_iostream(basic_iostream&& __rhs);
#endif #endif
// assign/swap // assign/swap
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
basic_iostream& operator=(basic_iostream&& __rhs); basic_iostream& operator=(basic_iostream&& __rhs);
#endif #endif
void swap(basic_iostream& __rhs); inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
void swap(basic_iostream& __rhs)
{ basic_istream<char_type, traits_type>::swap(__rhs); }
public: public:
}; };
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf<char_type, traits_type>* __sb)
: basic_istream<_CharT, _Traits>(__sb)
{
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
{ {
} }
template <class _CharT, class _Traits> template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_iostream<_CharT, _Traits>& basic_iostream<_CharT, _Traits>&
basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs)
{ {
@@ -1535,14 +1497,6 @@ basic_iostream<_CharT, _Traits>::~basic_iostream()
{ {
} }
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs)
{
basic_istream<char_type, traits_type>::swap(__rhs);
}
template<class _CharT, class _Traits, class _Allocator> template<class _CharT, class _Traits, class _Allocator>
basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, operator>>(basic_istream<_CharT, _Traits>& __is,
@@ -1688,7 +1642,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{ {
basic_string<_CharT, _Traits> __str; basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc()); const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
streamsize __c = 0; size_t __c = 0;
ios_base::iostate __err = ios_base::goodbit; ios_base::iostate __err = ios_base::goodbit;
_CharT __zero = __ct.widen('0'); _CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1'); _CharT __one = __ct.widen('1');
@@ -1724,9 +1678,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is; return __is;
} }
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

File diff suppressed because it is too large Load Diff

View File

@@ -182,7 +182,7 @@ protected:
static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
}; };
template <class _Tp, int digits, bool is_signed> template <class _Tp, int digits, bool _IsSigned>
struct __libcpp_compute_min struct __libcpp_compute_min
{ {
static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << digits); static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << digits);
@@ -306,7 +306,7 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_signed = true; static _LIBCPP_CONSTEXPR const bool is_signed = true;
static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000; static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __FLT_MIN__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __FLT_MAX__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
@@ -352,7 +352,7 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_signed = true; static _LIBCPP_CONSTEXPR const bool is_signed = true;
static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000; static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __DBL_MIN__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __DBL_MAX__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
@@ -398,7 +398,7 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_signed = true; static _LIBCPP_CONSTEXPR const bool is_signed = true;
static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103)/100000; static _LIBCPP_CONSTEXPR const int max_digits10 = 2+(digits * 30103l)/100000l;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type min() _NOEXCEPT {return __LDBL_MIN__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type max() _NOEXCEPT {return __LDBL_MAX__;}
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT {return -max();}
@@ -438,7 +438,7 @@ protected:
}; };
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY numeric_limits class _LIBCPP_TEMPLATE_VIS numeric_limits
: private __libcpp_numeric_limits<typename remove_cv<_Tp>::type> : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
{ {
typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base; typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
@@ -531,7 +531,7 @@ template <class _Tp>
_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const _Tp> class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp>
: private numeric_limits<_Tp> : private numeric_limits<_Tp>
{ {
typedef numeric_limits<_Tp> __base; typedef numeric_limits<_Tp> __base;
@@ -624,7 +624,7 @@ template <class _Tp>
_LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style; _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY numeric_limits<volatile _Tp> class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp>
: private numeric_limits<_Tp> : private numeric_limits<_Tp>
{ {
typedef numeric_limits<_Tp> __base; typedef numeric_limits<_Tp> __base;
@@ -717,7 +717,7 @@ template <class _Tp>
_LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style; _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
template <class _Tp> template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const volatile _Tp> class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp>
: private numeric_limits<_Tp> : private numeric_limits<_Tp>
{ {
typedef numeric_limits<_Tp> __base; typedef numeric_limits<_Tp> __base;

65
include/limits.h Normal file
View File

@@ -0,0 +1,65 @@
// -*- C++ -*-
//===--------------------------- limits.h ---------------------------------===//
//
// 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_LIMITS_H
#define _LIBCPP_LIMITS_H
/*
limits.h synopsis
Macros:
CHAR_BIT
SCHAR_MIN
SCHAR_MAX
UCHAR_MAX
CHAR_MIN
CHAR_MAX
MB_LEN_MAX
SHRT_MIN
SHRT_MAX
USHRT_MAX
INT_MIN
INT_MAX
UINT_MAX
LONG_MIN
LONG_MAX
ULONG_MAX
LLONG_MIN // C99
LLONG_MAX // C99
ULLONG_MAX // C99
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#ifndef __GNUC__
#include_next <limits.h>
#else
// GCC header limits.h recursively includes itself through another header called
// syslimits.h for some reason. This setup breaks down if we directly
// #include_next GCC's limits.h (reasons not entirely clear to me). Therefore,
// we manually re-create the necessary include sequence below:
// Get the system limits.h defines (force recurse into the next level)
#define _GCC_LIMITS_H_
#define _GCC_NEXT_LIMITS_H
#include_next <limits.h>
// Get the ISO C defines
#undef _GCC_LIMITS_H_
#include_next <limits.h>
#endif // __GNUC__
#endif // _LIBCPP_LIMITS_H

View File

@@ -93,10 +93,10 @@ public:
size_type max_size() const noexcept; size_type max_size() const noexcept;
template <class... Args> template <class... Args>
void emplace_front(Args&&... args); reference emplace_front(Args&&... args); // reference in C++17
void pop_front(); void pop_front();
template <class... Args> template <class... Args>
void emplace_back(Args&&... args); reference emplace_back(Args&&... args); // reference in C++17
void pop_back(); void pop_back();
void push_front(const value_type& x); void push_front(const value_type& x);
void push_front(value_type&& x); void push_front(value_type&& x);
@@ -266,12 +266,12 @@ struct __list_node
} }
}; };
template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TYPE_VIS_ONLY list; template <class _Tp, class _Alloc = allocator<_Tp> > class _LIBCPP_TEMPLATE_VIS list;
template <class _Tp, class _Alloc> class __list_imp; template <class _Tp, class _Alloc> class __list_imp;
template <class _Tp, class _VoidPtr> class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator; template <class _Tp, class _VoidPtr> class _LIBCPP_TEMPLATE_VIS __list_const_iterator;
template <class _Tp, class _VoidPtr> template <class _Tp, class _VoidPtr>
class _LIBCPP_TYPE_VIS_ONLY __list_iterator class _LIBCPP_TEMPLATE_VIS __list_iterator
{ {
typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
typedef typename _NodeTraits::__link_pointer __link_pointer; typedef typename _NodeTraits::__link_pointer __link_pointer;
@@ -394,7 +394,7 @@ public:
}; };
template <class _Tp, class _VoidPtr> template <class _Tp, class _VoidPtr>
class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator class _LIBCPP_TEMPLATE_VIS __list_const_iterator
{ {
typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
typedef typename _NodeTraits::__link_pointer __link_pointer; typedef typename _NodeTraits::__link_pointer __link_pointer;
@@ -570,6 +570,10 @@ protected:
const __node_allocator& __node_alloc() const _NOEXCEPT const __node_allocator& __node_alloc() const _NOEXCEPT
{return __size_alloc_.second();} {return __size_alloc_.second();}
_LIBCPP_INLINE_VISIBILITY
size_type __node_alloc_max_size() const _NOEXCEPT {
return __node_alloc_traits::max_size(__node_alloc());
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT; static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT;
@@ -622,9 +626,9 @@ protected:
void swap(__list_imp& __c) void swap(__list_imp& __c)
#if _LIBCPP_STD_VER >= 14 #if _LIBCPP_STD_VER >= 14
_NOEXCEPT; _NOEXCEPT_DEBUG;
#else #else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value); __is_nothrow_swappable<allocator_type>::value);
#endif #endif
@@ -651,7 +655,7 @@ private:
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __list_imp& __c, false_type) void __copy_assign_alloc(const __list_imp&, false_type)
{} {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -662,9 +666,16 @@ private:
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__list_imp& __c, false_type) void __move_assign_alloc(__list_imp&, false_type)
_NOEXCEPT _NOEXCEPT
{} {}
_LIBCPP_INLINE_VISIBILITY
void __invalidate_all_iterators() {
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__invalidate_all(this);
#endif
}
}; };
// Unlink nodes [__f, __l] // Unlink nodes [__f, __l]
@@ -720,21 +731,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
__node_alloc_traits::deallocate(__na, __np, 1); __node_alloc_traits::deallocate(__na, __np, 1);
} }
#if _LIBCPP_DEBUG_LEVEL >= 2 __invalidate_all_iterators();
__c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; )
{
--__p;
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
if (__i->__ptr_ != __l)
{
(*__p)->__c_ = nullptr;
if (--__c->end_ != __p)
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
}
}
__get_db()->unlock();
#endif
} }
} }
@@ -742,9 +739,9 @@ template <class _Tp, class _Alloc>
void void
__list_imp<_Tp, _Alloc>::swap(__list_imp& __c) __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
#if _LIBCPP_STD_VER >= 14 #if _LIBCPP_STD_VER >= 14
_NOEXCEPT _NOEXCEPT_DEBUG
#else #else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) __is_nothrow_swappable<allocator_type>::value)
#endif #endif
{ {
@@ -803,7 +800,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
} }
template <class _Tp, class _Alloc /*= allocator<_Tp>*/> template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
class _LIBCPP_TYPE_VIS_ONLY list class _LIBCPP_TEMPLATE_VIS list
: private __list_imp<_Tp, _Alloc> : private __list_imp<_Tp, _Alloc>
{ {
typedef __list_imp<_Tp, _Alloc> base; typedef __list_imp<_Tp, _Alloc> base;
@@ -904,7 +901,11 @@ public:
bool empty() const _NOEXCEPT {return base::empty();} bool empty() const _NOEXCEPT {return base::empty();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT size_type max_size() const _NOEXCEPT
{return numeric_limits<difference_type>::max();} {
return std::min<size_type>(
base::__node_alloc_max_size(),
numeric_limits<difference_type >::max());
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return base::begin();} iterator begin() _NOEXCEPT {return base::begin();}
@@ -968,9 +969,17 @@ public:
void push_back(value_type&& __x); void push_back(value_type&& __x);
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
reference emplace_front(_Args&&... __args);
#else
void emplace_front(_Args&&... __args); void emplace_front(_Args&&... __args);
#endif
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
reference emplace_back(_Args&&... __args);
#else
void emplace_back(_Args&&... __args); void emplace_back(_Args&&... __args);
#endif
template <class... _Args> template <class... _Args>
iterator emplace(const_iterator __p, _Args&&... __args); iterator emplace(const_iterator __p, _Args&&... __args);
#endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_VARIADICS
@@ -994,9 +1003,9 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
void swap(list& __c) void swap(list& __c)
#if _LIBCPP_STD_VER >= 14 #if _LIBCPP_STD_VER >= 14
_NOEXCEPT _NOEXCEPT_DEBUG
#else #else
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || _NOEXCEPT_DEBUG_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value) __is_nothrow_swappable<__node_allocator>::value)
#endif #endif
{base::swap(__c);} {base::swap(__c);}
@@ -1353,6 +1362,9 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
insert(__e, __f, __l); insert(__e, __f, __l);
else else
erase(__i, __e); erase(__i, __e);
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__invalidate_all(this);
#endif
} }
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
@@ -1367,6 +1379,9 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
insert(__e, __n, __x); insert(__e, __n, __x);
else else
erase(__i, __e); erase(__i, __e);
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__invalidate_all(this);
#endif
} }
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
@@ -1593,7 +1608,11 @@ list<_Tp, _Alloc>::push_back(value_type&& __x)
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
typename list<_Tp, _Alloc>::reference
#else
void void
#endif
list<_Tp, _Alloc>::emplace_front(_Args&&... __args) list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
{ {
__node_allocator& __na = base::__node_alloc(); __node_allocator& __na = base::__node_alloc();
@@ -1602,12 +1621,20 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
__link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
++base::__sz(); ++base::__sz();
#if _LIBCPP_STD_VER > 14
return __hold.release()->__value_;
#else
__hold.release(); __hold.release();
#endif
} }
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
template <class... _Args> template <class... _Args>
#if _LIBCPP_STD_VER > 14
typename list<_Tp, _Alloc>::reference
#else
void void
#endif
list<_Tp, _Alloc>::emplace_back(_Args&&... __args) list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
{ {
__node_allocator& __na = base::__node_alloc(); __node_allocator& __na = base::__node_alloc();
@@ -1617,7 +1644,11 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
__link_pointer __nl = __hold->__as_link(); __link_pointer __nl = __hold->__as_link();
__link_nodes_at_back(__nl, __nl); __link_nodes_at_back(__nl, __nl);
++base::__sz(); ++base::__sz();
#if _LIBCPP_STD_VER > 14
return __hold.release()->__value_;
#else
__hold.release(); __hold.release();
#endif
} }
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
@@ -1751,15 +1782,15 @@ list<_Tp, _Alloc>::erase(const_iterator __p)
--base::__sz(); --base::__sz();
#if _LIBCPP_DEBUG_LEVEL >= 2 #if _LIBCPP_DEBUG_LEVEL >= 2
__c_node* __c = __get_db()->__find_c_and_lock(this); __c_node* __c = __get_db()->__find_c_and_lock(this);
for (__i_node** __p = __c->end_; __p != __c->beg_; ) for (__i_node** __ip = __c->end_; __ip != __c->beg_; )
{ {
--__p; --__ip;
iterator* __i = static_cast<iterator*>((*__p)->__i_); iterator* __i = static_cast<iterator*>((*__ip)->__i_);
if (__i->__ptr_ == __n) if (__i->__ptr_ == __n)
{ {
(*__p)->__c_ = nullptr; (*__ip)->__c_ = nullptr;
if (--__c->end_ != __p) if (--__c->end_ != __ip)
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); memmove(__ip, __ip+1, (__c->end_ - __ip)*sizeof(__i_node*));
} }
} }
__get_db()->unlock(); __get_db()->unlock();
@@ -1782,6 +1813,9 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this, _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
"list::erase(iterator, iterator) called with an iterator not" "list::erase(iterator, iterator) called with an iterator not"
" referring to this list"); " referring to this list");
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == this,
"list::erase(iterator, iterator) called with an iterator not"
" referring to this list");
#endif #endif
if (__f != __l) if (__f != __l)
{ {
@@ -1961,16 +1995,16 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
__libcpp_db* __db = __get_db(); __libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this); __c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(&__c); __c_node* __cn2 = __db->__find_c(&__c);
for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;) for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{ {
--__p; --__ip;
iterator* __i = static_cast<iterator*>((*__p)->__i_); iterator* __i = static_cast<iterator*>((*__ip)->__i_);
if (__i->__ptr_ != __c.__end_as_link()) if (__i->__ptr_ != __c.__end_as_link())
{ {
__cn1->__add(*__p); __cn1->__add(*__ip);
(*__p)->__c_ = __cn1; (*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __p) if (--__cn2->end_ != __ip)
memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
} }
} }
__db->unlock(); __db->unlock();
@@ -2004,16 +2038,16 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
__libcpp_db* __db = __get_db(); __libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this); __c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(&__c); __c_node* __cn2 = __db->__find_c(&__c);
for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;) for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{ {
--__p; --__ip;
iterator* __j = static_cast<iterator*>((*__p)->__i_); iterator* __j = static_cast<iterator*>((*__ip)->__i_);
if (__j->__ptr_ == __f) if (__j->__ptr_ == __f)
{ {
__cn1->__add(*__p); __cn1->__add(*__ip);
(*__p)->__c_ = __cn1; (*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __p) if (--__cn2->end_ != __ip)
memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
} }
} }
__db->unlock(); __db->unlock();
@@ -2058,19 +2092,19 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
__libcpp_db* __db = __get_db(); __libcpp_db* __db = __get_db();
__c_node* __cn1 = __db->__find_c_and_lock(this); __c_node* __cn1 = __db->__find_c_and_lock(this);
__c_node* __cn2 = __db->__find_c(&__c); __c_node* __cn2 = __db->__find_c(&__c);
for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;) for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{ {
--__p; --__ip;
iterator* __j = static_cast<iterator*>((*__p)->__i_); iterator* __j = static_cast<iterator*>((*__ip)->__i_);
for (__link_pointer __k = __f.__ptr_; for (__link_pointer __k = __f.__ptr_;
__k != __l.__ptr_; __k = __k->__next_) __k != __l.__ptr_; __k = __k->__next_)
{ {
if (__j->__ptr_ == __k) if (__j->__ptr_ == __k)
{ {
__cn1->__add(*__p); __cn1->__add(*__ip);
(*__p)->__c_ = __cn1; (*__ip)->__c_ = __cn1;
if (--__cn2->end_ != __p) if (--__cn2->end_ != __ip)
memmove(__p, __p+1, (__cn2->end_ - __p)*sizeof(__i_node*)); memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
} }
} }
} }
@@ -2083,7 +2117,7 @@ template <class _Tp, class _Alloc>
void void
list<_Tp, _Alloc>::remove(const value_type& __x) list<_Tp, _Alloc>::remove(const value_type& __x)
{ {
list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (const_iterator __i = begin(), __e = end(); __i != __e;) for (const_iterator __i = begin(), __e = end(); __i != __e;)
{ {
if (*__i == __x) if (*__i == __x)
@@ -2328,14 +2362,14 @@ list<_Tp, _Alloc>::__decrementable(const const_iterator* __i) const
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
bool bool
list<_Tp, _Alloc>::__addable(const const_iterator* __i, ptrdiff_t __n) const list<_Tp, _Alloc>::__addable(const const_iterator*, ptrdiff_t) const
{ {
return false; return false;
} }
template <class _Tp, class _Alloc> template <class _Tp, class _Alloc>
bool bool
list<_Tp, _Alloc>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const
{ {
return false; return false;
} }

View File

@@ -180,6 +180,7 @@ template <class charT> class messages_byname;
#include <__config> #include <__config>
#include <__locale> #include <__locale>
#include <__debug>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <ios> #include <ios>
@@ -522,11 +523,11 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
return 0; return 0;
} }
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY num_get class _LIBCPP_TEMPLATE_VIS num_get
: public locale::facet, : public locale::facet,
private __num_get<_CharT> private __num_get<_CharT>
{ {
@@ -756,6 +757,29 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end,
} }
template <class _Tp> template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
_Tp __do_strtod(const char* __a, char** __p2);
template <>
inline _LIBCPP_INLINE_VISIBILITY
float __do_strtod<float>(const char* __a, char** __p2) {
return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
}
template <>
inline _LIBCPP_INLINE_VISIBILITY
double __do_strtod<double>(const char* __a, char** __p2) {
return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
}
template <>
inline _LIBCPP_INLINE_VISIBILITY
long double __do_strtod<long double>(const char* __a, char** __p2) {
return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE);
}
template <class _Tp>
_LIBCPP_HIDDEN
_Tp _Tp
__num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
{ {
@@ -764,7 +788,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
typename remove_reference<decltype(errno)>::type __save_errno = errno; typename remove_reference<decltype(errno)>::type __save_errno = errno;
errno = 0; errno = 0;
char *__p2; char *__p2;
long double __ld = strtold_l(__a, &__p2, _LIBCPP_GET_C_LOCALE); _Tp __ld = __do_strtod<_Tp>(__a, &__p2);
typename remove_reference<decltype(errno)>::type __current_errno = errno; typename remove_reference<decltype(errno)>::type __current_errno = errno;
if (__current_errno == 0) if (__current_errno == 0)
errno = __save_errno; errno = __save_errno;
@@ -775,7 +799,7 @@ __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err)
} }
else if (__current_errno == ERANGE) else if (__current_errno == ERANGE)
__err = ios_base::failbit; __err = ios_base::failbit;
return static_cast<_Tp>(__ld); return __ld;
} }
__err = ios_base::failbit; __err = ios_base::failbit;
return 0; return 0;
@@ -1019,8 +1043,8 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b; return __b;
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>)
struct _LIBCPP_TYPE_VIS __num_put_base struct _LIBCPP_TYPE_VIS __num_put_base
{ {
@@ -1169,11 +1193,11 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne,
__op = __ob + (__np - __nb); __op = __ob + (__np - __nb);
} }
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY num_put class _LIBCPP_TEMPLATE_VIS num_put
: public locale::facet, : public locale::facet,
private __num_put<_CharT> private __num_put<_CharT>
{ {
@@ -1598,8 +1622,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); return __pad_and_output(__s, __o, __op, __oe, __iob, __fl);
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>)
template <class _CharT, class _InputIterator> template <class _CharT, class _InputIterator>
_LIBCPP_HIDDEN _LIBCPP_HIDDEN
@@ -1641,7 +1665,7 @@ public:
}; };
template <class _CharT> template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage class _LIBCPP_TEMPLATE_VIS __time_get_c_storage
{ {
protected: protected:
typedef basic_string<_CharT> string_type; typedef basic_string<_CharT> string_type;
@@ -1659,7 +1683,7 @@ protected:
}; };
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_get class _LIBCPP_TEMPLATE_VIS time_get
: public locale::facet, : public locale::facet,
public time_base, public time_base,
private __time_get_c_storage<_CharT> private __time_get_c_storage<_CharT>
@@ -2268,8 +2292,8 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b; return __b;
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>)
class _LIBCPP_TYPE_VIS __time_get class _LIBCPP_TYPE_VIS __time_get
{ {
@@ -2282,7 +2306,7 @@ protected:
}; };
template <class _CharT> template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY __time_get_storage class _LIBCPP_TEMPLATE_VIS __time_get_storage
: public __time_get : public __time_get
{ {
protected: protected:
@@ -2309,7 +2333,7 @@ private:
}; };
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_get_byname class _LIBCPP_TEMPLATE_VIS time_get_byname
: public time_get<_CharT, _InputIterator>, : public time_get<_CharT, _InputIterator>,
private __time_get_storage<_CharT> private __time_get_storage<_CharT>
{ {
@@ -2351,8 +2375,8 @@ private:
virtual const string_type& __X() const {return this->__X_;} virtual const string_type& __X() const {return this->__X_;}
}; };
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>)
class _LIBCPP_TYPE_VIS __time_put class _LIBCPP_TYPE_VIS __time_put
{ {
@@ -2369,7 +2393,7 @@ protected:
}; };
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_put class _LIBCPP_TEMPLATE_VIS time_put
: public locale::facet, : public locale::facet,
private __time_put private __time_put
{ {
@@ -2464,11 +2488,11 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&,
return _VSTD::copy(__nb, __ne, __s); return _VSTD::copy(__nb, __ne, __s);
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY time_put_byname class _LIBCPP_TEMPLATE_VIS time_put_byname
: public time_put<_CharT, _OutputIterator> : public time_put<_CharT, _OutputIterator>
{ {
public: public:
@@ -2485,8 +2509,8 @@ protected:
~time_put_byname() {} ~time_put_byname() {}
}; };
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>)
// money_base // money_base
@@ -2502,7 +2526,7 @@ public:
// moneypunct // moneypunct
template <class _CharT, bool _International = false> template <class _CharT, bool _International = false>
class _LIBCPP_TYPE_VIS_ONLY moneypunct class _LIBCPP_TEMPLATE_VIS moneypunct
: public locale::facet, : public locale::facet,
public money_base public money_base
{ {
@@ -2552,15 +2576,15 @@ template <class _CharT, bool _International>
const bool const bool
moneypunct<_CharT, _International>::intl; moneypunct<_CharT, _International>::intl;
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>)
// moneypunct_byname // moneypunct_byname
template <class _CharT, bool _International = false> template <class _CharT, bool _International = false>
class _LIBCPP_TYPE_VIS_ONLY moneypunct_byname class _LIBCPP_TEMPLATE_VIS moneypunct_byname
: public moneypunct<_CharT, _International> : public moneypunct<_CharT, _International>
{ {
public: public:
@@ -2609,10 +2633,10 @@ template<> void moneypunct_byname<char, true>::init(const char*);
template<> void moneypunct_byname<wchar_t, false>::init(const char*); template<> void moneypunct_byname<wchar_t, false>::init(const char*);
template<> void moneypunct_byname<wchar_t, true>::init(const char*); template<> void moneypunct_byname<wchar_t, true>::init(const char*);
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>)
// money_get // money_get
@@ -2668,11 +2692,11 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc,
} }
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>)
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY money_get class _LIBCPP_TEMPLATE_VIS money_get
: public locale::facet, : public locale::facet,
private __money_get<_CharT> private __money_get<_CharT>
{ {
@@ -3051,8 +3075,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
return __b; return __b;
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>)
// money_put // money_put
@@ -3226,11 +3250,11 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m
__mi = __mb; __mi = __mb;
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>)
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
class _LIBCPP_TYPE_VIS_ONLY money_put class _LIBCPP_TEMPLATE_VIS money_put
: public locale::facet, : public locale::facet,
private __money_put<_CharT> private __money_put<_CharT>
{ {
@@ -3379,8 +3403,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>)
// messages // messages
@@ -3393,7 +3417,7 @@ public:
}; };
template <class _CharT> template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY messages class _LIBCPP_TEMPLATE_VIS messages
: public locale::facet, : public locale::facet,
public messages_base public messages_base
{ {
@@ -3489,11 +3513,11 @@ messages<_CharT>::do_close(catalog __c) const
#endif // _LIBCPP_HAS_CATOPEN #endif // _LIBCPP_HAS_CATOPEN
} }
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>)
template <class _CharT> template <class _CharT>
class _LIBCPP_TYPE_VIS_ONLY messages_byname class _LIBCPP_TEMPLATE_VIS messages_byname
: public messages<_CharT> : public messages<_CharT>
{ {
public: public:
@@ -3513,13 +3537,13 @@ protected:
~messages_byname() {} ~messages_byname() {}
}; };
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>) _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>)
template<class _Codecvt, class _Elem = wchar_t, template<class _Codecvt, class _Elem = wchar_t,
class _Wide_alloc = allocator<_Elem>, class _Wide_alloc = allocator<_Elem>,
class _Byte_alloc = allocator<char> > class _Byte_alloc = allocator<char> >
class _LIBCPP_TYPE_VIS_ONLY wstring_convert class _LIBCPP_TEMPLATE_VIS wstring_convert
{ {
public: public:
typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string; typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
@@ -3611,7 +3635,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
: __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)), : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)),
__wide_err_string_(_VSTD::move(__wc.__wide_err_string_)), __wide_err_string_(_VSTD::move(__wc.__wide_err_string_)),
__cvtptr_(__wc.__cvtptr_), __cvtptr_(__wc.__cvtptr_),
__cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtstate_) __cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtcount_)
{ {
__wc.__cvtptr_ = nullptr; __wc.__cvtptr_ = nullptr;
} }
@@ -3678,10 +3702,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
if (__r == codecvt_base::ok) if (__r == codecvt_base::ok)
return __ws; return __ws;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__wide_err_string_.empty()) if (__wide_err_string_.empty())
throw range_error("wstring_convert: from_bytes error"); __throw_range_error("wstring_convert: from_bytes error");
#endif // _LIBCPP_NO_EXCEPTIONS
return __wide_err_string_; return __wide_err_string_;
} }
@@ -3767,15 +3791,15 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
return __bs; return __bs;
} }
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__byte_err_string_.empty()) if (__byte_err_string_.empty())
throw range_error("wstring_convert: to_bytes error"); __throw_range_error("wstring_convert: to_bytes error");
#endif // _LIBCPP_NO_EXCEPTIONS
return __byte_err_string_; return __byte_err_string_;
} }
template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
class _LIBCPP_TYPE_VIS_ONLY wbuffer_convert class _LIBCPP_TEMPLATE_VIS wbuffer_convert
: public basic_streambuf<_Elem, _Tr> : public basic_streambuf<_Elem, _Tr>
{ {
public: public:
@@ -3901,13 +3925,16 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
} }
else else
{ {
_LIBCPP_ASSERT(!(__extbufnext_ == NULL && (__extbufend_ != __extbufnext_)), "underflow moving from NULL" );
if (__extbufend_ != __extbufnext_)
memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_); memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
__extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_); __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
__extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_); __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz), streamsize __nmemb = _VSTD::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
static_cast<streamsize>(__extbufend_ - __extbufnext_)); static_cast<streamsize>(__extbufend_ - __extbufnext_));
codecvt_base::result __r; codecvt_base::result __r;
state_type __svs = __st_; // FIXME: Do we ever need to restore the state here?
//state_type __svs = __st_;
streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb); streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
if (__nr != 0) if (__nr != 0)
{ {

45
include/locale.h Normal file
View File

@@ -0,0 +1,45 @@
// -*- C++ -*-
//===---------------------------- locale.h --------------------------------===//
//
// 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_H
#define _LIBCPP_LOCALE_H
/*
locale.h synopsis
Macros:
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
Types:
lconv
Functions:
setlocale
localeconv
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
#include_next <locale.h>
#endif // _LIBCPP_LOCALE_H

View File

@@ -453,9 +453,7 @@ swap(multimap<Key, T, Compare, Allocator>& x,
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _CP, class _Compare, template <class _Key, class _CP, class _Compare, bool _IsSmall>
bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value
>
class __map_value_compare class __map_value_compare
: private _Compare : private _Compare
{ {
@@ -682,7 +680,7 @@ struct __extract_key_value_types<__value_type<_Key, _Tp> >
}; };
template <class _TreeIterator> template <class _TreeIterator>
class _LIBCPP_TYPE_VIS_ONLY __map_iterator class _LIBCPP_TEMPLATE_VIS __map_iterator
{ {
typedef typename _TreeIterator::_NodeTypes _NodeTypes; typedef typename _TreeIterator::_NodeTypes _NodeTypes;
typedef typename _TreeIterator::__pointer_traits __pointer_traits; typedef typename _TreeIterator::__pointer_traits __pointer_traits;
@@ -735,13 +733,13 @@ public:
bool operator!=(const __map_iterator& __x, const __map_iterator& __y) bool operator!=(const __map_iterator& __x, const __map_iterator& __y)
{return __x.__i_ != __y.__i_;} {return __x.__i_ != __y.__i_;}
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; template <class> friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
}; };
template <class _TreeIterator> template <class _TreeIterator>
class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator class _LIBCPP_TEMPLATE_VIS __map_const_iterator
{ {
typedef typename _TreeIterator::_NodeTypes _NodeTypes; typedef typename _TreeIterator::_NodeTypes _NodeTypes;
typedef typename _TreeIterator::__pointer_traits __pointer_traits; typedef typename _TreeIterator::__pointer_traits __pointer_traits;
@@ -797,14 +795,14 @@ public:
bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y)
{return __x.__i_ != __y.__i_;} {return __x.__i_ != __y.__i_;}
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; template <class, class, class> friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;
}; };
template <class _Key, class _Tp, class _Compare = less<_Key>, template <class _Key, class _Tp, class _Compare = less<_Key>,
class _Allocator = allocator<pair<const _Key, _Tp> > > class _Allocator = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY map class _LIBCPP_TEMPLATE_VIS map
{ {
public: public:
// types: // types:
@@ -820,7 +818,7 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value), static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type"); "Allocator::value_type must be same type as value_type");
class _LIBCPP_TYPE_VIS_ONLY value_compare class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool> : public binary_function<value_type, value_type, bool>
{ {
friend class map; friend class map;
@@ -873,7 +871,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit map(const key_compare& __comp, const allocator_type& __a) explicit map(const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) {} : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
template <class _InputIterator> template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -888,7 +886,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
map(_InputIterator __f, _InputIterator __l, map(_InputIterator __f, _InputIterator __l,
const key_compare& __comp, const allocator_type& __a) const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{ {
insert(__f, __l); insert(__f, __l);
} }
@@ -910,7 +908,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
map& operator=(const map& __m) map& operator=(const map& __m)
{ {
#if __cplusplus >= 201103L #ifndef _LIBCPP_CXX03_LANG
__tree_ = __m.__tree_; __tree_ = __m.__tree_;
#else #else
if (this != &__m) { if (this != &__m) {
@@ -955,7 +953,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{ {
insert(__il.begin(), __il.end()); insert(__il.begin(), __il.end());
} }
@@ -977,13 +975,13 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit map(const allocator_type& __a) explicit map(const allocator_type& __a)
: __tree_(__a) : __tree_(typename __base::allocator_type(__a))
{ {
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
map(const map& __m, const allocator_type& __a) map(const map& __m, const allocator_type& __a)
: __tree_(__m.__tree_.value_comp(), __a) : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
{ {
insert(__m.begin(), __m.end()); insert(__m.begin(), __m.end());
} }
@@ -1034,7 +1032,7 @@ public:
const mapped_type& at(const key_type& __k) const; const mapped_type& at(const key_type& __k) const;
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
key_compare key_comp() const {return __tree_.value_comp().key_comp();} key_compare key_comp() const {return __tree_.value_comp().key_comp();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -1297,6 +1295,7 @@ private:
typedef typename __base::__node_allocator __node_allocator; typedef typename __base::__node_allocator __node_allocator;
typedef typename __base::__node_pointer __node_pointer; typedef typename __base::__node_pointer __node_pointer;
typedef typename __base::__node_base_pointer __node_base_pointer; typedef typename __base::__node_base_pointer __node_base_pointer;
typedef typename __base::__parent_pointer __parent_pointer;
typedef __map_node_destructor<__node_allocator> _Dp; typedef __map_node_destructor<__node_allocator> _Dp;
typedef unique_ptr<__node, _Dp> __node_holder; typedef unique_ptr<__node, _Dp> __node_holder;
@@ -1304,70 +1303,14 @@ private:
#ifdef _LIBCPP_CXX03_LANG #ifdef _LIBCPP_CXX03_LANG
__node_holder __construct_node_with_key(const key_type& __k); __node_holder __construct_node_with_key(const key_type& __k);
#endif #endif
__node_base_pointer const&
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
_LIBCPP_INLINE_VISIBILITY
__node_base_pointer&
__find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
map const* __const_this = this;
return const_cast<__node_base_pointer&>(
__const_this->__find_equal_key(__parent, __k));
}
}; };
// Find __k
// Set __parent to parent of null leaf and
// return reference to null leaf iv __k does not exist.
// If __k exists, set parent to node of __k and return reference to node of __k
template <class _Key, class _Tp, class _Compare, class _Allocator>
typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
const key_type& __k) const
{
__node_pointer __nd = __tree_.__root();
if (__nd != nullptr)
{
while (true)
{
if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
{
if (__nd->__left_ != nullptr)
__nd = static_cast<__node_pointer>(__nd->__left_);
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent->__left_;
}
}
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
{
if (__nd->__right_ != nullptr)
__nd = static_cast<__node_pointer>(__nd->__right_);
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent->__right_;
}
}
else
{
__parent = static_cast<__node_base_pointer>(__nd);
return __parent;
}
}
}
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
return __parent->__left_;
}
#ifndef _LIBCPP_CXX03_LANG #ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator> template <class _Key, class _Tp, class _Compare, class _Allocator>
map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
: __tree_(_VSTD::move(__m.__tree_), __a) : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
{ {
if (__a != __m.get_allocator()) if (__a != __m.get_allocator())
{ {
@@ -1400,8 +1343,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp& _Tp&
map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k)
{ {
__node_base_pointer __parent; __parent_pointer __parent;
__node_base_pointer& __child = __find_equal_key(__parent, __k); __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
__node_pointer __r = static_cast<__node_pointer>(__child); __node_pointer __r = static_cast<__node_pointer>(__child);
if (__child == nullptr) if (__child == nullptr)
{ {
@@ -1440,8 +1383,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
_Tp& _Tp&
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
{ {
__node_base_pointer __parent; __parent_pointer __parent;
__node_base_pointer& __child = __find_equal_key(__parent, __k); __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr) if (__child == nullptr)
throw out_of_range("map::at: key not found"); throw out_of_range("map::at: key not found");
@@ -1453,8 +1396,8 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
const _Tp& const _Tp&
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
{ {
__node_base_pointer __parent; __parent_pointer __parent;
__node_base_pointer __child = __find_equal_key(__parent, __k); __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS #ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr) if (__child == nullptr)
throw out_of_range("map::at: key not found"); throw out_of_range("map::at: key not found");
@@ -1529,7 +1472,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
template <class _Key, class _Tp, class _Compare = less<_Key>, template <class _Key, class _Tp, class _Compare = less<_Key>,
class _Allocator = allocator<pair<const _Key, _Tp> > > class _Allocator = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TYPE_VIS_ONLY multimap class _LIBCPP_TEMPLATE_VIS multimap
{ {
public: public:
// types: // types:
@@ -1545,7 +1488,7 @@ public:
static_assert((is_same<typename allocator_type::value_type, value_type>::value), static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type"); "Allocator::value_type must be same type as value_type");
class _LIBCPP_TYPE_VIS_ONLY value_compare class _LIBCPP_TEMPLATE_VIS value_compare
: public binary_function<value_type, value_type, bool> : public binary_function<value_type, value_type, bool>
{ {
friend class multimap; friend class multimap;
@@ -1599,7 +1542,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit multimap(const key_compare& __comp, const allocator_type& __a) explicit multimap(const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) {} : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
template <class _InputIterator> template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -1614,7 +1557,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
multimap(_InputIterator __f, _InputIterator __l, multimap(_InputIterator __f, _InputIterator __l,
const key_compare& __comp, const allocator_type& __a) const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{ {
insert(__f, __l); insert(__f, __l);
} }
@@ -1637,7 +1580,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
multimap& operator=(const multimap& __m) multimap& operator=(const multimap& __m)
{ {
#if __cplusplus >= 201103L #ifndef _LIBCPP_CXX03_LANG
__tree_ = __m.__tree_; __tree_ = __m.__tree_;
#else #else
if (this != &__m) { if (this != &__m) {
@@ -1682,7 +1625,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a) multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
: __tree_(__vc(__comp), __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a))
{ {
insert(__il.begin(), __il.end()); insert(__il.begin(), __il.end());
} }
@@ -1704,13 +1647,13 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
explicit multimap(const allocator_type& __a) explicit multimap(const allocator_type& __a)
: __tree_(__a) : __tree_(typename __base::allocator_type(__a))
{ {
} }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
multimap(const multimap& __m, const allocator_type& __a) multimap(const multimap& __m, const allocator_type& __a)
: __tree_(__m.__tree_.value_comp(), __a) : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a))
{ {
insert(__m.begin(), __m.end()); insert(__m.begin(), __m.end());
} }
@@ -1752,7 +1695,7 @@ public:
size_type max_size() const _NOEXCEPT {return __tree_.max_size();} size_type max_size() const _NOEXCEPT {return __tree_.max_size();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
allocator_type get_allocator() const _NOEXCEPT {return __tree_.__alloc();} allocator_type get_allocator() const _NOEXCEPT {return allocator_type(__tree_.__alloc());}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
key_compare key_comp() const {return __tree_.value_comp().key_comp();} key_compare key_comp() const {return __tree_.value_comp().key_comp();}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
@@ -1923,7 +1866,7 @@ private:
#ifndef _LIBCPP_CXX03_LANG #ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator> template <class _Key, class _Tp, class _Compare, class _Allocator>
multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
: __tree_(_VSTD::move(__m.__tree_), __a) : __tree_(_VSTD::move(__m.__tree_), typename __base::allocator_type(__a))
{ {
if (__a != __m.get_allocator()) if (__a != __m.get_allocator())
{ {

View File

@@ -308,10 +308,6 @@ extern "C++" {
#include <type_traits> #include <type_traits>
#ifdef _LIBCPP_MSVCRT
#include "support/win32/math_win32.h"
#endif
// signbit // signbit
#ifdef signbit #ifdef signbit
@@ -636,11 +632,9 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
#endif // isunordered #endif // isunordered
#ifndef __sun__
// abs // abs
#if !defined(_AIX) #if !(defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
float float
abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
@@ -652,11 +646,11 @@ abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
long double long double
abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
#endif // !defined(_AIX) #endif // !(defined(_AIX) || defined(__sun__))
// acos // acos
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
#endif #endif
@@ -668,7 +662,7 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
// asin // asin
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
#endif #endif
@@ -680,7 +674,7 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
// atan // atan
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
#endif #endif
@@ -692,7 +686,7 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
// atan2 // atan2
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
#endif #endif
@@ -715,7 +709,7 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
// ceil // ceil
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
#endif #endif
@@ -727,7 +721,7 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);}
// cos // cos
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);}
#endif #endif
@@ -739,7 +733,7 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);}
// cosh // cosh
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);}
#endif #endif
@@ -751,7 +745,7 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);}
// exp // exp
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);}
#endif #endif
@@ -763,7 +757,7 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);}
// fabs // fabs
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
#endif #endif
@@ -775,7 +769,7 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);}
// floor // floor
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);}
#endif #endif
@@ -787,7 +781,7 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);}
// fmod // fmod
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);}
#endif #endif
@@ -810,7 +804,7 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// frexp // frexp
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);}
#endif #endif
@@ -822,7 +816,7 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __l
// ldexp // ldexp
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);}
#endif #endif
@@ -834,7 +828,7 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lc
// log // log
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);}
#endif #endif
@@ -846,7 +840,7 @@ log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);}
// log10 // log10
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);}
#endif #endif
@@ -858,14 +852,14 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);}
// modf // modf
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);}
#endif #endif
// pow // pow
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);}
#endif #endif
@@ -888,7 +882,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// sin // sin
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);}
#endif #endif
@@ -900,7 +894,7 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);}
// sinh // sinh
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);}
#endif #endif
@@ -912,21 +906,19 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);}
// sqrt // sqrt
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);}
#endif #endif
#endif // __sun__
template <class _A1> template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
typename std::enable_if<std::is_integral<_A1>::value, double>::type typename std::enable_if<std::is_integral<_A1>::value, double>::type
sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);}
#ifndef __sun__
// tan // tan
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);}
#endif #endif
@@ -938,7 +930,7 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);}
// tanh // tanh
#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) #if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);}
#endif #endif
@@ -1410,7 +1402,6 @@ typename std::enable_if<std::is_integral<_A1>::value, double>::type
trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);}
#endif // !_LIBCPP_MSVCRT #endif // !_LIBCPP_MSVCRT
#endif // __sun__
} // extern "C++" } // extern "C++"

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More