Merge to upstream r244462.

Change-Id: I97e4a2e1d843ad20a9225a31bacc7b1a6e9d8f4f
This commit is contained in:
Dan Albert
2015-10-19 14:37:53 -07:00
607 changed files with 20116 additions and 6501 deletions

View File

@@ -3,18 +3,21 @@
#===============================================================================
# Setup Project
#===============================================================================
project(libcxx CXX C)
cmake_minimum_required(VERSION 2.8)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang
endif()
project(libcxx CXX C)
set(PACKAGE_NAME libcxx)
set(PACKAGE_VERSION trunk-svn)
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
# Add path for custom modules
set(CMAKE_MODULE_PATH
@@ -30,45 +33,95 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LIBCXX_LIBDIR_SUFFIX "" CACHE STRING
"Define suffix of library directory name (32/64)")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
set(LIBCXX_BUILT_STANDALONE 1)
else()
set(LIBCXX_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX})
# Find the LLVM sources and simulate LLVM CMake options.
include(HandleOutOfTreeLLVM)
if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND)
message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: "
"llvm-config not found and LLVM_PATH not defined.\n"
"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
"or -DLLVM_PATH=path/to/llvm-source-root.")
endif()
#===============================================================================
# Setup CMake Options
#===============================================================================
# Define options.
# Basic options ---------------------------------------------------------------
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
"Define suffix of library directory name (32/64)")
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
# ABI Library options ---------------------------------------------------------
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
"Specify C++ ABI library to use." FORCE)
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
# Build libc++abi with libunwind. We need this option to determine whether to
# link with libunwind or libgcc_s while running the test cases.
option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF)
# Target options --------------------------------------------------------------
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
# Feature options -------------------------------------------------------------
option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF)
option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON)
option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON)
option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON)
option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON)
option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF)
option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON)
option(LIBCXX_ENABLE_MONOTONIC_CLOCK
"Build libc++ with support for a monotonic clock.
This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON)
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF)
set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
if (LIBCXX_BUILT_STANDALONE)
set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build the library and tests")
# Misc options ----------------------------------------------------------------
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
"The Profile-rt library used to build with code coverage")
#===============================================================================
# Check option configurations
#===============================================================================
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when
# LIBCXX_ENABLE_THREADS is on.
if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
endif()
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
# is ON.
if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
endif()
# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS)
# and check that we can build with 32 bits if requested.
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM
message(STATUS "Building 32 bits executables and libraries.")
endif()
elseif(LIBCXX_BUILD_32_BITS)
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
endif()
# Check that this option is not enabled on Apple and emit a usage warning.
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
if (APPLE)
message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
@@ -77,23 +130,6 @@ if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
endif()
endif()
set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++)
if (NOT LIBCXX_CXX_ABI)
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_LIBCXXABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
set(LIBCXX_CXX_ABI_INTREE 1)
else ()
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif ()
else ()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
endif ()
set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING
"Specify C++ ABI library to use." FORCE)
set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
#===============================================================================
# Configure System
#===============================================================================
@@ -103,202 +139,155 @@ set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
# Declare libc++ configuration variables.
# They are intended for use as follows:
# LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
# LIBCXX_COMPILE_FLAGS: Compile only flags.
# LIBCXX_LINK_FLAGS: Linker only flags.
set(LIBCXX_CXX_FLAGS "")
set(LIBCXX_COMPILE_FLAGS "")
set(LIBCXX_LINK_FLAGS "")
set(LIBCXX_LIBRARIES "")
# Configure compiler.
include(config-ix)
# Configure ABI library
include(HandleLibCXXABI)
# Configure coverage options.
if (LIBCXX_GENERATE_COVERAGE)
include(CodeCoverage)
set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
#===============================================================================
# Setup Compiler Flags
#===============================================================================
# Get required flags.
include(HandleLibCXXABI) # Steup the ABI library flags
# Include macros for adding and removing libc++ flags.
include(HandleLibcxxFlags)
# Remove flags that may have snuck in.
remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
-stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
# Required flags ==============================================================
add_compile_flags_if_supported(-std=c++11)
if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG)
message(FATAL_ERROR "C++11 is required but the compiler does not support -std=c++11")
endif()
# On all systems the system c++ standard library headers need to be excluded.
if (MSVC)
# MSVC only has -X, which disables all default includes; including the crt.
# Thus, we do nothing and hope we don't accidentally include any of the C++
# headers.
else()
if (LIBCXX_HAS_NOSTDINCXX_FLAG)
list(APPEND LIBCXX_COMPILE_FLAGS -nostdinc++)
string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# If c++1y has been enabled then attempt to use it. Fail if it is no supported
# by the compiler. Otherwise choose c++11 and ensure the compiler supports it.
if (LIBCXX_ENABLE_CXX1Y)
if (LIBCXX_HAS_STDCXX1Y_FLAG)
set(LIBCXX_STD_VERSION c++1y)
else()
message(FATAL_ERROR "c++1y was enabled but the compiler does not support it.")
endif()
else()
if (LIBCXX_HAS_STDCXX11_FLAG)
set(LIBCXX_STD_VERSION c++11)
else()
message(FATAL_ERROR "c++11 is required by libc++ but is not supported by the compiler")
endif()
endif()
# LIBCXX_STD_VERSION should always be set at this point.
list(APPEND LIBCXX_CXX_FLAGS "-std=${LIBCXX_STD_VERSION}")
endif()
# MSVC only has -X, which disables all default includes; including the crt.
# Thus, we do nothing and hope we don't accidentally include any of the C++
# headers
add_compile_flags_if_supported(-nostdinc++)
macro(append_if list condition var)
if (${condition})
list(APPEND ${list} ${var})
endif()
endmacro()
# Target flags ================================================================
add_flags_if(LIBCXX_BUILD_32_BITS -m32)
add_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}")
add_flags_if(LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
add_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
# Get warning flags
if (NOT MSVC)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WALL_FLAG -Wall)
list(APPEND LIBCXX_COMPILE_FLAGS -Werror=return-type)
endif()
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_W_FLAG -W)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
# Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
add_compile_flags_if_supported(
-Wall -W -Wwrite-strings
-Wno-unused-parameter -Wno-long-long
-Werror=return-type)
if (LIBCXX_ENABLE_WERROR)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WX_FLAG -WX)
add_compile_flags_if_supported(-Werror)
add_compile_flags_if_supported(-WX)
else()
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_ERROR_FLAG -Wno-error)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_NO_WX_FLAG -WX-)
# TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is
# added elsewhere.
add_compile_flags_if_supported(-Wno-error)
endif()
if (LIBCXX_ENABLE_PEDANTIC)
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic)
add_compile_flags_if_supported(-pedantic)
endif()
# Get feature flags.
# Exceptions
# Exception flags =============================================================
if (LIBCXX_ENABLE_EXCEPTIONS)
# Catches C++ exceptions only and tells the compiler to assume that extern C
# functions never throw a C++ exception.
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc)
add_compile_flags_if_supported(-EHsc)
else()
list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_EXCEPTIONS)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions)
add_definitions(-D_LIBCPP_NO_EXCEPTIONS)
add_compile_flags_if_supported(-EHs- -EHa-)
add_compile_flags_if_supported(-fno-exceptions)
endif()
# RTTI
# RTTI flags ==================================================================
if (NOT LIBCXX_ENABLE_RTTI)
list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_RTTI)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti)
add_definitions(-D_LIBCPP_NO_RTTI)
add_compile_flags_if_supported(-GR-)
add_compile_flags_if_supported(-fno-rtti)
endif()
# Assert
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
# Assertion flags =============================================================
define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG)
define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG)
if (LIBCXX_ENABLE_ASSERTIONS)
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if (NOT MSVC)
list(APPEND LIBCXX_COMPILE_FLAGS -D_DEBUG)
endif()
# On Release builds cmake automatically defines NDEBUG, so we
# explicitly undefine it:
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
list(APPEND LIBCXX_COMPILE_FLAGS -UNDEBUG)
endif()
else()
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
list(APPEND LIBCXX_COMPILE_FLAGS -DNDEBUG)
endif()
endif()
# Static library
if (NOT LIBCXX_ENABLE_SHARED)
list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
define_if_not(MSVC -D_DEBUG)
endif()
if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32)
if (LIBCXX_BUILD_32_BITS)
message(STATUS "Building 32 bits executables and libraries.")
list(APPEND LIBCXX_CXX_FLAGS "-m32")
endif()
elseif(LIBCXX_BUILD_32_BITS)
message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.")
endif()
# This is the _ONLY_ place where add_definitions is called.
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# Feature flags ===============================================================
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE -D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
define_if_not(LIBCXX_ENABLE_STDIN -D_LIBCPP_HAS_NO_STDIN)
define_if_not(LIBCXX_ENABLE_STDOUT -D_LIBCPP_HAS_NO_STDOUT)
define_if_not(LIBCXX_ENABLE_THREADS -D_LIBCPP_HAS_NO_THREADS)
define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK -D_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS -D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS)
# LIBCXX_ENABLE_THREADS configuration
if (NOT LIBCXX_ENABLE_THREADS)
add_definitions(-D_LIBCPP_HAS_NO_THREADS)
if (NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
add_definitions(-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
endif()
# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON.
elseif(NOT LIBCXX_ENABLE_MONOTONIC_CLOCK)
message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF"
" when LIBCXX_ENABLE_THREADS is also set to OFF.")
endif()
# Sanitizer flags
# Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do
# the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it.
if (LIBCXX_BUILT_STANDALONE)
set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build the library and tests")
# NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC.
# But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do.
if (LLVM_USE_SANITIZER AND NOT MSVC)
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG
"-fno-omit-frame-pointer")
add_flags_if_supported("-fno-omit-frame-pointer")
add_flags_if_supported("-gline-tables-only")
if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND
NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG
"-gline-tables-only")
add_flags_if_supported("-gline-tables-only")
endif()
if (LLVM_USE_SANITIZER STREQUAL "Address")
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=address")
add_flags("-fsanitize=address")
elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=memory")
add_flags(-fsanitize=memory)
if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins")
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize-memory-track-origins")
add_flags("-fsanitize-memory-track-origins")
endif()
elseif (LLVM_USE_SANITIZER STREQUAL "Undefined")
list(APPEND LIBCXX_CXX_FLAGS
"-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover")
add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
elseif (LLVM_USE_SANITIZER STREQUAL "Thread")
list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=thread")
add_flags(-fsanitize=thread)
else()
message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
elseif(MSVC)
message(WARNING "LLVM_USE_SANITIZER is not supported with MSVC")
elseif(LLVM_USE_SANITIZER AND MSVC)
message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.")
endif()
endif()
append_if(LIBCXX_CXX_FLAGS LIBCXX_TARGET_TRIPLE
"-target ${LIBCXX_TARGET_TRIPLE}")
append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN
"-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}")
#===============================================================================
# Setup Source Code
# Setup Source Code And Tests
#===============================================================================
include_directories(include)
add_subdirectory(include)
# Add source code. This also contains all of the logic for deciding linker flags
# soname, etc...
add_subdirectory(lib)
#===============================================================================
# Setup Tests
#===============================================================================
add_subdirectory(test)
if (LIBCXX_INCLUDE_TESTS)
add_subdirectory(test)
endif()

View File

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

49
TODO.TXT Normal file
View File

@@ -0,0 +1,49 @@
This is meant to be a general place to list things that should be done "someday"
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
=========================
* 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 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++
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
linux. Do this for every supported c++ runtime library.
Atomic Related Tasks
====================
* Support <atomic> in C++03 (needed for internal use).
* Audit use of libatomic builtins in <atomic> with GCC.
* future should use <atomic> for synchronization.
* call_once should use <atomic> for synchronization.
* Audit shared_ptr use of <atomic>
Test Suite Tasks
================
* Get test suite passing in C++03.
* 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.
Misc Tasks
==========
* Find all sequences of >2 underscores and eradicate them.
* run clang-tidy on libc++
* Document the "conditionally-supported" bits of libc++
* Look at basic_string's move assignment operator, re LWG 2063 and POCMA
* libc++ is missing try_emplace
* Put a static_assert in std::allocator to deny const/volatile types (LWG 2447)
* Investigate the effect of using __decltype instead of __typeof__ to provide
decltype in C++03. What code could be broken by this change?
* Convert failure tests to use Clang Verify.
* Document support (or lack of) for C++11 libraries in C++03.
* Document supported compilers.

View File

@@ -0,0 +1,36 @@
find_program(CODE_COVERAGE_LCOV lcov)
if (NOT CODE_COVERAGE_LCOV)
message(FATAL_ERROR "Cannot find lcov...")
endif()
find_program(CODE_COVERAGE_GENHTML genhtml)
if (NOT CODE_COVERAGE_GENHTML)
message(FATAL_ERROR "Cannot find genhtml...")
endif()
set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage")
function(setup_lcov_test_target_coverage target_name output_dir capture_dirs source_dirs)
file(MAKE_DIRECTORY ${output_dir})
set(CAPTURE_DIRS "")
foreach(cdir ${capture_dirs})
list(APPEND CAPTURE_DIRS "-d;${cdir}")
endforeach()
set(EXTRACT_DIRS "")
foreach(sdir ${source_dirs})
list(APPEND EXTRACT_DIRS "'${sdir}/*'")
endforeach()
message(STATUS "Capture Directories: ${CAPTURE_DIRS}")
message(STATUS "Extract Directories: ${EXTRACT_DIRS}")
add_custom_target(generate-lib${target_name}-coverage
COMMAND ${CODE_COVERAGE_LCOV} --capture ${CAPTURE_DIRS} -o test_coverage.info
COMMAND ${CODE_COVERAGE_LCOV} --extract test_coverage.info ${EXTRACT_DIRS} -o test_coverage.info
COMMAND ${CODE_COVERAGE_GENHTML} --demangle-cpp test_coverage.info -o test_coverage
COMMAND ${CMAKE_COMMAND} -E remove test_coverage.info
WORKING_DIRECTORY ${output_dir}
COMMENT "Generating coverage results")
endfunction()

View File

@@ -15,9 +15,9 @@
# abidirs : A list of relative paths to create under an include directory
# in the libc++ build directory.
#
macro(setup_abi_lib abipathvar abidefines abilib abifiles abidirs)
macro(setup_abi_lib abidefines abilib abifiles abidirs)
list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
set(${abipathvar} "${${abipathvar}}"
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
CACHE PATH
"Paths to C++ ABI header directories separated by ';'." FORCE
)
@@ -33,7 +33,7 @@ macro(setup_abi_lib abipathvar abidefines abilib abifiles abidirs)
foreach(fpath ${LIBCXX_ABILIB_FILES})
set(found FALSE)
foreach(incpath ${${abipathvar}})
foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS})
if (EXISTS "${incpath}/${fpath}")
set(found TRUE)
get_filename_component(dstdir ${fpath} PATH)
@@ -58,6 +58,21 @@ macro(setup_abi_lib abipathvar abidefines abilib abifiles abidirs)
endmacro()
# Setup the default options if LIBCXX_CXX_ABI is not specified.
if (NOT LIBCXX_CXX_ABI)
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
set(LIBCXX_CXX_ABI_INTREE 1)
else ()
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif ()
else ()
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
endif ()
# Configure based on the selected ABI library.
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
"${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++")
set(_LIBSUPCXX_INCLUDE_FILES
@@ -71,7 +86,7 @@ if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
set(_LIBSUPCXX_DEFINES "")
set(_LIBSUPCXX_LIBNAME supc++)
endif()
setup_abi_lib("LIBCXX_LIBSUPCXX_INCLUDE_PATHS"
setup_abi_lib(
"-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
"${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
)
@@ -88,11 +103,11 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
# Assume c++abi is installed in the system, rely on -lc++abi link flag.
set(CXXABI_LIBNAME "c++abi")
endif()
setup_abi_lib("LIBCXX_LIBCXXABI_INCLUDE_PATHS" ""
setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI"
${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" ""
)
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
setup_abi_lib("LIBCXX_LIBCXXRT_INCLUDE_PATHS" "-DLIBCXXRT"
setup_abi_lib("-DLIBCXXRT"
"cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
)
elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")

View File

@@ -0,0 +1,147 @@
# HandleLibcxxFlags - A set of macros used to setup the flags used to compile
# and link libc++. These macros add flags to the following CMake variables.
# - LIBCXX_COMPILE_FLAGS: flags used to compile libc++
# - LIBCXX_LINK_FLAGS: flags used to link libc++
# - LIBCXX_LIBRARIES: libraries to link libc++ to.
include(CheckCXXCompilerFlag)
unset(add_flag_if_supported)
# Mangle the name of a compiler flag into a valid CMake identifier.
# Ex: --std=c++11 -> STD_EQ_CXX11
macro(mangle_name str output)
string(STRIP "${str}" strippedStr)
string(REGEX REPLACE "^/" "" strippedStr "${strippedStr}")
string(REGEX REPLACE "^-+" "" strippedStr "${strippedStr}")
string(REGEX REPLACE "-+$" "" strippedStr "${strippedStr}")
string(REPLACE "-" "_" strippedStr "${strippedStr}")
string(REPLACE "=" "_EQ_" strippedStr "${strippedStr}")
string(REPLACE "+" "X" strippedStr "${strippedStr}")
string(TOUPPER "${strippedStr}" ${output})
endmacro()
# Remove a list of flags from all CMake variables that affect compile flags.
# This can be used to remove unwanted flags specified on the command line
# or added in other parts of LLVM's cmake configuration.
macro(remove_flags)
foreach(var ${ARGN})
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_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_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS "${CMAKE_SHARED_MODULE_FLAGS}")
remove_definitions(${var})
endforeach()
endmacro(remove_flags)
# Add a macro definition if condition is true.
macro(define_if condition def)
if (${condition})
add_definitions(${def})
endif()
endmacro()
# Add a macro definition if condition is not true.
macro(define_if_not condition def)
if (NOT ${condition})
add_definitions(${def})
endif()
endmacro()
# Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and
# 'LIBCXX_LINK_FLAGS'.
macro(add_flags)
foreach(value ${ARGN})
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 both
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'.
macro(add_flags_if condition)
if (${condition})
add_flags(${ARGN})
endif()
endmacro()
# Add each flag in the list to LIBCXX_COMPILE_FLAGS and LIBCXX_LINK_FLAGS
# if that flag is supported by the current compiler.
macro(add_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
add_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()
# Add a list of flags to 'LIBCXX_COMPILE_FLAGS'.
macro(add_compile_flags)
foreach(f ${ARGN})
list(APPEND LIBCXX_COMPILE_FLAGS ${f})
endforeach()
endmacro()
# If 'condition' is true then add the specified list of flags to
# 'LIBCXX_COMPILE_FLAGS'
macro(add_compile_flags_if condition)
if (${condition})
add_compile_flags(${ARGN})
endif()
endmacro()
# For each specified flag, add that flag to 'LIBCXX_COMPILE_FLAGS' if the
# flag is supported by the C++ compiler.
macro(add_compile_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
add_compile_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()
# Add a list of flags to 'LIBCXX_LINK_FLAGS'.
macro(add_link_flags)
foreach(f ${ARGN})
list(APPEND LIBCXX_LINK_FLAGS ${f})
endforeach()
endmacro()
# If 'condition' is true then add the specified list of flags to
# 'LIBCXX_LINK_FLAGS'
macro(add_link_flags_if condition)
if (${condition})
add_link_flags(${ARGN})
endif()
endmacro()
# For each specified flag, add that flag to 'LIBCXX_LINK_FLAGS' if the
# flag is supported by the C++ compiler.
macro(add_link_flags_if_supported)
foreach(flag ${ARGN})
mangle_name("${flag}" flagname)
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
add_link_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
endforeach()
endmacro()
# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
macro(add_library_flags)
foreach(lib ${ARGN})
list(APPEND LIBCXX_LIBRARIES ${lib})
endforeach()
endmacro()
# if 'condition' is true then add the specified list of libraries and flags
# to 'LIBCXX_LIBRARIES'.
macro(add_library_flags_if condition)
if(${condition})
add_library_flags(${ARGN})
endif()
endmacro()
# Turn a comma separated CMake list into a space separated string.
macro(split_list listname)
string(REPLACE ";" " " ${listname} "${${listname}}")
endmacro()

View File

@@ -0,0 +1,96 @@
macro(find_llvm_parts)
# Rely on llvm-config.
set(CONFIG_OUTPUT)
find_program(LLVM_CONFIG "llvm-config")
if(DEFINED LLVM_PATH)
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_MAIN_SRC_DIR ${LLVM_PATH})
set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
elseif(LLVM_CONFIG)
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
set(CONFIG_COMMAND ${LLVM_CONFIG}
"--includedir"
"--prefix"
"--src-root")
execute_process(
COMMAND ${CONFIG_COMMAND}
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE CONFIG_OUTPUT
)
if(NOT HAD_ERROR)
string(REGEX REPLACE
"[ \t]*[\r\n]+[ \t]*" ";"
CONFIG_OUTPUT ${CONFIG_OUTPUT})
else()
string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
message(STATUS "${CONFIG_COMMAND_STR}")
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
endif()
list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR)
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_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
else()
set(LLVM_FOUND OFF)
return()
endif()
if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
message(FATAL_ERROR "Not found: ${LLVM_MAIN_SRC_DIR}")
endif()
if(NOT EXISTS ${LLVM_CMAKE_PATH})
message(FATAL_ERROR "Not found: ${LLVM_CMAKE_PATH}")
endif()
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
set(LLVM_FOUND ON)
endmacro(find_llvm_parts)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LIBCXX_BUILT_STANDALONE 1)
message(STATUS "Configuring for standalone build.")
find_llvm_parts()
# LLVM Options --------------------------------------------------------------
include(FindPythonInterp)
if( NOT PYTHONINTERP_FOUND )
message(WARNING "Failed to find python interpreter. "
"The libc++ test suite will be disabled.")
set(LLVM_INCLUDE_TESTS OFF)
endif()
if (NOT DEFINED LLVM_INCLUDE_TESTS)
set(LLVM_INCLUDE_TESTS ${LLVM_FOUND})
endif()
# Required LIT Configuration ------------------------------------------------
# Define the default arguments to use with 'lit', and an option for the user
# to override.
set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
if (MSVC OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
# 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()
# Add LLVM Functions --------------------------------------------------------
include(AddLLVM OPTIONAL)
endif()

View File

@@ -2,23 +2,7 @@ include(CheckLibraryExists)
include(CheckCXXCompilerFlag)
# Check compiler flags
check_cxx_compiler_flag(-std=c++11 LIBCXX_HAS_STDCXX11_FLAG)
check_cxx_compiler_flag(-std=c++1y LIBCXX_HAS_STDCXX1Y_FLAG)
check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG)
check_cxx_compiler_flag(-fno-omit-frame-pointer LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG)
check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG)
check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG)
check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG)
check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG)
check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG)
check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG)
check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG)
check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG)
check_cxx_compiler_flag(-Wno-error LIBCXX_HAS_WNO_ERROR_FLAG)
check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG)
check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG)
check_cxx_compiler_flag(-gline-tables-only LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG)
check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG)
check_cxx_compiler_flag(/WX- LIBCXX_HAS_NO_WX_FLAG)
check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG)
@@ -26,6 +10,7 @@ check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG)
check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG)
check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
# Check libraries
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
check_library_exists(c printf "" LIBCXX_HAS_C_LIB)

View File

@@ -17,13 +17,11 @@
#ifdef __GNUC__
#define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
#else
#define _GNUC_VER 0
#endif
#if !_WIN32
#include <unistd.h>
#endif
#define _LIBCPP_VERSION 1101
#define _LIBCPP_VERSION 3800
#define _LIBCPP_ABI_VERSION 1
@@ -32,6 +30,23 @@
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(__x) 0
#endif
#ifndef __has_feature
#define __has_feature(__x) 0
#endif
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
// the compiler and '1' otherwise.
#ifndef __is_identifier
#define __is_identifier(__x) 1
#endif
#ifdef __LITTLE_ENDIAN__
#if __LITTLE_ENDIAN__
#define _LIBCPP_LITTLE_ENDIAN 1
@@ -75,10 +90,8 @@
#ifdef _WIN32
# define _LIBCPP_LITTLE_ENDIAN 1
# define _LIBCPP_BIG_ENDIAN 0
// Compiler intrinsics (GCC or MSVC)
# if defined(__clang__) \
|| (defined(_MSC_VER) && _MSC_VER >= 1400) \
|| (defined(__GNUC__) && _GNUC_VER > 403)
// Compiler intrinsics (MSVC)
#if defined(_MSC_VER) && _MSC_VER >= 1400
# define _LIBCPP_HAS_IS_BASE_OF
# endif
# if defined(_MSC_VER) && !defined(__clang__)
@@ -93,12 +106,6 @@
# endif
#endif // _WIN32
#ifdef __linux__
# if defined(__GNUC__) && _GNUC_VER >= 403
# define _LIBCPP_HAS_IS_BASE_OF
# endif
#endif
#ifdef __sun__
# include <sys/isa_defs.h>
# ifdef _LITTLE_ENDIAN
@@ -110,12 +117,22 @@
# endif
#endif // __sun__
#if defined(__native_client__)
#if defined(__CloudABI__)
// Certain architectures provide arc4random(). Prefer using
// arc4random() over /dev/{u,}random to make it possible to obtain
// random data even when using sandboxing mechanisms such as chroots,
// Capsicum, etc.
# define _LIBCPP_USING_ARC4_RANDOM
#elif defined(__native_client__)
// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
// including accesses to the special files under /dev. C++11's
// std::random_device is instead exposed through a NaCl syscall.
# define _LIBCPP_USING_NACL_RANDOM
#endif // defined(__native_client__)
#elif defined(_WIN32)
# define _LIBCPP_USING_WIN32_RANDOM
#else
# define _LIBCPP_USING_DEV_RANDOM
#endif
#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
# include <endian.h>
@@ -172,10 +189,6 @@
#endif // _WIN32
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef _LIBCPP_HIDDEN
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
#endif
@@ -308,6 +321,10 @@ typedef __char32_t char32_t;
# define _LIBCPP_HAS_IS_BASE_OF
#endif
#if __has_feature(is_final)
# define _LIBCPP_HAS_IS_FINAL
#endif
// Objective-C++ features (opt-in)
#if __has_feature(objc_arc)
#define _LIBCPP_HAS_OBJC_ARC
@@ -326,6 +343,10 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#endif
#if !(__has_feature(cxx_variable_templates))
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#endif
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
#if defined(__FreeBSD__)
#define _LIBCPP_HAS_QUICK_EXIT
@@ -387,6 +408,11 @@ namespace std {
#if _GNUC_VER >= 407
#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
#define _LIBCPP_HAS_IS_FINAL
#endif
#if defined(__GNUC__) && _GNUC_VER >= 403
# define _LIBCPP_HAS_IS_BASE_OF
#endif
#if !__EXCEPTIONS
@@ -405,6 +431,8 @@ namespace std {
// No version of GCC supports relaxed constexpr rules
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
// GCC 5 will support variable templates
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#define _NOEXCEPT throw()
#define _NOEXCEPT_(x)
@@ -476,6 +504,7 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_DELETED_FUNCTIONS
#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
@@ -518,6 +547,8 @@ namespace std {
#define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_IS_BASE_OF
#define _LIBCPP_HAS_IS_FINAL
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#if defined(_AIX)
#define __MULTILOCALE_API
@@ -557,7 +588,12 @@ template <unsigned> struct __static_assert_check {};
#endif // _LIBCPP_HAS_NO_STATIC_ASSERT
#ifdef _LIBCPP_HAS_NO_DECLTYPE
#define decltype(x) __typeof__(x)
// GCC 4.6 provides __decltype in all standard modes.
#if !__is_identifier(__decltype) || _GNUC_VER >= 406
# define decltype(__x) __decltype(__x)
#else
# define decltype(__x) __typeof__(__x)
#endif
#endif
#ifdef _LIBCPP_HAS_NO_CONSTEXPR
@@ -578,14 +614,6 @@ template <unsigned> struct __static_assert_check {};
#define _NOALIAS
#endif
#ifndef __has_feature
#define __has_feature(__x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(__x) 0
#endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__)
# define _LIBCPP_EXPLICIT explicit
#else
@@ -621,7 +649,7 @@ template <unsigned> struct __static_assert_check {};
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE
#define _LIBCPP_EXTERN_TEMPLATE(...)
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#endif
#ifndef _LIBCPP_EXTERN_TEMPLATE2
@@ -632,10 +660,16 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
#endif
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION) && \
!defined(__CloudABI__)
#define _LIBCPP_HAS_CATOPEN 1
#endif
#ifdef __FreeBSD__
#define _DECLARE_C99_LDBL_MATH 1
#endif
@@ -708,8 +742,29 @@ extern "C" void __sanitizer_annotate_contiguous_container(
_LIBCPP_HAS_NO_THREADS is defined.
#endif
#if defined(__ANDROID__)
// Systems that use capability-based security (FreeBSD with Capsicum,
// Nuxi CloudABI) may only provide local filesystem access (using *at()).
// Functions like open(), rename(), unlink() and stat() should not be
// used, as they attempt to access the global filesystem namespace.
#ifdef __CloudABI__
#define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
#endif
// CloudABI is intended for running networked services. Processes do not
// have standard input and output channels.
#ifdef __CloudABI__
#define _LIBCPP_HAS_NO_STDIN
#define _LIBCPP_HAS_NO_STDOUT
#endif
#if defined(__ANDROID__) || defined(__CloudABI__)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif
// Thread-unsafe functions such as strtok(), mbtowc() and localtime()
// are not available.
#ifdef __CloudABI__
#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
#endif
#endif // _LIBCPP_CONFIG

View File

@@ -22,7 +22,7 @@
# include <cstdio>
# include <cstddef>
# ifndef _LIBCPP_ASSERT
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::printf("%s\n", m), _VSTD::abort()))
# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort()))
# endif
#endif

View File

@@ -17,218 +17,7 @@
#pragma GCC system_header
#endif
template <class _Tp>
class __mem_fn
: public __weak_result_type<_Tp>
{
public:
// types
typedef _Tp type;
private:
type __f_;
public:
_LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
// invoke
typename __invoke_return<type>::type
operator() () const
{
return __invoke(__f_);
}
template <class _A0>
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const
{
return __invoke(__f_, __a0);
}
template <class _A0, class _A1>
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const
{
return __invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1, class _A2>
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
{
return __invoke(__f_, __a0, __a1, __a2);
}
};
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp _Tp::*>
mem_fn(_Rp _Tp::* __pm)
{
return __mem_fn<_Rp _Tp::*>(__pm);
}
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)()>
mem_fn(_Rp (_Tp::* __pm)())
{
return __mem_fn<_Rp (_Tp::*)()>(__pm);
}
template<class _Rp, class _Tp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0)>
mem_fn(_Rp (_Tp::* __pm)(_A0))
{
return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1)>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1))
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2))
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm);
}
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)() const>
mem_fn(_Rp (_Tp::* __pm)() const)
{
return __mem_fn<_Rp (_Tp::*)() const>(__pm);
}
template<class _Rp, class _Tp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0) const>
mem_fn(_Rp (_Tp::* __pm)(_A0) const)
{
return __mem_fn<_Rp (_Tp::*)(_A0) const>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1) const>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>(__pm);
}
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)() volatile>
mem_fn(_Rp (_Tp::* __pm)() volatile)
{
return __mem_fn<_Rp (_Tp::*)() volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0) volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0) volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0) volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>(__pm);
}
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)() const volatile>
mem_fn(_Rp (_Tp::* __pm)() const volatile)
{
return __mem_fn<_Rp (_Tp::*)() const volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0) const volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0) const volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0) const volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>(__pm);
}
template<class _Rp, class _Tp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>
mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const volatile)
{
return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>(__pm);
}
// bad_function_call
class _LIBCPP_EXCEPTION_ABI bad_function_call
: public exception
{
};
template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
namespace __function
{
template<class _Fp>
struct __maybe_derive_from_unary_function
{
};
template<class _Rp, class _A1>
struct __maybe_derive_from_unary_function<_Rp(_A1)>
: public unary_function<_A1, _Rp>
{
};
template<class _Fp>
struct __maybe_derive_from_binary_function
{
};
template<class _Rp, class _A1, class _A2>
struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
namespace __function {
template<class _Fp> class __base;
@@ -333,7 +122,8 @@ template<class _Fp, class _Alloc, class _Rp>
__base<_Rp()>*
__func<_Fp, _Alloc, _Rp()>::__clone() const
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -359,7 +149,8 @@ template<class _Fp, class _Alloc, class _Rp>
void
__func<_Fp, _Alloc, _Rp()>::destroy_deallocate()
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -417,7 +208,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
__base<_Rp(_A0)>*
__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -443,7 +235,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0>
void
__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate()
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -501,7 +294,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
__base<_Rp(_A0, _A1)>*
__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -527,7 +321,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1>
void
__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate()
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -585,7 +380,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
__base<_Rp(_A0, _A1, _A2)>*
__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -611,7 +407,8 @@ template<class _Fp, class _Alloc, class _Rp, class _A0, class _A1, class _A2>
void
__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate()
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -794,17 +591,11 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(__f);
::new (__f_) _FF(__f, __a0);
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -831,6 +622,7 @@ function<_Rp()>::operator=(nullptr_t)
else if (__f_)
__f_->destroy_deallocate();
__f_ = 0;
return *this;
}
template<class _Rp>
@@ -1096,17 +888,11 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(__f);
::new (__f_) _FF(__f, __a0);
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1133,6 +919,7 @@ function<_Rp(_A0)>::operator=(nullptr_t)
else if (__f_)
__f_->destroy_deallocate();
__f_ = 0;
return *this;
}
template<class _Rp, class _A0>
@@ -1398,17 +1185,11 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f,
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(__f);
::new (__f_) _FF(__f, __a0);
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1435,6 +1216,7 @@ function<_Rp(_A0, _A1)>::operator=(nullptr_t)
else if (__f_)
__f_->destroy_deallocate();
__f_ = 0;
return *this;
}
template<class _Rp, class _A0, class _A1>
@@ -1700,17 +1482,11 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp
if (sizeof(_FF) <= sizeof(__buf_))
{
__f_ = (__base*)&__buf_;
::new (__f_) _FF(__f);
::new (__f_) _FF(__f, __a0);
}
else
{
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1737,6 +1513,7 @@ function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t)
else if (__f_)
__f_->destroy_deallocate();
__f_ = 0;
return *this;
}
template<class _Rp, class _A0, class _A1, class _A2>
@@ -1868,272 +1645,4 @@ void
swap(function<_Fp>& __x, function<_Fp>& __y)
{return __x.swap(__y);}
template<class _Tp> struct __is_bind_expression : public false_type {};
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
: public __is_bind_expression<typename remove_cv<_Tp>::type> {};
template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder
: public __is_placeholder<typename remove_cv<_Tp>::type> {};
namespace placeholders
{
template <int _Np> struct __ph {};
extern __ph<1> _1;
extern __ph<2> _2;
extern __ph<3> _3;
extern __ph<4> _4;
extern __ph<5> _5;
extern __ph<6> _6;
extern __ph<7> _7;
extern __ph<8> _8;
extern __ph<9> _9;
extern __ph<10> _10;
} // placeholders
template<int _Np>
struct __is_placeholder<placeholders::__ph<_Np> >
: public integral_constant<int, _Np> {};
template <class _Tp, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
__mu(reference_wrapper<_Tp> __t, _Uj&)
{
return __t.get();
}
/*
template <bool _IsBindExpr, class _Ti, class ..._Uj>
struct __mu_return1 {};
template <class _Ti, class ..._Uj>
struct __mu_return1<true, _Ti, _Uj...>
{
typedef typename result_of<_Ti(_Uj...)>::type type;
};
template <class _Ti, class ..._Uj, size_t ..._Indx>
inline _LIBCPP_INLINE_VISIBILITY
typename __mu_return1<true, _Ti, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>)
{
__ti(_VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj))...);
}
template <class _Ti, class ..._Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_bind_expression<_Ti>::value,
typename __mu_return1<is_bind_expression<_Ti>::value, _Ti, _Uj...>::type
>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
return __mu_expand(__ti, __uj, __indices());
}
template <bool IsPh, class _Ti, class _Uj>
struct __mu_return2 {};
template <class _Ti, class _Uj>
struct __mu_return2<true, _Ti, _Uj>
{
typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
};
template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
0 < is_placeholder<_Ti>::value,
typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
>::type
__mu(_Ti&, _Uj& __uj)
{
const size_t _Indx = is_placeholder<_Ti>::value - 1;
// compiler bug workaround
typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj);
return __t;
// return _VSTD::forward<typename tuple_element<_Indx, _Uj>::type>(_VSTD::get<_Indx>(__uj));
}
template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
!is_bind_expression<_Ti>::value &&
is_placeholder<_Ti>::value == 0 &&
!__is_reference_wrapper<_Ti>::value,
_Ti&
>::type
__mu(_Ti& __ti, _Uj& __uj)
{
return __ti;
}
template <class _Ti, bool IsBindEx, bool IsPh, class _TupleUj>
struct ____mu_return;
template <class _Ti, class ..._Uj>
struct ____mu_return<_Ti, true, false, tuple<_Uj...> >
{
typedef typename result_of<_Ti(_Uj...)>::type type;
};
template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, true, _TupleUj>
{
typedef typename tuple_element<is_placeholder<_Ti>::value - 1,
_TupleUj>::type&& type;
};
template <class _Ti, class _TupleUj>
struct ____mu_return<_Ti, false, false, _TupleUj>
{
typedef _Ti& type;
};
template <class _Ti, class _TupleUj>
struct __mu_return
: public ____mu_return<_Ti,
is_bind_expression<_Ti>::value,
0 < is_placeholder<_Ti>::value,
_TupleUj>
{
};
template <class _Ti, class _TupleUj>
struct __mu_return<reference_wrapper<_Ti>, _TupleUj>
{
typedef _Ti& type;
};
template <class _Fp, class _BoundArgs, class _TupleUj>
struct __bind_return;
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
typedef typename __ref_return
<
_Fp&,
typename __mu_return
<
_BoundArgs,
_TupleUj
>::type...
>::type type;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
typedef typename __ref_return
<
_Fp&,
typename __mu_return
<
const _BoundArgs,
_TupleUj
>::type...
>::type type;
};
template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
inline _LIBCPP_INLINE_VISIBILITY
typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
_Args&& __args)
{
return __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...);
}
template<class _Fp, class ..._BoundArgs>
class __bind
{
_Fp __f_;
tuple<_BoundArgs...> __bound_args_;
typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
template <class _Gp, class ..._BA>
explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
: __f_(_VSTD::forward<_Gp>(__f)),
__bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
operator()(_Args&& ...__args)
{
// compiler bug workaround
return __apply_functor(__f_, __bound_args_, __indices(),
tuple<_Args&&...>(__args...));
}
template <class ..._Args>
typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type
operator()(_Args&& ...__args) const
{
return __apply_functor(__f_, __bound_args_, __indices(),
tuple<_Args&&...>(__args...));
}
};
template<class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
template<class _Rp, class _Fp, class ..._BoundArgs>
class __bind_r
: public __bind<_Fp, _BoundArgs...>
{
typedef __bind<_Fp, _BoundArgs...> base;
public:
typedef _Rp result_type;
template <class _Gp, class ..._BA>
explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
: base(_VSTD::forward<_Gp>(__f),
_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
result_type
operator()(_Args&& ...__args)
{
return base::operator()(_VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
result_type
operator()(_Args&& ...__args) const
{
return base::operator()(_VSTD::forward<_Args>(__args)...);
}
};
template<class _Rp, class _Fp, class ..._BoundArgs>
struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
template<class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind<typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}
template<class _Rp, class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY
__bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type;
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}
*/
#endif // _LIBCPP_FUNCTIONAL_03

View File

@@ -127,11 +127,6 @@ addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT
}
#endif
#ifdef _LIBCPP_HAS_NO_VARIADICS
#include <__functional_base_03>
#else // _LIBCPP_HAS_NO_VARIADICS
// __weak_result_type
@@ -314,6 +309,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
{
};
#ifndef _LIBCPP_HAS_NO_VARIADICS
// 3 or more arguments
template <class _Rp, class _A1, class _A2, class _A3, class ..._A4>
@@ -358,8 +355,12 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile>
typedef _Rp result_type;
};
#endif // _LIBCPP_HAS_NO_VARIADICS
// __invoke
#ifndef _LIBCPP_HAS_NO_VARIADICS
// bullets 1 and 2
template <class _Fp, class _A0, class ..._Args,
@@ -414,31 +415,79 @@ __invoke(_Fp&& __f, _Args&& ...__args)
{
return _VSTD::forward<_Fp>(__f)(_VSTD::forward<_Args>(__args)...);
}
template <class _Tp, class ..._Args>
struct __invoke_return
{
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type;
};
#else // _LIBCPP_HAS_NO_VARIADICS
#include <__functional_base_03>
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Ret>
struct __invoke_void_return_wrapper
{
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class ..._Args>
static _Ret __call(_Args&&... __args)
{
static _Ret __call(_Args&&... __args) {
return __invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static _Ret __call(_Fn __f) {
return __invoke(__f);
}
template <class _Fn, class _A0>
static _Ret __call(_Fn __f, _A0& __a0) {
return __invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) {
return __invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){
return __invoke(__f, __a0, __a1, __a2);
}
#endif
};
template <>
struct __invoke_void_return_wrapper<void>
{
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class ..._Args>
static void __call(_Args&&... __args)
{
static void __call(_Args&&... __args) {
__invoke(_VSTD::forward<_Args>(__args)...);
}
#else
template <class _Fn>
static void __call(_Fn __f) {
__invoke(__f);
}
template <class _Fn, class _A0>
static void __call(_Fn __f, _A0& __a0) {
__invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static void __call(_Fn __f, _A0& __a0, _A1& __a1) {
__invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) {
__invoke(__f, __a0, __a1, __a2);
}
#endif
};
template <class _Tp>
@@ -463,6 +512,7 @@ public:
_LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;}
_LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;}
#ifndef _LIBCPP_HAS_NO_VARIADICS
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY
@@ -471,6 +521,39 @@ public:
{
return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...);
}
#else
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type>::type
operator() () const
{
return __invoke(get());
}
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type&, _A0>::type
operator() (_A0& __a0) const
{
return __invoke<type&, _A0>(get(), __a0);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type&, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const
{
return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type&, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
{
return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
}
#endif // _LIBCPP_HAS_NO_VARIADICS
};
template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
@@ -510,6 +593,7 @@ cref(reference_wrapper<_Tp> __t) _NOEXCEPT
return cref(__t.get());
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS

View File

@@ -13,404 +13,7 @@
// manual variadic expansion for <functional>
// __weak_result_type
template <class _Tp>
struct __derives_from_unary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _Ap, class _Rp>
static unary_function<_Ap, _Rp>
__test(const volatile unary_function<_Ap, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp>
struct __derives_from_binary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _A1, class _A2, class _Rp>
static binary_function<_A1, _A2, _Rp>
__test(const volatile binary_function<_A1, _A2, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
struct __maybe_derive_from_unary_function // bool is true
: public __derives_from_unary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_unary_function<_Tp, false>
{
};
template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
struct __maybe_derive_from_binary_function // bool is true
: public __derives_from_binary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_binary_function<_Tp, false>
{
};
template <class _Tp, bool = __has_result_type<_Tp>::value>
struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
typedef typename _Tp::result_type result_type;
};
template <class _Tp>
struct __weak_result_type_imp<_Tp, false>
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
};
template <class _Tp>
struct __weak_result_type
: public __weak_result_type_imp<typename remove_reference<_Tp>::type>
{
};
// 0 argument case
template <class _Rp>
struct __weak_result_type<_Rp ()>
{
typedef _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (&)()>
{
typedef _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (*)()>
{
typedef _Rp result_type;
};
// 1 argument case
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (&)(_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _A1>
struct __weak_result_type<_Rp (*)(_A1)>
: public unary_function<_A1, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)()>
: public unary_function<_Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const>
: public unary_function<const _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() volatile>
: public unary_function<volatile _Cp*, _Rp>
{
};
template <class _Rp, class _Cp>
struct __weak_result_type<_Rp (_Cp::*)() const volatile>
: public unary_function<const volatile _Cp*, _Rp>
{
};
// 2 argument case
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (*)(_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _A1, class _A2>
struct __weak_result_type<_Rp (&)(_A1, _A2)>
: public binary_function<_A1, _A2, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1)>
: public binary_function<_Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const>
: public binary_function<const _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile>
: public binary_function<volatile _Cp*, _A1, _Rp>
{
};
template <class _Rp, class _Cp, class _A1>
struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile>
: public binary_function<const volatile _Cp*, _A1, _Rp>
{
};
// 3 or more arguments
template <class _Rp, class _A1, class _A2, class _A3>
struct __weak_result_type<_Rp (_A1, _A2, _A3)>
{
typedef _Rp result_type;
};
template <class _Rp, class _A1, class _A2, class _A3>
struct __weak_result_type<_Rp (&)(_A1, _A2, _A3)>
{
typedef _Rp result_type;
};
template <class _Rp, class _A1, class _A2, class _A3>
struct __weak_result_type<_Rp (*)(_A1, _A2, _A3)>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2)>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) const>
{
typedef _Rp result_type;
};
template <class _Rp, class _Cp, class _A1, class _A2>
struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) volatile>
{
typedef _Rp result_type;
};
// __invoke
// __ref_return0
//
// template <class _Tp, bool _HasResultType>
// struct ________ref_return0 // _HasResultType is true
// {
// typedef typename _Tp::result_type type;
// };
//
// template <class _Tp>
// struct ________ref_return0<_Tp, false>
// {
// typedef void type;
// };
//
// template <class _Tp, bool _IsClass>
// struct ____ref_return0 // _IsClass is true
// : public ________ref_return0<_Tp, __has_result_type<typename remove_cv<_Tp>::type>::value>
// {
// };
//
// template <class _Tp, bool _HasResultType>
// struct ______ref_return0 // _HasResultType is true
// {
// typedef typename __callable_type<_Tp>::result_type type;
// };
//
// template <class _Tp>
// struct ______ref_return0<_Tp, false> // pointer to member data
// {
// typedef void type;
// };
//
// template <class _Tp>
// struct ____ref_return0<_Tp, false>
// : public ______ref_return0<typename remove_cv<_Tp>::type,
// __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value>
// {
// };
//
// template <class _Tp>
// struct __ref_return0
// : public ____ref_return0<typename remove_reference<_Tp>::type,
// is_class<typename remove_reference<_Tp>::type>::value>
// {
// };
//
// __ref_return1
//
// template <class _Tp, bool _IsClass, class _A0>
// struct ____ref_return1 // _IsClass is true
// {
// typedef typename result_of<_Tp(_A0)>::type type;
// };
//
// template <class _Tp, bool _HasResultType, class _A0>
// struct ______ref_return1 // _HasResultType is true
// {
// typedef typename __callable_type<_Tp>::result_type type;
// };
//
// template <class _Tp, class _A0, bool>
// struct __ref_return1_member_data1;
//
// template <class _Rp, class _Cp, class _A0>
// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, true>
// {
// typedef typename __apply_cv<_A0, _Rp>::type& type;
// };
//
// template <class _Rp, class _Cp, class _A0>
// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, false>
// {
// static _A0 __a;
// typedef typename __apply_cv<decltype(*__a), _Rp>::type& type;
// };
//
// template <class _Tp, class _A0>
// struct __ref_return1_member_data;
//
// template <class _Rp, class _Cp, class _A0>
// struct __ref_return1_member_data<_Rp _Cp::*, _A0>
// : public __ref_return1_member_data1<_Rp _Cp::*, _A0,
// is_same<typename remove_cv<_Cp>::type,
// typename remove_cv<typename remove_reference<_A0>::type>::type>::value>
// {
// };
//
// template <class _Tp, class _A0>
// struct ______ref_return1<_Tp, false, _A0> // pointer to member data
// : public __ref_return1_member_data<typename remove_cv<_Tp>::type, _A0>
// {
// };
//
// template <class _Tp, class _A0>
// struct ____ref_return1<_Tp, false, _A0>
// : public ______ref_return1<typename remove_cv<_Tp>::type,
// __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0>
// {
// };
//
// template <class _Tp, class _A0>
// struct __ref_return1
// : public ____ref_return1<typename remove_reference<_Tp>::type,
// is_class<typename remove_reference<_Tp>::type>::value, _A0>
// {
// };
//
// __ref_return2
//
// template <class _Tp, bool _IsClass, class _A0, class _A1>
// struct ____ref_return2 // _IsClass is true
// {
// typedef typename result_of<_Tp(_A0, _A1)>::type type;
// };
//
// template <class _Tp, bool _HasResultType, class _A0, class _A1>
// struct ______ref_return2 // _HasResultType is true
// {
// typedef typename __callable_type<_Tp>::result_type type;
// };
//
// template <class _Tp>
// struct ______ref_return2<_Tp, false, class _A0, class _A1> // pointer to member data
// {
// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer"
// " to member data with too many arguments.");
// };
//
// template <class _Tp, class _A0, class _A1>
// struct ____ref_return2<_Tp, false, _A0, _A1>
// : public ______ref_return2<typename remove_cv<_Tp>::type,
// __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0, _A1>
// {
// };
//
// template <class _Tp, class _A0, class _A1>
// struct __ref_return2
// : public ____ref_return2<typename remove_reference<_Tp>::type,
// is_class<typename remove_reference<_Tp>::type>::value, _A0, _A1>
// {
// };
//
// __ref_return3
//
// template <class _Tp, bool _IsClass, class _A0, class _A1, class _A2>
// struct ____ref_return3 // _IsClass is true
// {
// typedef typename result_of<_Tp(_A0, _A1, _A2)>::type type;
// };
//
// template <class _Tp, bool _HasResultType, class _A0, class _A1, class _A2>
// struct ______ref_return3 // _HasResultType is true
// {
// typedef typename __callable_type<_Tp>::result_type type;
// };
//
// template <class _Tp>
// struct ______ref_return3<_Tp, false, class _A0, class _A1, class _A2> // pointer to member data
// {
// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer"
// " to member data with too many arguments.");
// };
//
// template <class _Tp, class _A0, class _A1, class _A2>
// struct ____ref_return3<_Tp, false, _A0, _A1, _A2>
// : public ______ref_return3<typename remove_cv<_Tp>::type,
// __has_result_type<__callable_type<typename remove_cv<_Tp>::type> >::value, _A0, _A1, _A2>
// {
// };
//
// template <class _Tp, class _A0, class _A1, class _A2>
// struct __ref_return3
// : public ____ref_return3<typename remove_reference<_Tp>::type,
// is_class<typename remove_reference<_Tp>::type>::value, _A0, _A1, _A2>
// {
// };
// first bullet
template <class _Rp, class _Tp, class _T1>
@@ -805,32 +408,15 @@ template <class _Rp, class _Tp, class _T1>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_member_object_pointer<_Rp _Tp::*>::value &&
is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
typename __apply_cv<_T1, _Rp>::type&
>::type
__apply_cv<_T1, _Rp>
>::type::type&
__invoke(_Rp _Tp::* __f, _T1& __t1)
{
return __t1.*__f;
}
template <class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
__invoke(_Rp _Tp::*)
{
}
// template <class _Dp, class _Rp, class _Tp, class _T1>
// inline _LIBCPP_INLINE_VISIBILITY
// typename enable_if
// <
// is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
// typename __ref_return1<_Rp _Tp::*, _T1>::type
// >::type
// __invoke(_Rp _Tp::* __f, _T1& __t1)
// {
// return __t1.*__f;
// }
// forth bullet
@@ -842,114 +428,54 @@ struct __4th_helper
template <class _T1, class _Rp>
struct __4th_helper<_T1, _Rp, true>
{
typedef typename __apply_cv<decltype(*_VSTD::declval<_T1>()), _Rp>::type type;
typedef typename __apply_cv<decltype(*_VSTD::declval<_T1&>()), _Rp>::type type;
};
template <class _Rp, class _Tp, class _T1>
inline _LIBCPP_INLINE_VISIBILITY
typename __4th_helper<_T1, _Rp,
!is_base_of<_Tp,
typename remove_reference<_T1>::type
>::value
>::type&
is_member_object_pointer<_Rp _Tp::*>::value &&
!is_base_of<_Tp, typename remove_reference<_T1>::type>::value
>::type&
__invoke(_Rp _Tp::* __f, _T1& __t1)
{
return (*__t1).*__f;
}
// template <class _Dp, class _Rp, class _Tp, class _T1>
// inline _LIBCPP_INLINE_VISIBILITY
// typename enable_if
// <
// !is_base_of<_Tp, typename remove_reference<_T1>::type>::value,
// typename __ref_return1<_Rp _Tp::*, _T1>::type
// >::type
// __invoke(_Rp _Tp::* __f, _T1 __t1)
// {
// return (*__t1).*__f;
// }
// fifth bullet
template <class _Fp>
inline _LIBCPP_INLINE_VISIBILITY
decltype(declval<_Fp>()())
__invoke(_Fp __f)
decltype(_VSTD::declval<_Fp&>()())
__invoke(_Fp& __f)
{
return __f();
}
template <class _Fp, class _A0>
inline _LIBCPP_INLINE_VISIBILITY
decltype(declval<_Fp>()(declval<_A0&>()))
__invoke(_Fp __f, _A0& __a0)
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>()))
__invoke(_Fp& __f, _A0& __a0)
{
return __f(__a0);
}
template <class _Fp, class _A0, class _A1>
inline _LIBCPP_INLINE_VISIBILITY
decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>()))
__invoke(_Fp __f, _A0& __a0, _A1& __a1)
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1)
{
return __f(__a0, __a1);
}
template <class _Fp, class _A0, class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
decltype(declval<_Fp>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>()))
__invoke(_Fp __f, _A0& __a0, _A1& __a1, _A2& __a2)
decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>()))
__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
{
return __f(__a0, __a1, __a2);
}
// template <class _Rp, class _Fp>
// inline _LIBCPP_INLINE_VISIBILITY
// _Rp
// __invoke(_Fp& __f)
// {
// return __f();
// }
//
// template <class _Rp, class _Fp, class _A0>
// inline _LIBCPP_INLINE_VISIBILITY
// typename enable_if
// <
// !is_member_pointer<_Fp>::value,
// _Rp
// >::type
// __invoke(_Fp& __f, _A0& __a0)
// {
// return __f(__a0);
// }
//
// template <class _Rp, class _Fp, class _A0, class _A1>
// inline _LIBCPP_INLINE_VISIBILITY
// _Rp
// __invoke(_Fp& __f, _A0& __a0, _A1& __a1)
// {
// return __f(__a0, __a1);
// }
//
// template <class _Rp, class _Fp, class _A0, class _A1, class _A2>
// inline _LIBCPP_INLINE_VISIBILITY
// _Rp
// __invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2)
// {
// return __f(__a0, __a1, __a2);
// }
template <class _Tp>
struct __has_type
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value>
struct __invoke_return
{
@@ -959,23 +485,23 @@ struct __invoke_return
template <class _Fp>
struct __invoke_return<_Fp, false>
{
typedef decltype(__invoke(_VSTD::declval<_Fp>())) type;
typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type;
};
template <class _Tp, class _A0>
template <class _Tp, class _A0, bool = is_member_object_pointer<_Tp>::value>
struct __invoke_return0
{
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>())) type;
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type;
};
template <class _Rp, class _Tp, class _A0>
struct __invoke_return0<_Rp _Tp::*, _A0>
struct __invoke_return0<_Rp _Tp::*, _A0, true>
{
typedef typename __apply_cv<_A0, _Rp>::type& type;
};
template <class _Rp, class _Tp, class _A0>
struct __invoke_return0<_Rp _Tp::*, _A0*>
struct __invoke_return0<_Rp _Tp::*, _A0*, true>
{
typedef typename __apply_cv<_A0, _Rp>::type& type;
};
@@ -983,162 +509,16 @@ struct __invoke_return0<_Rp _Tp::*, _A0*>
template <class _Tp, class _A0, class _A1>
struct __invoke_return1
{
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(),
_VSTD::declval<_A1>())) type;
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
_VSTD::declval<_A1&>())) type;
};
template <class _Tp, class _A0, class _A1, class _A2>
struct __invoke_return2
{
typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(),
_VSTD::declval<_A1>(),
_VSTD::declval<_A2>())) type;
typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(),
_VSTD::declval<_A1&>(),
_VSTD::declval<_A2&>())) type;
};
template <class _Ret>
struct __invoke_void_return_wrapper
{
template <class _Fn>
static _Ret __call(_Fn __f)
{
return __invoke(__f);
}
template <class _Fn, class _A0>
static _Ret __call(_Fn __f, _A0& __a0)
{
return __invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1)
{
return __invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2)
{
return __invoke(__f, __a0, __a1, __a2);
}
};
template <>
struct __invoke_void_return_wrapper<void>
{
template <class _Fn>
static void __call(_Fn __f)
{
__invoke(__f);
}
template <class _Fn, class _A0>
static void __call(_Fn __f, _A0& __a0)
{
__invoke(__f, __a0);
}
template <class _Fn, class _A0, class _A1>
static void __call(_Fn __f, _A0& __a0, _A1& __a1)
{
__invoke(__f, __a0, __a1);
}
template <class _Fn, class _A0, class _A1, class _A2>
static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2)
{
__invoke(__f, __a0, __a1, __a2);
}
};
template <class _Tp>
class _LIBCPP_TYPE_VIS_ONLY reference_wrapper
: public __weak_result_type<_Tp>
{
public:
// types
typedef _Tp type;
private:
type* __f_;
public:
// construct/copy/destroy
_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) : __f_(&__f) {}
// access
_LIBCPP_INLINE_VISIBILITY operator type& () const {return *__f_;}
_LIBCPP_INLINE_VISIBILITY type& get() const {return *__f_;}
// invoke
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type&>::type
operator() () const
{
return __invoke(get());
}
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return0<type&, _A0>::type
operator() (_A0& __a0) const
{
return __invoke<type&, _A0>(get(), __a0);
}
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return1<type&, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const
{
return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
}
template <class _A0, class _A1, class _A2>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return2<type&, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
{
return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
}
};
template <class _Tp> struct __is_reference_wrapper_impl : public false_type {};
template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};
template <class _Tp> struct __is_reference_wrapper
: public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {};
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<_Tp>
ref(_Tp& __t)
{
return reference_wrapper<_Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t)
{
return ref(__t.get());
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<const _Tp>
cref(const _Tp& __t)
{
return reference_wrapper<const _Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t)
{
return cref(__t.get());
}
#endif // _LIBCPP_FUNCTIONAL_BASE_03

View File

@@ -85,8 +85,6 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table
template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator;
template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator;
template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator;
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
class _LIBCPP_TYPE_VIS_ONLY unordered_map;
template <class _NodePtr>
class _LIBCPP_TYPE_VIS_ONLY __hash_iterator
@@ -777,13 +775,7 @@ public:
public:
// Create __node
typedef __hash_node<value_type, typename __alloc_traits::void_pointer> __node;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;
@@ -798,13 +790,7 @@ public:
private:
typedef typename __node_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node_pointer>
#else
rebind_alloc<__node_pointer>::other
#endif
__pointer_allocator;
typedef typename __rebind_alloc_helper<__node_traits, __node_pointer>::type __pointer_allocator;
typedef __bucket_list_deallocator<__pointer_allocator> __bucket_list_deleter;
typedef unique_ptr<__node_pointer[], __bucket_list_deleter> __bucket_list;
typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
@@ -910,11 +896,21 @@ public:
iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _ValueTp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique_value(_ValueTp&& __x);
#else
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> __insert_unique_value(const value_type& __x);
#endif
pair<iterator, bool> __insert_unique(const value_type& __x);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
pair<iterator, bool> __insert_unique(value_type&& __x);
template <class _Pp>
pair<iterator, bool> __insert_unique(_Pp&& __x);
pair<iterator, bool> __insert_unique(_Pp&& __x);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -988,13 +984,17 @@ public:
__equal_range_multi(const _Key& __k) const;
void swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable<__pointer_allocator>::value) &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
&& (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
|| __is_nothrow_swappable<__pointer_allocator>::value)
&& (!__node_traits::propagate_on_container_swap::value
|| __is_nothrow_swappable<__node_allocator>::value)
);
#else
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const _NOEXCEPT
@@ -1122,38 +1122,6 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {}
template <class _Ap>
_LIBCPP_INLINE_VISIBILITY
static
void
__swap_alloc(_Ap& __x, _Ap& __y)
_NOEXCEPT_(
!allocator_traits<_Ap>::propagate_on_container_swap::value ||
__is_nothrow_swappable<_Ap>::value)
{
__swap_alloc(__x, __y,
integral_constant<bool,
allocator_traits<_Ap>::propagate_on_container_swap::value
>());
}
template <class _Ap>
_LIBCPP_INLINE_VISIBILITY
static
void
__swap_alloc(_Ap& __x, _Ap& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<_Ap>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
template <class _Ap>
_LIBCPP_INLINE_VISIBILITY
static
void
__swap_alloc(_Ap&, _Ap&, false_type) _NOEXCEPT {}
void __deallocate(__node_pointer __np) _NOEXCEPT;
__node_pointer __detach() _NOEXCEPT;
@@ -1753,6 +1721,26 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
{
return __insert_unique_value(__x);
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _ValueTp>
_LIBCPP_INLINE_VISIBILITY
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(_ValueTp&& __x)
#else
template <class _Tp, class _Hash, class _Equal, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type& __x)
#endif
{
#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
typedef const value_type& _ValueTp;
#endif
size_t __hash = hash_function()(__x);
size_type __bc = bucket_count();
bool __inserted = false;
@@ -1774,7 +1762,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(const value_type& __x)
}
}
{
__node_holder __h = __construct_node(__x, __hash);
__node_holder __h = __construct_node(_VSTD::forward<_ValueTp>(__x), __hash);
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
@@ -1857,6 +1845,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi(
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Hash, class _Equal, class _Alloc>
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique(value_type&& __x)
{
return __insert_unique_value(_VSTD::move(__x));
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <class _Pp>
pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool>
@@ -2358,13 +2353,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(
(!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
__is_nothrow_swappable<__pointer_allocator>::value) &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value)
__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
&& (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
|| __is_nothrow_swappable<__pointer_allocator>::value)
&& (!__node_traits::propagate_on_container_swap::value
|| __is_nothrow_swappable<__node_allocator>::value)
)
#else
_NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
#endif
{
{
__node_pointer_pointer __npp = __bucket_list_.release();
@@ -2372,9 +2371,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
__u.__bucket_list_.reset(__npp);
}
_VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size());
__swap_alloc(__bucket_list_.get_deleter().__alloc(),
__swap_allocator(__bucket_list_.get_deleter().__alloc(),
__u.__bucket_list_.get_deleter().__alloc());
__swap_alloc(__node_alloc(), __u.__node_alloc());
__swap_allocator(__node_alloc(), __u.__node_alloc());
_VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_);
__p2_.swap(__u.__p2_);
__p3_.swap(__u.__p3_);

View File

@@ -353,6 +353,7 @@ public:
static const mask punct = _PUNCT;
static const mask xdigit = _HEX;
static const mask blank = _BLANK;
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
# ifdef __APPLE__
typedef __uint32_t mask;
@@ -401,6 +402,9 @@ public:
static const mask punct = _P;
static const mask xdigit = _X | _N;
static const mask blank = _B;
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
#else
typedef unsigned long mask;
static const mask space = 1<<0;

View File

@@ -156,25 +156,6 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<__alloc_rr>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<__alloc_rr>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__alloc_rr&, __alloc_rr&, false_type) _NOEXCEPT
{}
};
template <class _Tp, class _Allocator>
@@ -431,7 +412,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
_VSTD::swap(__begin_, __x.__begin_);
_VSTD::swap(__end_, __x.__end_);
_VSTD::swap(__end_cap(), __x.__end_cap());
__swap_alloc(__alloc(), __x.__alloc());
__swap_allocator(__alloc(), __x.__alloc());
}
template <class _Tp, class _Allocator>

View File

@@ -276,7 +276,6 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
codecvt_base::result __r;
char_type* pbase = &__1buf;
char_type* pptr = pbase + 1;
char_type* epptr = pptr;
do
{
const char_type* __e;

View File

@@ -28,14 +28,6 @@ template <class _Tp, class _NodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_iterator;
template <class _Tp, class _ConstNodePtr, class _DiffType>
class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator;
template <class _Key, class _Tp, class _Compare, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY map;
template <class _Key, class _Tp, class _Compare, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY multimap;
template <class _Key, class _Compare, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY set;
template <class _Key, class _Compare, class _Allocator>
class _LIBCPP_TYPE_VIS_ONLY multiset;
/*
@@ -810,13 +802,7 @@ public:
typedef __tree_node<value_type, __void_pointer> __node;
typedef __tree_node_base<__void_pointer> __node_base;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;
@@ -940,9 +926,12 @@ public:
void swap(__tree& __t)
_NOEXCEPT_(
__is_nothrow_swappable<value_compare>::value &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value));
__is_nothrow_swappable<value_compare>::value
#if _LIBCPP_STD_VER <= 11
&& (!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1110,25 +1099,6 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree& __t, false_type) _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
_NOEXCEPT_(
!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__node_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type)
_NOEXCEPT
{}
__node_pointer __detach();
static __node_pointer __detach(__node_pointer);
@@ -1148,8 +1118,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp)
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
: __pair1_(__node_allocator(__a)),
__begin_node_(__node_pointer()),
: __begin_node_(__node_pointer()),
__pair1_(__node_allocator(__a)),
__pair3_(0)
{
__begin_node() = __end_node();
@@ -1158,8 +1128,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
template <class _Tp, class _Compare, class _Allocator>
__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
const allocator_type& __a)
: __pair1_(__node_allocator(__a)),
__begin_node_(__node_pointer()),
: __begin_node_(__node_pointer()),
__pair1_(__node_allocator(__a)),
__pair3_(0, __comp)
{
__begin_node() = __end_node();
@@ -1466,15 +1436,18 @@ __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT
template <class _Tp, class _Compare, class _Allocator>
void
__tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
_NOEXCEPT_(
__is_nothrow_swappable<value_compare>::value &&
(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value))
_NOEXCEPT_(
__is_nothrow_swappable<value_compare>::value
#if _LIBCPP_STD_VER <= 11
&& (!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
)
{
using _VSTD::swap;
swap(__begin_node_, __t.__begin_node_);
swap(__pair1_.first(), __t.__pair1_.first());
__swap_alloc(__node_alloc(), __t.__node_alloc());
__swap_allocator(__node_alloc(), __t.__node_alloc());
__pair3_.swap(__t.__pair3_);
if (size() == 0)
__begin_node() = __end_node();
@@ -2085,7 +2058,6 @@ template <class _Key>
typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const
{
typedef pair<const_iterator, const_iterator> _Pp;
__node_const_pointer __result = __end_node();
__node_const_pointer __rt = __root();
while (__rt != nullptr)

View File

@@ -19,40 +19,9 @@
#pragma GCC system_header
#endif
#ifdef _LIBCPP_HAS_NO_VARIADICS
#include <__tuple_03>
#else // _LIBCPP_HAS_NO_VARIADICS
_LIBCPP_BEGIN_NAMESPACE_STD
// __lazy_and
template <bool _Last, class ..._Preds>
struct __lazy_and_impl;
template <class ..._Preds>
struct __lazy_and_impl<false, _Preds...> : false_type {};
template <>
struct __lazy_and_impl<true> : true_type {};
template <class _Pred>
struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
template <class _Hp, class ..._Tp>
struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
template <class _P1, class ..._Pr>
struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
// __lazy_not
template <class _Pred>
struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
template <class _Tp>
@@ -90,19 +59,18 @@ public:
typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
template <class _Tp> struct __tuple_like : false_type {};
template <class _Tp> struct __tuple_like<const _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<volatile _Tp> : public __tuple_like<_Tp> {};
template <class _Tp> struct __tuple_like<const volatile _Tp> : public __tuple_like<_Tp> {};
// tuple specializations
#if !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple;
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class ..._Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -118,6 +86,13 @@ template <size_t _Ip, class ..._Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
get(tuple<_Tp...>&&) _NOEXCEPT;
#endif
// pair specializations
template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair;
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -129,10 +104,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>&) _NOEXCEPT;
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
get(pair<_T1, _T2>&&) _NOEXCEPT;
#endif
// array specializations
template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array;
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -144,10 +127,39 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
get(const array<_Tp, _Size>&) _NOEXCEPT;
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&&
get(array<_Tp, _Size>&&) _NOEXCEPT;
#endif
#if !defined(_LIBCPP_HAS_NO_VARIADICS)
// __lazy_and
template <bool _Last, class ..._Preds>
struct __lazy_and_impl;
template <class ..._Preds>
struct __lazy_and_impl<false, _Preds...> : false_type {};
template <>
struct __lazy_and_impl<true> : true_type {};
template <class _Pred>
struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {};
template <class _Hp, class ..._Tp>
struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {};
template <class _P1, class ..._Pr>
struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {};
// __lazy_not
template <class _Pred>
struct __lazy_not : integral_constant<bool, !_Pred::type::value> {};
// __make_tuple_indices
@@ -354,8 +366,8 @@ struct __tuple_assignable<_Tp, _Up, true, true>
tuple_size<_Up>::value, _Tp, _Up>
{};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_HAS_NO_VARIADICS
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TUPLE

View File

@@ -1,27 +0,0 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___TUPLE_03
#define _LIBCPP___TUPLE_03
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size;
template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___TUPLE_03

View File

@@ -521,11 +521,11 @@ template <class RandomAccessIterator, class Compare>
template <class ForwardIterator>
ForwardIterator
min_element(ForwardIterator first, ForwardIterator last);
min_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template <class ForwardIterator, class Compare>
ForwardIterator
min_element(ForwardIterator first, ForwardIterator last, Compare comp);
min_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template <class T>
const T&
@@ -545,11 +545,11 @@ template<class T, class Compare>
template <class ForwardIterator>
ForwardIterator
max_element(ForwardIterator first, ForwardIterator last);
max_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template <class ForwardIterator, class Compare>
ForwardIterator
max_element(ForwardIterator first, ForwardIterator last, Compare comp);
max_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template <class T>
const T&
@@ -569,11 +569,11 @@ template<class T, class Compare>
template<class ForwardIterator>
pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last);
minmax_element(ForwardIterator first, ForwardIterator last); // constexpr in C++14
template<class ForwardIterator, class Compare>
pair<ForwardIterator, ForwardIterator>
minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
minmax_element(ForwardIterator first, ForwardIterator last, Compare comp); // constexpr in C++14
template<class T>
pair<const T&, const T&>
@@ -1763,7 +1763,8 @@ typename enable_if
__copy(_Tp* __first, _Tp* __last, _Up* __result)
{
const size_t __n = static_cast<size_t>(__last - __first);
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
if (__n > 0)
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
return __result + __n;
}
@@ -1798,8 +1799,11 @@ typename enable_if
__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
{
const size_t __n = static_cast<size_t>(__last - __first);
__result -= __n;
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
if (__n > 0)
{
__result -= __n;
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
}
return __result;
}
@@ -1896,7 +1900,8 @@ typename enable_if
__move(_Tp* __first, _Tp* __last, _Up* __result)
{
const size_t __n = static_cast<size_t>(__last - __first);
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
if (__n > 0)
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
return __result + __n;
}
@@ -1931,8 +1936,11 @@ typename enable_if
__move_backward(_Tp* __first, _Tp* __last, _Up* __result)
{
const size_t __n = static_cast<size_t>(__last - __first);
__result -= __n;
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
if (__n > 0)
{
__result -= __n;
_VSTD::memmove(__result, __first, __n * sizeof(_Up));
}
return __result;
}
@@ -2544,7 +2552,7 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato
template <class _ForwardIterator, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
{
@@ -2556,20 +2564,12 @@ __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
return __first;
}
template <class _ForwardIterator, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
return __min_element(__first, __last, __comp);
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
return __min_element(__first, __last,
return _VSTD::min_element(__first, __last,
__less<typename iterator_traits<_ForwardIterator>::value_type>());
}
@@ -2598,7 +2598,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t, _Compare __comp)
{
return *__min_element(__t.begin(), __t.end(), __comp);
return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
@@ -2606,7 +2606,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t)
{
return *__min_element(__t.begin(), __t.end(), __less<_Tp>());
return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>());
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -2616,7 +2616,7 @@ min(initializer_list<_Tp> __t)
template <class _ForwardIterator, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
{
@@ -2629,20 +2629,12 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
}
template <class _ForwardIterator, class _Compare>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
return __max_element(__first, __last, __comp);
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
return __max_element(__first, __last,
return _VSTD::max_element(__first, __last,
__less<typename iterator_traits<_ForwardIterator>::value_type>());
}
@@ -2671,7 +2663,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t, _Compare __comp)
{
return *__max_element(__t.begin(), __t.end(), __comp);
return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
@@ -2679,7 +2671,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t)
{
return *__max_element(__t.begin(), __t.end(), __less<_Tp>());
return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>());
}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
@@ -2687,6 +2679,7 @@ max(initializer_list<_Tp> __t)
// minmax_element
template <class _ForwardIterator, class _Compare>
_LIBCPP_CONSTEXPR_AFTER_CXX11
std::pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
@@ -2734,7 +2727,7 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
}
template <class _ForwardIterator>
inline _LIBCPP_INLINE_VISIBILITY
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
std::pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -3044,7 +3037,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p
if (_Rp == 0)
return static_cast<result_type>(_Eng(__g, _Dt)());
size_t __w = _Dt - __clz(_Rp) - 1;
if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0)
if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
++__w;
_Eng __e(__g, __w);
_UIntType __u;
@@ -4368,6 +4361,34 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1,
// inplace_merge
template <class _Compare, class _InputIterator1, class _InputIterator2,
class _OutputIterator>
void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
_OutputIterator __result, _Compare __comp)
{
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
{
_VSTD::move(__first1, __last1, __result);
return;
}
if (__comp(*__first2, *__first1))
{
*__result = _VSTD::move(*__first2);
++__first2;
}
else
{
*__result = _VSTD::move(*__first1);
++__first1;
}
}
// __first2 through __last2 are already in the right spot.
}
template <class _Compare, class _BidirectionalIterator>
void
__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
@@ -4383,11 +4404,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
value_type* __p = __buff;
for (_BidirectionalIterator __i = __first; __i != __middle; __d.__incr((value_type*)0), (void) ++__i, ++__p)
::new(__p) value_type(_VSTD::move(*__i));
__merge<_Compare>(move_iterator<value_type*>(__buff),
move_iterator<value_type*>(__p),
move_iterator<_BidirectionalIterator>(__middle),
move_iterator<_BidirectionalIterator>(__last),
__first, __comp);
__half_inplace_merge(__buff, __p, __middle, __last, __first, __comp);
}
else
{
@@ -4396,9 +4413,9 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
::new(__p) value_type(_VSTD::move(*__i));
typedef reverse_iterator<_BidirectionalIterator> _RBi;
typedef reverse_iterator<value_type*> _Rv;
__merge(move_iterator<_RBi>(_RBi(__middle)), move_iterator<_RBi>(_RBi(__first)),
move_iterator<_Rv>(_Rv(__p)), move_iterator<_Rv>(_Rv(__buff)),
_RBi(__last), __negate<_Compare>(__comp));
__half_inplace_merge(_Rv(__p), _Rv(__buff),
_RBi(__middle), _RBi(__first),
_RBi(__last), __negate<_Compare>(__comp));
}
}

View File

@@ -288,10 +288,6 @@ template <class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> >
{
@@ -299,13 +295,6 @@ public:
typedef _Tp type;
};
template <size_t _Ip, class _Tp, size_t _Size>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const array<_Tp, _Size> >
{
public:
typedef const _Tp type;
};
template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp&

View File

@@ -554,7 +554,8 @@ namespace __gcc_atomic {
template <typename _Tp>
struct __gcc_atomic_t {
__gcc_atomic_t() _NOEXCEPT {}
explicit __gcc_atomic_t(_Tp value) _NOEXCEPT : __a_value(value) {}
_LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
: __a_value(value) {}
_Tp __a_value;
};
#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
@@ -633,10 +634,6 @@ static inline void __c11_atomic_signal_fence(memory_order __order) {
__atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order));
}
static inline bool __c11_atomic_is_lock_free(size_t __size) {
return __atomic_is_lock_free(__size, 0);
}
template <typename _Tp>
static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val,
memory_order __order) {
@@ -827,10 +824,16 @@ struct __atomic_base // false
_LIBCPP_INLINE_VISIBILITY
bool is_lock_free() const volatile _NOEXCEPT
{return __c11_atomic_is_lock_free(sizeof(_Tp));}
{
#if __has_feature(cxx_atomic)
return __c11_atomic_is_lock_free(sizeof(_Tp));
#else
return __atomic_is_lock_free(sizeof(_Tp), 0);
#endif
}
_LIBCPP_INLINE_VISIBILITY
bool is_lock_free() const _NOEXCEPT
{return __c11_atomic_is_lock_free(sizeof(_Tp));}
{return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
_LIBCPP_INLINE_VISIBILITY
void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
{__c11_atomic_store(&__a_, __d, __m);}

View File

@@ -247,7 +247,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
using::imaxdiv_t;
#undef imaxabs
using::imaxabs;
#undef imaxdiv
using::imaxdiv;
using::strtoimax;
using::strtoumax;

View File

@@ -45,7 +45,9 @@ lconv* localeconv();
_LIBCPP_BEGIN_NAMESPACE_STD
using ::lconv;
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
using ::setlocale;
#endif
using ::localeconv;
_LIBCPP_END_NAMESPACE_STD

View File

@@ -654,6 +654,10 @@ using ::double_t;
// abs
#if defined(__sun__)
using ::abs;
#endif
#if !defined(_AIX) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY
float

View File

@@ -144,30 +144,20 @@ using ::FILE;
using ::fpos_t;
using ::size_t;
using ::remove;
using ::rename;
using ::tmpfile;
using ::tmpnam;
using ::fclose;
using ::fflush;
using ::fopen;
using ::freopen;
using ::setbuf;
using ::setvbuf;
using ::fprintf;
using ::fscanf;
using ::printf;
using ::scanf;
using ::snprintf;
using ::sprintf;
using ::sscanf;
#ifndef _LIBCPP_MSVCRT
using ::vfprintf;
using ::vfscanf;
using ::vscanf;
using ::vsscanf;
#endif // _LIBCPP_MSVCRT
using ::vprintf;
using ::vsnprintf;
using ::vsprintf;
using ::fgetc;
@@ -175,13 +165,7 @@ using ::fgets;
using ::fputc;
using ::fputs;
using ::getc;
using ::getchar;
#if _LIBCPP_STD_VER <= 11
using ::gets;
#endif
using ::putc;
using ::putchar;
using ::puts;
using ::ungetc;
using ::fread;
using ::fwrite;
@@ -195,6 +179,31 @@ using ::feof;
using ::ferror;
using ::perror;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
using ::fopen;
using ::freopen;
using ::remove;
using ::rename;
using ::tmpfile;
using ::tmpnam;
#endif
#ifndef _LIBCPP_HAS_NO_STDIN
using ::getchar;
#if _LIBCPP_STD_VER <= 11
using ::gets;
#endif
using ::scanf;
using ::vscanf;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
using ::printf;
using ::putchar;
using ::puts;
using ::vprintf;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDIO

View File

@@ -131,19 +131,27 @@ using ::getenv;
using ::system;
using ::bsearch;
using ::qsort;
#undef abs
using ::abs;
#undef labs
using ::labs;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
#undef llabs
using ::llabs;
#endif // _LIBCPP_HAS_NO_LONG_LONG
#undef div
using ::div;
#undef ldiv
using ::ldiv;
#ifndef _LIBCPP_HAS_NO_LONG_LONG
#undef lldiv
using ::lldiv;
#endif // _LIBCPP_HAS_NO_LONG_LONG
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
using ::mblen;
using ::mbtowc;
using ::wctomb;
#endif
using ::mbstowcs;
using ::wcstombs;
#ifdef _LIBCPP_HAS_QUICK_EXIT

View File

@@ -102,7 +102,9 @@ inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, si
inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
#endif
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
using ::strtok;
#endif
using ::memset;
using ::strerror;
using ::strlen;

View File

@@ -61,10 +61,12 @@ using ::clock;
using ::difftime;
using ::mktime;
using ::time;
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
#endif
using ::strftime;
_LIBCPP_END_NAMESPACE_STD

View File

@@ -126,24 +126,18 @@ using ::fwscanf;
using ::swprintf;
using ::vfwprintf;
using ::vswprintf;
using ::vwprintf;
#ifndef _LIBCPP_MSVCRT
using ::swscanf;
using ::vfwscanf;
using ::vswscanf;
using ::vwscanf;
#endif // _LIBCPP_MSVCRT
using ::wprintf;
using ::wscanf;
using ::fgetwc;
using ::fgetws;
using ::fputwc;
using ::fputws;
using ::fwide;
using ::getwc;
using ::getwchar;
using ::putwc;
using ::putwchar;
using ::ungetwc;
using ::wcstod;
#ifndef _LIBCPP_MSVCRT
@@ -212,6 +206,20 @@ using ::wcrtomb;
using ::mbsrtowcs;
using ::wcsrtombs;
#ifndef _LIBCPP_HAS_NO_STDIN
using ::getwchar;
#ifndef _LIBCPP_MSVCRT
using ::vwscanf;
#endif // _LIBCPP_MSVCRT
using ::wscanf;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
using ::putwchar;
using ::vwprintf;
using ::wprintf;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CWCHAR

View File

@@ -124,8 +124,7 @@ public:
iterator erase(const_iterator p);
iterator erase(const_iterator f, const_iterator l);
void swap(deque& c)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
void clear() noexcept;
};
@@ -912,22 +911,10 @@ protected:
static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<pointer>
#else
rebind_alloc<pointer>::other
#endif
__pointer_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator;
typedef allocator_traits<__pointer_allocator> __map_traits;
typedef typename __map_traits::pointer __map_pointer;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<const_pointer>
#else
rebind_alloc<const_pointer>::other
#endif
__const_pointer_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, const_pointer>::type __const_pointer_allocator;
typedef typename allocator_traits<__const_pointer_allocator>::const_pointer __map_const_pointer;
typedef __split_buffer<pointer, __pointer_allocator> __map;
@@ -966,8 +953,12 @@ public:
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
void swap(__deque_base& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
__is_nothrow_swappable<allocator_type>::value);
#endif
protected:
void clear() _NOEXCEPT;
@@ -1003,26 +994,6 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__deque_base&, false_type) _NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type&, allocator_type&, false_type)
_NOEXCEPT
{}
};
template <class _Tp, class _Allocator>
@@ -1146,13 +1117,17 @@ __deque_base<_Tp, _Allocator>::__deque_base(__deque_base&& __c, const allocator_
template <class _Tp, class _Allocator>
void
__deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
__is_nothrow_swappable<allocator_type>::value)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
__map_.swap(__c.__map_);
_VSTD::swap(__start_, __c.__start_);
_VSTD::swap(size(), __c.size());
__swap_alloc(__alloc(), __c.__alloc());
__swap_allocator(__alloc(), __c.__alloc());
}
template <class _Tp, class _Allocator>
@@ -1354,8 +1329,12 @@ public:
iterator erase(const_iterator __f, const_iterator __l);
void swap(deque& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
void clear() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
@@ -2050,7 +2029,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
if (__n > __front_spare())
__add_front_capacity(__n - __front_spare());
// __n <= __front_spare()
size_type __old_n = __n;
iterator __old_begin = __base::begin();
iterator __i = __old_begin;
if (__n > __pos)
@@ -2075,7 +2053,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty
if (__n > __back_capacity)
__add_back_capacity(__n - __back_capacity);
// __n <= __back_capacity
size_type __old_n = __n;
iterator __old_end = __base::end();
iterator __i = __old_end;
size_type __de = __base::size() - __pos;
@@ -2140,7 +2117,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
if (__n > __front_spare())
__add_front_capacity(__n - __front_spare());
// __n <= __front_spare()
size_type __old_n = __n;
iterator __old_begin = __base::begin();
iterator __i = __old_begin;
_BiIter __m = __f;
@@ -2171,7 +2147,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l,
if (__n > __back_capacity)
__add_back_capacity(__n - __back_capacity);
// __n <= __back_capacity
size_type __old_n = __n;
iterator __old_end = __base::end();
iterator __i = __old_end;
_BiIter __m = __l;
@@ -2288,19 +2263,14 @@ deque<_Tp, _Allocator>::__add_front_capacity()
__split_buffer<pointer, typename __base::__pointer_allocator&>
__buf(max<size_type>(2 * __base::__map_.capacity(), 1),
0, __base::__map_.__alloc());
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
__buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__alloc_traits::deallocate(__a, __buf.front(), __base::__block_size);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
typedef __allocator_destructor<_Allocator> _Dp;
unique_ptr<pointer, _Dp> __hold(
__alloc_traits::allocate(__a, __base::__block_size),
_Dp(__a, __base::__block_size));
__buf.push_back(__hold.get());
__hold.release();
for (typename __base::__map_pointer __i = __base::__map_.begin();
__i != __base::__map_.end(); ++__i)
__buf.push_back(*__i);
@@ -2436,19 +2406,14 @@ deque<_Tp, _Allocator>::__add_back_capacity()
__buf(max<size_type>(2* __base::__map_.capacity(), 1),
__base::__map_.size(),
__base::__map_.__alloc());
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
__buf.push_back(__alloc_traits::allocate(__a, __base::__block_size));
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__alloc_traits::deallocate(__a, __buf.back(), __base::__block_size);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
typedef __allocator_destructor<_Allocator> _Dp;
unique_ptr<pointer, _Dp> __hold(
__alloc_traits::allocate(__a, __base::__block_size),
_Dp(__a, __base::__block_size));
__buf.push_back(__hold.get());
__hold.release();
for (typename __base::__map_pointer __i = __base::__map_.end();
__i != __base::__map_.begin();)
__buf.push_front(*--__i);
@@ -2716,12 +2681,11 @@ template <class _Tp, class _Allocator>
typename deque<_Tp, _Allocator>::iterator
deque<_Tp, _Allocator>::erase(const_iterator __f)
{
difference_type __n = 1;
iterator __b = __base::begin();
difference_type __pos = __f - __b;
iterator __p = __b + __pos;
allocator_type& __a = __base::__alloc();
if (__pos < (__base::size() - 1) / 2)
if (__pos <= (__base::size() - 1) / 2)
{ // erase from front
_VSTD::move_backward(__b, __p, _VSTD::next(__p));
__alloc_traits::destroy(__a, _VSTD::addressof(*__b));
@@ -2759,7 +2723,7 @@ deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l)
if (__n > 0)
{
allocator_type& __a = __base::__alloc();
if (__pos < (__base::size() - __n) / 2)
if (__pos <= (__base::size() - __n) / 2)
{ // erase from front
iterator __i = _VSTD::move_backward(__b, __p, __p + __n);
for (; __b != __i; ++__b)
@@ -2815,8 +2779,12 @@ template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
deque<_Tp, _Allocator>::swap(deque& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
__is_nothrow_swappable<allocator_type>::value)
#endif
{
__base::swap(__c);
}

View File

@@ -48,7 +48,8 @@ terminate_handler set_terminate(terminate_handler f ) noexcept;
terminate_handler get_terminate() noexcept;
[[noreturn]] void terminate() noexcept;
bool uncaught_exception() noexcept;
bool uncaught_exception() noexcept;
int uncaught_exceptions() noexcept; // C++17
typedef unspecified exception_ptr;
@@ -115,6 +116,7 @@ _LIBCPP_FUNC_VIS terminate_handler get_terminate() _NOEXCEPT;
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void terminate() _NOEXCEPT;
_LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT;
_LIBCPP_FUNC_VIS int uncaught_exceptions() _NOEXCEPT;
class _LIBCPP_TYPE_VIS exception_ptr;
@@ -193,6 +195,7 @@ void
throw_with_nested(_Tp&& __t, typename enable_if<
is_class<typename remove_reference<_Tp>::type>::value &&
!is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
&& !__libcpp_is_final<typename remove_reference<_Tp>::type>::value
>::type* = 0)
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
throw_with_nested (_Tp& __t, typename enable_if<
@@ -212,6 +215,7 @@ void
throw_with_nested(_Tp&& __t, typename enable_if<
!is_class<typename remove_reference<_Tp>::type>::value ||
is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
|| __libcpp_is_final<typename remove_reference<_Tp>::type>::value
>::type* = 0)
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
throw_with_nested (_Tp& __t, typename enable_if<

View File

@@ -0,0 +1,120 @@
// -*- C++ -*-
//===-------------------------- algorithm ---------------------------------===//
//
// 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_ALGORITHM
#define _LIBCPP_EXPERIMENTAL_ALGORITHM
/*
experimental/algorithm synopsis
#include <algorithm>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
template <class ForwardIterator, class Searcher>
ForwardIterator search(ForwardIterator first, ForwardIterator last,
const Searcher &searcher);
template <class PopulationIterator, class SampleIterator, class Distance,
class UniformRandomNumberGenerator>
SampleIterator sample(PopulationIterator first, PopulationIterator last,
SampleIterator out, Distance n,
UniformRandomNumberGenerator &&g);
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
#include <experimental/__config>
#include <algorithm>
#include <type_traits>
#include <__undef_min_max>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
template <class _ForwardIterator, class _Searcher>
_LIBCPP_INLINE_VISIBILITY
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
{ return __s(__f, __l); }
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
_LIBCPP_INLINE_VISIBILITY
_SampleIterator __sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __out,
_Distance __n,
_UniformRandomNumberGenerator &&__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
#endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */

592
include/experimental/any Normal file
View File

@@ -0,0 +1,592 @@
// -*- C++ -*-
//===------------------------------ any -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_ANY
#define _LIBCPP_EXPERIMENTAL_ANY
/*
experimental/any synopsis
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
class bad_any_cast : public bad_cast
{
public:
virtual const char* what() const noexcept;
};
class any
{
public:
// 6.3.1 any construct/destruct
any() noexcept;
any(const any& other);
any(any&& other) noexcept;
template <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 clear() noexcept;
void swap(any& rhs) noexcept;
// 6.3.4 any observers
bool empty() const noexcept;
const type_info& type() const noexcept;
};
// 6.4 Non-member functions
void swap(any& x, any& y) noexcept;
template<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
_LIBCPP_BEGIN_NAMESPACE_LFTS
class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast
{
public:
//TODO(EricWF) Enable or delete these.
//bad_any_cast() _NOEXCEPT;
//virtual ~bad_any_cast() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
};
#if _LIBCPP_STD_VER > 11 // C++ > 11
_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
inline void __throw_bad_any_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_any_cast();
#else
_VSTD::abort();
#endif
}
// Forward declarations
class any;
template <class _ValueType>
typename add_pointer<typename add_const<_ValueType>::type>::type
any_cast(any const *) _NOEXCEPT;
template <class _ValueType>
typename add_pointer<_ValueType>::type
any_cast(any *) _NOEXCEPT;
namespace __any_imp
{
typedef typename aligned_storage<3*sizeof(void*), alignment_of<void*>::value>::type
_Buffer;
template <class _Tp>
struct _IsSmallObject
: public 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>
using _Handler = typename conditional<_IsSmallObject<_Tp>::value
, _SmallHandler<_Tp>
, _LargeHandler<_Tp>
>::type;
template <class _ValueType>
using _EnableIfNotAny = typename
enable_if<
!is_same<typename decay<_ValueType>::type, any>::value
>::type;
} // namespace __any_imp
class any
{
public:
// 6.3.1 any construct/destruct
_LIBCPP_INLINE_VISIBILITY
any() _NOEXCEPT : __h(nullptr) {}
_LIBCPP_INLINE_VISIBILITY
any(any const & __other) : __h(nullptr)
{
if (__other.__h) __other.__call(_Action::_Copy, this);
}
_LIBCPP_INLINE_VISIBILITY
any(any && __other) _NOEXCEPT : __h(nullptr)
{
if (__other.__h) __other.__call(_Action::_Move, this);
}
template <
class _ValueType
, class = __any_imp::_EnableIfNotAny<_ValueType>
>
any(_ValueType && __value);
_LIBCPP_INLINE_VISIBILITY
~any()
{
this->clear();
}
// 6.3.2 any assignments
_LIBCPP_INLINE_VISIBILITY
any & operator=(any const & __rhs)
{
any(__rhs).swap(*this);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
any & operator=(any && __rhs) _NOEXCEPT
{
any(_VSTD::move(__rhs)).swap(*this);
return *this;
}
template <
class _ValueType
, class = __any_imp::_EnableIfNotAny<_ValueType>
>
any & operator=(_ValueType && __rhs);
// 6.3.3 any modifiers
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT
{
if (__h) this->__call(_Action::_Destroy);
}
void swap(any & __rhs) _NOEXCEPT;
// 6.3.4 any observers
_LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{
return __h == nullptr;
}
#if !defined(_LIBCPP_NO_RTTI)
_LIBCPP_INLINE_VISIBILITY
const type_info & type() const _NOEXCEPT
{
if (__h) {
return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
} else {
return typeid(void);
}
}
#endif
private:
typedef __any_imp::_Action _Action;
typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *);
union _Storage
{
void * __ptr;
__any_imp::_Buffer __buf;
};
_LIBCPP_ALWAYS_INLINE
void * __call(_Action __a, any * __other = nullptr,
type_info const * __info = nullptr) const
{
return __h(__a, this, __other, __info);
}
_LIBCPP_ALWAYS_INLINE
void * __call(_Action __a, any * __other = nullptr,
type_info const * __info = nullptr)
{
return __h(__a, this, __other, __info);
}
template <class>
friend struct __any_imp::_SmallHandler;
template <class>
friend struct __any_imp::_LargeHandler;
template <class _ValueType>
friend typename add_pointer<typename add_const<_ValueType>::type>::type
any_cast(any const *) _NOEXCEPT;
template <class _ValueType>
friend typename add_pointer<_ValueType>::type
any_cast(any *) _NOEXCEPT;
_HandleFuncPtr __h;
_Storage __s;
};
namespace __any_imp
{
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler
{
_LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this, any * __other,
type_info const * __info)
{
switch (__act)
{
case _Action::_Destroy:
__destroy(const_cast<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);
case _Action::_TypeInfo:
return __type_info();
}
}
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
static void __create(any & __dest, _Up && __v)
{
::new (static_cast<void*>(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v));
__dest.__h = &_SmallHandler::__handle;
}
private:
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this)
{
_Tp & __value = *static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
__value.~_Tp();
__this.__h = nullptr;
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __copy(any const & __this, any & __dest)
{
_SmallHandler::__create(__dest, *static_cast<_Tp const *>(
static_cast<void const *>(&__this.__s.__buf)));
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __move(any & __this, any & __dest)
{
_SmallHandler::__create(__dest, _VSTD::move(
*static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
__destroy(__this);
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void* __get(any & __this, type_info const * __info)
{
#if !defined(_LIBCPP_NO_RTTI)
if (typeid(_Tp) == *__info) {
return static_cast<void*>(&__this.__s.__buf);
}
return nullptr;
#else
return static_cast<void*>(&__this.__s.__buf);
#endif
}
_LIBCPP_ALWAYS_INLINE _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_TYPE_VIS_ONLY _LargeHandler
{
_LIBCPP_INLINE_VISIBILITY
static void* __handle(_Action __act, any const * __this, any * __other,
type_info const * __info)
{
switch (__act)
{
case _Action::_Destroy:
__destroy(const_cast<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);
case _Action::_TypeInfo:
return __type_info();
}
}
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
static void __create(any & __dest, _Up && __v)
{
typedef allocator<_Tp> _Alloc;
typedef __allocator_destructor<_Alloc> _Dp;
_Alloc __a;
unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v));
__dest.__s.__ptr = __hold.release();
__dest.__h = &_LargeHandler::__handle;
}
private:
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __destroy(any & __this)
{
delete static_cast<_Tp*>(__this.__s.__ptr);
__this.__h = nullptr;
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __copy(any const & __this, any & __dest)
{
_LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void __move(any & __this, any & __dest)
{
__dest.__s.__ptr = __this.__s.__ptr;
__dest.__h = &_LargeHandler::__handle;
__this.__h = nullptr;
}
_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
static void* __get(any & __this, type_info const * __info)
{
#if !defined(_LIBCPP_NO_RTTI)
if (typeid(_Tp) == *__info) {
return static_cast<void*>(__this.__s.__ptr);
}
return nullptr;
#else
return static_cast<void*>(__this.__s.__ptr);
#endif
}
_LIBCPP_ALWAYS_INLINE _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>
_LIBCPP_INLINE_VISIBILITY
any::any(_ValueType && __v) : __h(nullptr)
{
typedef typename decay<_ValueType>::type _Tp;
static_assert(is_copy_constructible<_Tp>::value,
"_ValueType must be CopyConstructible.");
typedef __any_imp::_Handler<_Tp> _HandlerType;
_HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v));
}
template <class _ValueType, class>
_LIBCPP_INLINE_VISIBILITY
any & any::operator=(_ValueType && __v)
{
typedef typename decay<_ValueType>::type _Tp;
static_assert(is_copy_constructible<_Tp>::value,
"_ValueType must be CopyConstructible.");
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
return *this;
}
inline _LIBCPP_INLINE_VISIBILITY
void any::swap(any & __rhs) _NOEXCEPT
{
if (__h && __rhs.__h) {
any __tmp;
__rhs.__call(_Action::_Move, &__tmp);
this->__call(_Action::_Move, &__rhs);
__tmp.__call(_Action::_Move, this);
}
else if (__h) {
this->__call(_Action::_Move, &__rhs);
}
else if (__rhs.__h) {
__rhs.__call(_Action::_Move, this);
}
}
// 6.4 Non-member functions
inline _LIBCPP_INLINE_VISIBILITY
void swap(any & __lhs, any & __rhs) _NOEXCEPT
{
__lhs.swap(__rhs);
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any const & __v)
{
static_assert(
is_reference<_ValueType>::value
|| is_copy_constructible<_ValueType>::value,
"_ValueType is required to be a reference or a CopyConstructible type.");
typedef typename add_const<typename remove_reference<_ValueType>::type>::type
_Tp;
_Tp * __tmp = any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return *__tmp;
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any & __v)
{
static_assert(
is_reference<_ValueType>::value
|| is_copy_constructible<_ValueType>::value,
"_ValueType is required to be a reference or a CopyConstructible type.");
typedef typename remove_reference<_ValueType>::type _Tp;
_Tp * __tmp = any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return *__tmp;
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
_ValueType any_cast(any && __v)
{
static_assert(
is_reference<_ValueType>::value
|| is_copy_constructible<_ValueType>::value,
"_ValueType is required to be a reference or a CopyConstructible type.");
typedef typename remove_reference<_ValueType>::type _Tp;
_Tp * __tmp = any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__throw_bad_any_cast();
return *__tmp;
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
typename add_pointer<typename add_const<_ValueType>::type>::type
any_cast(any const * __any) _NOEXCEPT
{
static_assert(!is_reference<_ValueType>::value,
"_ValueType may not be a reference.");
return any_cast<_ValueType>(const_cast<any *>(__any));
}
template <class _ValueType>
_LIBCPP_INLINE_VISIBILITY
typename add_pointer<_ValueType>::type
any_cast(any * __any) _NOEXCEPT
{
using __any_imp::_Action;
static_assert(!is_reference<_ValueType>::value,
"_ValueType may not be a reference.");
typedef typename add_pointer<_ValueType>::type _ReturnType;
if (__any && __any->__h) {
return static_cast<_ReturnType>(
__any->__call(_Action::_Get, nullptr,
#if !defined(_LIBCPP_NO_RTTI)
&typeid(_ValueType)
#else
nullptr
#endif
));
}
return nullptr;
}
#endif // _LIBCPP_STD_VER > 11
_LIBCPP_END_NAMESPACE_LFTS
#endif // _LIBCPP_EXPERIMENTAL_ANY

View File

@@ -45,12 +45,12 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
#if __has_feature(cxx_variable_templates)
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
= treat_as_floating_point<_Rep>::value;
#endif /* __has_feature(cxx_variable_templates) */
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
_LIBCPP_END_NAMESPACE_CHRONO_LFTS

View File

@@ -0,0 +1,133 @@
// -*- C++ -*-
//===-------------------------- functional --------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL
#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
/*
experimental/functional synopsis
#include <algorithm>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
// See C++14 §20.9.9, Function object binders
template <class T> constexpr bool is_bind_expression_v
= is_bind_expression<T>::value;
template <class T> constexpr int is_placeholder_v
= is_placeholder<T>::value;
// 4.2, Class template function
template<class> class function; // undefined
template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
template<class R, class... ArgTypes>
void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
template<class R, class... ArgTypes>
bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
template<class R, class... ArgTypes>
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
template<class R, class... ArgTypes>
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
// 4.3, Searchers
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
class default_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_searcher;
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
class boyer_moore_horspool_searcher;
template<class ForwardIterator, class BinaryPredicate = equal_to<>>
default_searcher<ForwardIterator, BinaryPredicate>
make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate>
make_boyer_moore_searcher(
RandomAccessIterator pat_first, RandomAccessIterator pat_last,
Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
template<class RandomAccessIterator,
class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
class BinaryPredicate = equal_to<>>
boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate>
make_boyer_moore_horspool_searcher(
RandomAccessIterator pat_first, RandomAccessIterator pat_last,
Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
} // namespace fundamentals_v1
} // namespace experimental
template<class R, class... ArgTypes, class Alloc>
struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
} // namespace std
*/
#include <experimental/__config>
#include <functional>
#include <algorithm>
#include <__undef_min_max>
#include <__debug>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
// default searcher
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
class default_searcher {
public:
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
template <typename _ForwardIterator2>
_ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const {
return _VSTD::search(__f, __l, __first_, __last_, __pred_);
}
private:
_ForwardIterator __first_;
_ForwardIterator __last_;
_BinaryPredicate __pred_;
};
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
default_searcher<_ForwardIterator, _BinaryPredicate>
make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
{
return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
}
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */

View File

@@ -48,7 +48,7 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_LFTS
#if __has_feature(cxx_variable_templates)
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
= ratio_equal<_R1, _R2>::value;
@@ -68,10 +68,10 @@ template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
= ratio_greater_equal<_R1, _R2>::value;
#endif /* __has_feature(cxx_variable_templates) */
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_STD_VER > 11 */
#endif _LIBCPP_EXPERIMENTAL_RATIO
#endif // _LIBCPP_EXPERIMENTAL_RATIO

View File

@@ -46,7 +46,7 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_LFTS
#if __has_feature(cxx_variable_templates)
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v
= is_error_code_enum<_Tp>::value;
@@ -54,7 +54,7 @@ template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_code_enum_v
template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v
= is_error_condition_enum<_Tp>::value;
#endif /* __has_feature(cxx_variable_templates) */
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
_LIBCPP_END_NAMESPACE_LFTS

View File

@@ -0,0 +1,81 @@
// -*- C++ -*-
//===----------------------------- tuple ----------------------------------===//
//
// 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_TUPLE
#define _LIBCPP_EXPERIMENTAL_TUPLE
/*
experimental/tuple synopsis
// C++1y
#include <tuple>
namespace std {
namespace experimental {
inline namespace fundamentals_v1 {
// See C++14 20.4.2.5, tuple helper classes
template <class T> constexpr size_t tuple_size_v
= tuple_size<T>::value;
// 3.2.2, Calling a function with a tuple of arguments
template <class F, class Tuple>
constexpr decltype(auto) apply(F&& f, Tuple&& t);
} // namespace fundamentals_v1
} // namespace experimental
} // namespace std
*/
# include <experimental/__config>
#if _LIBCPP_STD_VER > 11
# include <tuple>
# include <utility>
# include <__functional_base>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_LFTS
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
template <class _Tp>
_LIBCPP_CONSTEXPR size_t tuple_size_v = tuple_size<_Tp>::value;
#endif
template <class _Fn, class _Tuple, size_t ..._Id>
inline _LIBCPP_INLINE_VISIBILITY
decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
integer_sequence<size_t, _Id...>) {
return _VSTD::__invoke(
_VSTD::forward<_Fn>(__f),
_VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...
);
}
template <class _Fn, class _Tuple>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
decltype(auto) apply(_Fn && __f, _Tuple && __t) {
return _VSTD_LFTS::__apply_tuple_impl(
_VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
make_index_sequence<tuple_size<typename decay<_Tuple>::type>::value>()
);
}
_LIBCPP_END_NAMESPACE_LFTS
#endif /* _LIBCPP_STD_VER > 11 */
#endif /* _LIBCPP_EXPERIMENTAL_TUPLE */

View File

@@ -190,7 +190,7 @@ inline namespace fundamentals_v1 {
_LIBCPP_BEGIN_NAMESPACE_LFTS
#if __has_feature(cxx_variable_templates)
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
// C++14 20.10.4.1, primary type categories
@@ -397,7 +397,7 @@ template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
= is_convertible<_Tp, _Up>::value;
#endif /* __has_feature(cxx_variable_templates) */
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
// 3.3.2, Other type transformations
/*

View File

@@ -203,6 +203,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <__hash_table>
#include <functional>
#include <stdexcept>
#include <type_traits>
#include <ext/__hash>
#if __DEPRECATED
@@ -213,16 +214,16 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#endif
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif
namespace __gnu_cxx {
using namespace std;
template <class _Tp, class _Hash, bool = is_empty<_Hash>::value
#if __has_feature(is_final)
&& !__is_final(_Hash)
#endif
template <class _Tp, class _Hash,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
>
class __hash_map_hasher
: private _Hash
@@ -255,10 +256,8 @@ public:
{return __hash_(__x);}
};
template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
#if __has_feature(is_final)
&& !__is_final(_Pred)
#endif
template <class _Tp, class _Pred,
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
>
class __hash_map_equal
: private _Pred
@@ -493,13 +492,7 @@ private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -772,13 +765,7 @@ private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;

View File

@@ -107,8 +107,7 @@ public:
iterator erase_after(const_iterator first, const_iterator last);
void swap(forward_list& x)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
void resize(size_type n);
void resize(size_type n, const value_type& v);
@@ -365,24 +364,12 @@ protected:
typedef typename allocator_traits<allocator_type>::void_pointer void_pointer;
typedef __forward_list_node<value_type, void_pointer> __node;
typedef typename __begin_node_of<value_type, void_pointer>::type __begin_node;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
typedef typename __node_traits::pointer __node_pointer;
typedef typename __node_traits::pointer __node_const_pointer;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__begin_node>
#else
rebind_alloc<__begin_node>::other
#endif
__begin_node_allocator;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __begin_node>::type __begin_node_allocator;
typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer;
__compressed_pair<__begin_node, __node_allocator> __before_begin_;
@@ -443,8 +430,12 @@ protected:
public:
void swap(__forward_list_base& __x)
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value);
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
__is_nothrow_swappable<__node_allocator>::value);
#endif
protected:
void clear() _NOEXCEPT;
@@ -466,26 +457,6 @@ private:
void __move_assign_alloc(__forward_list_base& __x, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value)
{__alloc() = _VSTD::move(__x.__alloc());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__node_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y,
false_type)
_NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y,
true_type)
_NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
};
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -524,10 +495,15 @@ template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
__forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
__swap_alloc(__alloc(), __x.__alloc());
__swap_allocator(__alloc(), __x.__alloc(),
integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
using _VSTD::swap;
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
}
@@ -715,8 +691,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(forward_list& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{base::swap(__x);}
void resize(size_type __n);

View File

@@ -206,8 +206,10 @@ public:
// 27.9.1.4 Members:
bool is_open() const;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
basic_filebuf* open(const char* __s, ios_base::openmode __mode);
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
#endif
basic_filebuf* close();
protected:
@@ -463,6 +465,7 @@ basic_filebuf<_CharT, _Traits>::is_open() const
return __file_ != 0;
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -550,6 +553,7 @@ basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod
{
return open(__s.c_str(), __mode);
}
#endif
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>*
@@ -1005,8 +1009,10 @@ public:
typedef typename traits_type::off_type off_type;
basic_ifstream();
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
basic_ifstream(basic_ifstream&& __rhs);
#endif
@@ -1018,8 +1024,10 @@ public:
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::in);
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
#endif
void close();
private:
@@ -1033,6 +1041,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream()
{
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
@@ -1050,6 +1059,7 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope
if (__sb_.open(__s, __mode | ios_base::in) == 0)
this->setstate(ios_base::failbit);
}
#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1107,6 +1117,7 @@ basic_ifstream<_CharT, _Traits>::is_open() const
return __sb_.is_open();
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
void
basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1126,6 +1137,7 @@ basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
else
this->setstate(ios_base::failbit);
}
#endif
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1163,8 +1175,10 @@ public:
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::out);
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
#endif
void close();
private:
@@ -1178,6 +1192,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream()
{
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
@@ -1195,6 +1210,7 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope
if (__sb_.open(__s, __mode | ios_base::out) == 0)
this->setstate(ios_base::failbit);
}
#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1252,6 +1268,7 @@ basic_ofstream<_CharT, _Traits>::is_open() const
return __sb_.is_open();
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
void
basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1271,6 +1288,7 @@ basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mo
else
this->setstate(ios_base::failbit);
}
#endif
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
@@ -1295,8 +1313,10 @@ public:
typedef typename traits_type::off_type off_type;
basic_fstream();
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
basic_fstream(basic_fstream&& __rhs);
#endif
@@ -1308,8 +1328,10 @@ public:
basic_filebuf<char_type, traits_type>* rdbuf() const;
bool is_open() const;
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#endif
void close();
private:
@@ -1323,6 +1345,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream()
{
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
@@ -1340,6 +1363,7 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm
if (__sb_.open(__s, __mode) == 0)
this->setstate(ios_base::failbit);
}
#endif
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1397,6 +1421,7 @@ basic_fstream<_CharT, _Traits>::is_open() const
return __sb_.is_open();
}
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
template <class _CharT, class _Traits>
void
basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
@@ -1416,6 +1441,7 @@ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod
else
this->setstate(ios_base::failbit);
}
#endif
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY

View File

@@ -1234,11 +1234,9 @@ const_mem_fun1_ref_t<_Sp,_Tp,_Ap>
mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const)
{return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);}
#ifdef _LIBCPP_HAS_NO_VARIADICS
#include <__functional_03>
#else // _LIBCPP_HAS_NO_VARIADICS
////////////////////////////////////////////////////////////////////////////////
// MEMFUN
//==============================================================================
template <class _Tp>
class __mem_fn
@@ -1253,14 +1251,34 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {}
#ifndef _LIBCPP_HAS_NO_VARIADICS
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const
{
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
}
_LIBCPP_INLINE_VISIBILITY
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...);
}
#else
template <class _A0>
typename __invoke_return0<type, _A0>::type
operator() (_A0& __a0) const {
return __invoke(__f_, __a0);
}
template <class _A0, class _A1>
typename __invoke_return1<type, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const {
return __invoke(__f_, __a0, __a1);
}
template <class _A0, class _A1, class _A2>
typename __invoke_return2<type, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const {
return __invoke(__f_, __a0, __a1, __a2);
}
#endif
};
template<class _Rp, class _Tp>
@@ -1271,6 +1289,10 @@ mem_fn(_Rp _Tp::* __pm)
return __mem_fn<_Rp _Tp::*>(__pm);
}
////////////////////////////////////////////////////////////////////////////////
// FUNCTION
//==============================================================================
// bad_function_call
class _LIBCPP_EXCEPTION_ABI bad_function_call
@@ -1283,7 +1305,7 @@ template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
namespace __function
{
template<class _Rp, class ..._ArgTypes>
template<class _Rp>
struct __maybe_derive_from_unary_function
{
};
@@ -1294,7 +1316,7 @@ struct __maybe_derive_from_unary_function<_Rp(_A1)>
{
};
template<class _Rp, class ..._ArgTypes>
template<class _Rp>
struct __maybe_derive_from_binary_function
{
};
@@ -1305,6 +1327,12 @@ struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)>
{
};
} // namespace __function
#ifndef _LIBCPP_HAS_NO_VARIADICS
namespace __function {
template<class _Fp> class __base;
template<class _Rp, class ..._ArgTypes>
@@ -1367,7 +1395,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
__base<_Rp(_ArgTypes...)>*
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
@@ -1393,7 +1422,8 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
typedef typename _Alloc::template rebind<__func>::other _Ap;
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
_Ap __a(__f_.second());
__f_.~__compressed_pair<_Fp, _Alloc>();
__a.deallocate(this, 1);
@@ -1654,13 +1684,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _
if (__not_null(__f))
{
typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<_FF>
#else
rebind_alloc<_FF>::other
#endif
_Ap;
typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap;
_Ap __a(__a0);
if (sizeof(_FF) <= sizeof(__buf_) &&
is_nothrow_copy_constructible<_Fp>::value && is_nothrow_copy_constructible<_Ap>::value)
@@ -1852,6 +1876,16 @@ void
swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT
{return __x.swap(__y);}
#else // _LIBCPP_HAS_NO_VARIADICS
#include <__functional_03>
#endif
////////////////////////////////////////////////////////////////////////////////
// BIND
//==============================================================================
template<class _Tp> struct __is_bind_expression : public false_type {};
template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression
: public __is_bind_expression<typename remove_cv<_Tp>::type> {};
@@ -1882,6 +1916,9 @@ template<int _Np>
struct __is_placeholder<placeholders::__ph<_Np> >
: public integral_constant<int, _Np> {};
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY
_Tp&
@@ -2000,27 +2037,27 @@ struct __mu_return
};
template <class _Fp, class _BoundArgs, class _TupleUj>
struct _is_valid_bind_return
struct __is_valid_bind_return
{
static const bool value = false;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
{
static const bool value = __invokable<_Fp,
typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct _is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
static const bool value = __invokable<_Fp,
typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class _BoundArgs, class _TupleUj,
bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
struct __bind_return;
template <class _Fp, class ..._BoundArgs, class _TupleUj>
@@ -2190,12 +2227,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
result_type>::value,
result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args)
{
return base::operator()(_VSTD::forward<_Args>(__args)...);
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
@@ -2203,12 +2241,13 @@ public:
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
result_type>::value,
result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args) const
{
return base::operator()(_VSTD::forward<_Args>(__args)...);
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base const&>(*this), _VSTD::forward<_Args>(__args)...);
}
};
@@ -2404,14 +2443,14 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
size_t __b;
size_t __c;
size_t __d;
};
} __s;
} __u;
__u.__a = 0;
__u.__b = 0;
__u.__c = 0;
__u.__d = 0;
__u.__s.__a = 0;
__u.__s.__b = 0;
__u.__s.__c = 0;
__u.__s.__d = 0;
__u.__t = __v;
return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d;
return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
#elif defined(__x86_64__)
// Zero out padding bits
union
@@ -2421,12 +2460,12 @@ struct _LIBCPP_TYPE_VIS_ONLY hash<long double>
{
size_t __a;
size_t __b;
};
} __s;
} __u;
__u.__a = 0;
__u.__b = 0;
__u.__s.__a = 0;
__u.__s.__b = 0;
__u.__t = __v;
return __u.__a ^ __u.__b;
return __u.__s.__a ^ __u.__s.__b;
#else
return __scalar_hash<long double>::operator()(__v);
#endif
@@ -2449,6 +2488,15 @@ struct _LIBCPP_TYPE_VIS_ONLY hash
};
#endif
#if _LIBCPP_STD_VER > 14
template <class _Fn, class ..._Args>
result_of_t<_Fn&&(_Args&&...)>
invoke(_Fn&& __f, _Args&&... __args) {
return __invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
}
#endif
// struct hash<T*> in <memory>
_LIBCPP_END_NAMESPACE_STD

View File

@@ -329,7 +329,7 @@ public:
template <class F>
explicit packaged_task(F&& f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
packaged_task(allocator_arg_t, const Allocator& a, F&& f);
~packaged_task();
// no copy
@@ -651,7 +651,6 @@ __assoc_state<_Rp>::set_value(_Arg& __arg)
#endif
::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed | base::ready;
__lk.unlock();
__cv_.notify_all();
}
@@ -672,7 +671,6 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg)
::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg));
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
}
template <class _Rp>
@@ -733,7 +731,6 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg)
#endif
__value_ = _VSTD::addressof(__arg);
this->__state_ |= base::__constructed | base::ready;
__lk.unlock();
__cv_.notify_all();
}
@@ -749,7 +746,6 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg)
__value_ = _VSTD::addressof(__arg);
this->__state_ |= base::__constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
}
template <class _Rp>
@@ -2046,7 +2042,7 @@ public:
>::type
>
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
__p_(allocator_arg, __a) {}
// ~packaged_task() = default;
@@ -2177,7 +2173,7 @@ public:
>::type
>
_LIBCPP_INLINE_VISIBILITY
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
__p_(allocator_arg, __a) {}
// ~packaged_task() = default;

View File

@@ -46,13 +46,17 @@ extern wostream wclog;
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_STDIN
extern _LIBCPP_FUNC_VIS istream cin;
extern _LIBCPP_FUNC_VIS ostream cout;
extern _LIBCPP_FUNC_VIS ostream cerr;
extern _LIBCPP_FUNC_VIS ostream clog;
extern _LIBCPP_FUNC_VIS wistream wcin;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
extern _LIBCPP_FUNC_VIS ostream cout;
extern _LIBCPP_FUNC_VIS wostream wcout;
#endif
extern _LIBCPP_FUNC_VIS ostream cerr;
extern _LIBCPP_FUNC_VIS wostream wcerr;
extern _LIBCPP_FUNC_VIS ostream clog;
extern _LIBCPP_FUNC_VIS wostream wclog;
_LIBCPP_END_NAMESPACE_STD

View File

@@ -214,7 +214,7 @@ public:
typedef traits traits_type;
typedef basic_istream<charT,traits> istream_type;
istream_iterator();
constexpr istream_iterator();
istream_iterator(istream_type& s);
istream_iterator(const istream_iterator& x);
~istream_iterator();
@@ -575,7 +575,7 @@ public:
_LIBCPP_INLINE_VISIBILITY reverse_iterator& operator-=(difference_type __n)
{current += __n; return *this;}
_LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
{return current[-__n-1];}
{return *(*this + __n);}
};
template <class _Iter1, class _Iter2>
@@ -765,7 +765,7 @@ private:
istream_type* __in_stream_;
_Tp __value_;
public:
_LIBCPP_INLINE_VISIBILITY istream_iterator() : __in_stream_(0) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(0), __value_() {}
_LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(&__s)
{
if (!(*__in_stream_ >> __value_))
@@ -1112,8 +1112,6 @@ typename enable_if
>::type
__unwrap_iter(__wrap_iter<_Tp*>);
template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY vector;
template <class _Iter>
class __wrap_iter
{
@@ -1243,7 +1241,7 @@ private:
template <class _Up> friend class __wrap_iter;
template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
template <class _Tp, class _Alloc> friend class vector;
template <class _Tp, class _Alloc> friend class _LIBCPP_TYPE_VIS_ONLY vector;
template <class _Iter1, class _Iter2>
friend

View File

@@ -118,8 +118,7 @@ public:
void resize(size_type sz, const value_type& c);
void swap(list&)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
noexcept(allocator_traits<allocator_type>::is_always_equal::value); // C++17
void clear() noexcept;
void splice(const_iterator position, list& x);
@@ -515,13 +514,7 @@ protected:
typedef __list_const_iterator<value_type, __void_pointer> const_iterator;
typedef __list_node_base<value_type, __void_pointer> __node_base;
typedef __list_node<value_type, __void_pointer> __node;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node>
#else
rebind_alloc<__node>::other
#endif
__node_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_alloc_traits;
typedef typename __node_alloc_traits::pointer __node_pointer;
typedef typename __node_alloc_traits::pointer __node_const_pointer;
@@ -529,13 +522,7 @@ protected:
typedef typename __alloc_traits::const_pointer const_pointer;
typedef typename __alloc_traits::difference_type difference_type;
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__node_base>
#else
rebind_alloc<__node_base>::other
#endif
__node_base_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __node_base>::type __node_base_allocator;
typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
__node_base __end_;
@@ -605,8 +592,12 @@ protected:
}
void swap(__list_imp& __c)
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value);
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __list_imp& __c)
@@ -622,24 +613,6 @@ protected:
__node_alloc_traits::propagate_on_container_move_assignment::value>());}
private:
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y)
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__node_alloc_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<__node_allocator>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__node_allocator& __x, __node_allocator& __y, false_type)
_NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __list_imp& __c, true_type)
{
@@ -740,15 +713,19 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
template <class _Tp, class _Alloc>
void
__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
_LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
this->__node_alloc() == __c.__node_alloc(),
"list::swap: Either propagate_on_container_swap must be true"
" or the allocators must compare equal");
using _VSTD::swap;
__swap_alloc(__node_alloc(), __c.__node_alloc());
__swap_allocator(__node_alloc(), __c.__node_alloc());
swap(__sz(), __c.__sz());
swap(__end_, __c.__end_);
if (__sz() == 0)
@@ -984,8 +961,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(list& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{base::swap(__c);}
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT {base::clear();}
@@ -1480,7 +1461,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
for (++__f; __f != __l; ++__f, ++__e, ++__ds)
for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds)
{
__hold.reset(__node_alloc_traits::allocate(__na, 1));
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);

View File

@@ -198,7 +198,8 @@ template <class charT> class messages_byname;
// include of <sys/cdefs.h> once https://sourceware.org/ml/newlib-cvs/2014-q3/msg00038.html
// has had a chance to bake for a bit
#include <support/newlib/xlocale.h>
#elif !defined(__ANDROID__)
#endif
#ifdef _LIBCPP_HAS_CATOPEN
#include <nl_types.h>
#endif
@@ -216,7 +217,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if defined(__APPLE__) || defined(__FreeBSD__)
# define _LIBCPP_GET_C_LOCALE 0
#elif defined(__NetBSD__)
#elif defined(__CloudABI__) || defined(__NetBSD__)
# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
#else
# define _LIBCPP_GET_C_LOCALE __cloc()
@@ -235,7 +236,7 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii;
// locale. Linux, not so much. The following functions avoid the locale when
// that's possible and otherwise do the wrong thing. FIXME.
#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \
defined(_NEWLIB_VERSION)
defined(_NEWLIB_VERSION) || defined(__GLIBC__)
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
@@ -1190,7 +1191,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
if (sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
#else
if (__sscanf_l(__buf.c_str(), __cloc(), "%p", &__v) != 1)
if (__sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
#endif
__err = ios_base::failbit;
// EOF checked
@@ -1560,7 +1561,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1590,7 +1591,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1620,7 +1621,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1650,7 +1651,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -1682,14 +1683,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#else
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
(int)__iob.precision(), __v);
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
unique_ptr<char, void(*)(void*)> __nbh(0, free);
if (__nc > static_cast<int>(__nbuf-1))
@@ -1698,14 +1699,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#else
__nc = __asprintf_l(&__nb, __cloc(), __fmt,
(int)__iob.precision(), __v);
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
__nc = __asprintf_l(&__nb, __cloc(), __fmt, (int)__iob.precision(), __v);
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
if (__nb == 0)
__throw_bad_alloc();
@@ -1751,14 +1751,14 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#else
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt,
(int)__iob.precision(), __v);
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt,
(int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
__nc = __snprintf_l(__nb, __nbuf, __cloc(), __fmt, __v);
__nc = __snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
unique_ptr<char, void(*)(void*)> __nbh(0, free);
if (__nc > static_cast<int>(__nbuf-1))
@@ -1767,14 +1767,13 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#else
__nc = __asprintf_l(&__nb, __cloc(), __fmt,
(int)__iob.precision(), __v);
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
#endif
else
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__nc = asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
__nc = __asprintf_l(&__nb, __cloc(), __fmt, __v);
__nc = __asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
if (__nb == 0)
__throw_bad_alloc();
@@ -1814,7 +1813,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
int __nc = snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#else
int __nc = __snprintf_l(__nar, sizeof(__nar), __cloc(), __fmt, __v);
int __nc = __snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
#endif
char* __ne = __nar + __nc;
char* __np = this->__identify_padding(__nar, __ne, __iob);
@@ -3527,7 +3526,7 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl,
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
__n = static_cast<size_t>(asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units));
#else
__n = __asprintf_l(&__bb, __cloc(), "%.0Lf", __units);
__n = __asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
#endif
if (__bb == 0)
__throw_bad_alloc();
@@ -3681,14 +3680,14 @@ template <class _CharT>
typename messages<_CharT>::catalog
messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const
{
#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
return -1;
#else // _WIN32 || __ANDROID__
#ifdef _LIBCPP_HAS_CATOPEN
catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
if (__cat != -1)
__cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1));
return __cat;
#endif // _WIN32 || __ANDROID__
#else // !_LIBCPP_HAS_CATOPEN
return -1;
#endif // _LIBCPP_HAS_CATOPEN
}
template <class _CharT>
@@ -3696,9 +3695,7 @@ typename messages<_CharT>::string_type
messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
const string_type& __dflt) const
{
#if defined(_WIN32) || defined(__ANDROID__) || defined(_NEWLIB_VERSION)
return __dflt;
#else // _WIN32
#ifdef _LIBCPP_HAS_CATOPEN
string __ndflt;
__narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__ndflt),
__dflt.c_str(),
@@ -3711,19 +3708,21 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid,
__widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(back_inserter(__w),
__n, __n + strlen(__n));
return __w;
#endif // _WIN32
#else // !_LIBCPP_HAS_CATOPEN
return __dflt;
#endif // _LIBCPP_HAS_CATOPEN
}
template <class _CharT>
void
messages<_CharT>::do_close(catalog __c) const
{
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(_NEWLIB_VERSION)
#ifdef _LIBCPP_HAS_CATOPEN
if (__c != -1)
__c <<= 1;
nl_catd __cat = (nl_catd)__c;
catclose(__cat);
#endif // !_WIN32
#endif // _LIBCPP_HAS_CATOPEN
}
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>)

View File

@@ -135,16 +135,32 @@ public:
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type> il);
template <class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
template <class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
template <class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
template <class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
template <class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
template <class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
template <class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
template <class M>
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(map& m)
noexcept(
__is_nothrow_swappable<key_compare>::value &&
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value));
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
__is_nothrow_swappable<key_compare>::value); // C++17
// observers:
allocator_type get_allocator() const noexcept;
@@ -330,15 +346,14 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(multimap& m)
noexcept(
__is_nothrow_swappable<key_compare>::value &&
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value));
noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
__is_nothrow_swappable<key_compare>::value); // C++17
// observers:
allocator_type get_allocator() const noexcept;
@@ -426,6 +441,7 @@ swap(multimap<Key, T, Compare, Allocator>& x,
#include <utility>
#include <functional>
#include <initializer_list>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -433,10 +449,8 @@ swap(multimap<Key, T, Compare, Allocator>& x,
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _CP, class _Compare, bool = is_empty<_Compare>::value
#if __has_feature(is_final)
&& !__is_final(_Compare)
#endif
template <class _Key, class _CP, class _Compare,
bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value
>
class __map_value_compare
: private _Compare
@@ -461,6 +475,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _CP& __y) const
{return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);}
void swap(__map_value_compare&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
{
using _VSTD::swap;
swap(static_cast<const _Compare&>(*this), static_cast<const _Compare&>(__y));
}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
@@ -503,6 +523,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _CP& __y) const
{return comp(__x, __y.__cc.first);}
void swap(__map_value_compare&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Compare>::value)
{
using _VSTD::swap;
swap(comp, __y.comp);
}
#if _LIBCPP_STD_VER > 11
template <typename _K2>
@@ -519,6 +545,16 @@ public:
#endif
};
template <class _Key, class _CP, class _Compare, bool __b>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__map_value_compare<_Key, _CP, _Compare, __b>& __x,
__map_value_compare<_Key, _CP, _Compare, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
template <class _Allocator>
class __map_node_destructor
{
@@ -822,13 +858,8 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
typedef allocator_traits<allocator_type> __alloc_traits;
@@ -1081,9 +1112,125 @@ public:
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#if _LIBCPP_STD_VER > 14
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
return _VSTD::make_pair(__p, false);
else
return _VSTD::make_pair(
emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
true);
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
return _VSTD::make_pair(__p, false);
else
return _VSTD::make_pair(
emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
true);
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
return __p;
else
return emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
return __p;
else
return emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
{
__p->second = _VSTD::forward<_Vp>(__v);
return _VSTD::make_pair(__p, false);
}
return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
{
__p->second = _VSTD::forward<_Vp>(__v);
return _VSTD::make_pair(__p, false);
}
return _VSTD::make_pair(emplace_hint(__p, _VSTD::move(__k), _VSTD::forward<_Vp>(__v)), true);
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
{
__p->second = _VSTD::forward<_Vp>(__v);
return __p;
}
return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
{
iterator __p = lower_bound(__k);
if ( __p != end() && !key_comp()(__k, __p->first))
{
__p->second = _VSTD::forward<_Vp>(__v);
return __p;
}
return emplace_hint(__h, _VSTD::move(__k), _VSTD::forward<_Vp>(__v));
}
#endif
#endif
#endif
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k)
{return __tree_.__erase_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
@@ -1119,7 +1266,7 @@ public:
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_unique(__k);}
count(const _K2& __k) const {return __tree_.__count_unique(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
@@ -1568,13 +1715,8 @@ private:
typedef _VSTD::__value_type<key_type, mapped_type> __value_type;
typedef __map_value_compare<key_type, __value_type, key_compare> __vc;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __tree<__value_type, __vc, __allocator_type> __base;
typedef typename __base::__node_traits __node_traits;
typedef allocator_traits<allocator_type> __alloc_traits;
@@ -1821,6 +1963,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(iterator __p) {return __tree_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __f, const_iterator __l)
@@ -1855,7 +1999,7 @@ public:
template <typename _K2>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_multi(__k);}
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)

View File

@@ -75,6 +75,8 @@ struct allocator_traits
| false_type propagate_on_container_move_assignment;
typedef Alloc::propagate_on_container_swap
| false_type propagate_on_container_swap;
typedef Alloc::is_always_equal
| is_empty is_always_equal;
template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
@@ -623,6 +625,18 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ValueType>
inline _LIBCPP_ALWAYS_INLINE
_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
defined(__ATOMIC_RELAXED) && \
(__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
return __atomic_load_n(__value, __ATOMIC_RELAXED);
#else
return *__value;
#endif
}
// addressof moved to <__functional_base>
template <class _Tp> class allocator;
@@ -1144,6 +1158,29 @@ struct __propagate_on_container_swap<_Alloc, true>
typedef typename _Alloc::propagate_on_container_swap type;
};
template <class _Tp>
struct __has_is_always_equal
{
private:
struct __two {char __lx; char __lxx;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::is_always_equal* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
struct __is_always_equal
{
typedef typename _VSTD::is_empty<_Alloc>::type type;
};
template <class _Alloc>
struct __is_always_equal<_Alloc, true>
{
typedef typename _Alloc::is_always_equal type;
};
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __has_rebind_other
{
@@ -1423,6 +1460,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
propagate_on_container_move_assignment;
typedef typename __propagate_on_container_swap<allocator_type>::type
propagate_on_container_swap;
typedef typename __is_always_equal<allocator_type>::type
is_always_equal;
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
template <class _Tp> using rebind_alloc =
@@ -1521,8 +1560,42 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
__construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
ptrdiff_t _Np = __end1 - __begin1;
_VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
if (_Np > 0)
{
_VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
}
}
template <class _Iter, class _Ptr>
_LIBCPP_INLINE_VISIBILITY
static
void
__construct_range_forward(allocator_type& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
>::type
__construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
{
typedef typename remove_const<_Tp>::type _Vp;
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
{
_VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));
__begin2 += _Np;
}
}
template <class _Ptr>
@@ -1552,7 +1625,8 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits
{
ptrdiff_t _Np = __end1 - __begin1;
__end2 -= _Np;
_VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
if (_Np > 0)
_VSTD::memcpy(__end2, __begin1, _Np * sizeof(_Tp));
}
private:
@@ -1607,6 +1681,16 @@ private:
{return __a;}
};
template <class _Traits, class _Tp>
struct __rebind_alloc_helper
{
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
typedef typename _Traits::template rebind_alloc<_Tp> type;
#else
typedef typename _Traits::template rebind_alloc<_Tp>::other type;
#endif
};
// allocator
template <class _Tp>
@@ -1622,6 +1706,7 @@ public:
typedef _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
@@ -1714,6 +1799,7 @@ public:
typedef const _Tp value_type;
typedef true_type propagate_on_container_move_assignment;
typedef true_type is_always_equal;
template <class _Up> struct rebind {typedef allocator<_Up> other;};
@@ -1817,6 +1903,9 @@ public:
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;}
_LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int)
{raw_storage_iterator __t(*this); ++__x_; return __t;}
#if _LIBCPP_STD_VER >= 14
_LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; }
#endif
};
template <class _Tp>
@@ -1906,14 +1995,9 @@ public:
template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type,
typename remove_cv<_T2>::type>::value,
bool = is_empty<_T1>::value
#if __has_feature(is_final)
&& !__is_final(_T1)
#endif
,
&& !__libcpp_is_final<_T1>::value,
bool = is_empty<_T2>::value
#if __has_feature(is_final)
&& !__is_final(_T2)
#endif
&& !__libcpp_is_final<_T2>::value
>
struct __libcpp_compressed_pair_switch;
@@ -1951,11 +2035,11 @@ public:
typedef const typename remove_reference<_T1>::type& _T1_const_reference;
typedef const typename remove_reference<_T2>::type& _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_(), __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
: __first_(_VSTD::forward<_T1_param>(__t1)) {}
: __first_(_VSTD::forward<_T1_param>(__t1)), __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
: __second_(_VSTD::forward<_T2_param>(__t2)) {}
: __first_(), __second_(_VSTD::forward<_T2_param>(__t2)) {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
: __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {}
@@ -2044,9 +2128,9 @@ public:
typedef const _T1& _T1_const_reference;
typedef const typename remove_reference<_T2>::type& _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
: _T1(_VSTD::forward<_T1_param>(__t1)) {}
: _T1(_VSTD::forward<_T1_param>(__t1)), __second_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
: __second_(_VSTD::forward<_T2_param>(__t2)) {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
@@ -2134,11 +2218,11 @@ public:
typedef const typename remove_reference<_T1>::type& _T1_const_reference;
typedef const _T2& _T2_const_reference;
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp() : __first_() {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T1_param __t1)
: __first_(_VSTD::forward<_T1_param>(__t1)) {}
_LIBCPP_INLINE_VISIBILITY explicit __libcpp_compressed_pair_imp(_T2_param __t2)
: _T2(_VSTD::forward<_T2_param>(__t2)) {}
: _T2(_VSTD::forward<_T2_param>(__t2)), __first_() {}
_LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2)
_NOEXCEPT_(is_nothrow_move_constructible<_T1>::value &&
is_nothrow_move_constructible<_T2>::value)
@@ -3336,7 +3420,7 @@ struct __scalar_hash<_Tp, 2>
{
size_t __a;
size_t __b;
};
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3358,7 +3442,7 @@ struct __scalar_hash<_Tp, 3>
size_t __a;
size_t __b;
size_t __c;
};
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3381,7 +3465,7 @@ struct __scalar_hash<_Tp, 4>
size_t __b;
size_t __c;
size_t __d;
};
} __s;
} __u;
__u.__t = __v;
return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
@@ -3486,8 +3570,8 @@ uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r)
try
{
#endif
for (; __f != __l; ++__f, ++__r)
::new(&*__r) value_type(*__f);
for (; __f != __l; ++__f, (void) ++__r)
::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3510,8 +3594,8 @@ uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r)
try
{
#endif
for (; __n > 0; ++__f, ++__r, --__n)
::new(&*__r) value_type(*__f);
for (; __n > 0; ++__f, (void) ++__r, (void) --__n)
::new (static_cast<void*>(_VSTD::addressof(*__r))) value_type(*__f);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3535,7 +3619,7 @@ uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x)
{
#endif
for (; __f != __l; ++__f)
::new(&*__f) value_type(__x);
::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3557,8 +3641,8 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x)
try
{
#endif
for (; __n > 0; ++__f, --__n)
::new(&*__f) value_type(__x);
for (; __n > 0; ++__f, (void) --__n)
::new (static_cast<void*>(_VSTD::addressof(*__f))) value_type(__x);
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
@@ -3600,7 +3684,9 @@ public:
void __add_shared() _NOEXCEPT;
bool __release_shared() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
long use_count() const _NOEXCEPT {return __shared_owners_ + 1;}
long use_count() const _NOEXCEPT {
return __libcpp_relaxed_load(&__shared_owners_) + 1;
}
};
class _LIBCPP_TYPE_VIS __shared_weak_count
@@ -4002,11 +4088,15 @@ private:
__enable_weak_this(const enable_shared_from_this<_Yp>* __e) _NOEXCEPT
{
if (__e)
__e->__weak_this_ = *this;
{
__e->__weak_this_.__ptr_ = const_cast<_Yp*>(static_cast<const _Yp*>(__e));
__e->__weak_this_.__cntrl_ = __cntrl_;
__cntrl_->__add_weak();
}
}
_LIBCPP_INLINE_VISIBILITY
void __enable_weak_this(const void*) _NOEXCEPT {}
void __enable_weak_this(const volatile void*) _NOEXCEPT {}
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr;
template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
@@ -4236,9 +4326,16 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
>::type)
: __ptr_(__r.get())
{
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
__enable_weak_this(__r.get());
#if _LIBCPP_STD_VER > 11
if (__ptr_ == nullptr)
__cntrl_ = nullptr;
else
#endif
{
typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
__enable_weak_this(__r.get());
}
__r.release();
}
@@ -4258,11 +4355,18 @@ shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp> __r,
>::type)
: __ptr_(__r.get())
{
typedef __shared_ptr_pointer<_Yp*,
reference_wrapper<typename remove_reference<_Dp>::type>,
allocator<_Yp> > _CntrlBlk;
__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
__enable_weak_this(__r.get());
#if _LIBCPP_STD_VER > 11
if (__ptr_ == nullptr)
__cntrl_ = nullptr;
else
#endif
{
typedef __shared_ptr_pointer<_Yp*,
reference_wrapper<typename remove_reference<_Dp>::type>,
allocator<_Yp> > _CntrlBlk;
__cntrl_ = new _CntrlBlk(__r.get(), ref(__r.get_deleter()), allocator<_Yp>());
__enable_weak_this(__r.get());
}
__r.release();
}
@@ -5439,6 +5543,38 @@ undeclare_reachable(_Tp* __p)
_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space);
// --- Helper for container swap --
template <typename _Alloc>
_LIBCPP_INLINE_VISIBILITY
void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
#endif
{
__swap_allocator(__a1, __a2,
integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
}
template <typename _Alloc>
_LIBCPP_INLINE_VISIBILITY
void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
#endif
{
using _VSTD::swap;
swap(__a1, __a2);
}
template <typename _Alloc>
_LIBCPP_INLINE_VISIBILITY
void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_MEMORY

View File

@@ -175,6 +175,7 @@ template<class Callable, class ...Args>
#include <__config>
#include <__mutex_base>
#include <functional>
#include <memory>
#ifndef _LIBCPP_HAS_NO_VARIADICS
#include <tuple>
#endif
@@ -442,7 +443,11 @@ void call_once(once_flag&, _Callable&&, _Args&&...);
template<class _Callable>
_LIBCPP_INLINE_VISIBILITY
void call_once(once_flag&, _Callable);
void call_once(once_flag&, _Callable&);
template<class _Callable>
_LIBCPP_INLINE_VISIBILITY
void call_once(once_flag&, const _Callable&);
#endif // _LIBCPP_HAS_NO_VARIADICS
@@ -465,7 +470,11 @@ private:
#else // _LIBCPP_HAS_NO_VARIADICS
template<class _Callable>
friend
void call_once(once_flag&, _Callable);
void call_once(once_flag&, _Callable&);
template<class _Callable>
friend
void call_once(once_flag&, const _Callable&);
#endif // _LIBCPP_HAS_NO_VARIADICS
};
@@ -474,15 +483,10 @@ private:
template <class _Fp>
class __call_once_param
{
_Fp __f_;
_Fp& __f_;
public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
#else
_LIBCPP_INLINE_VISIBILITY
explicit __call_once_param(const _Fp& __f) : __f_(__f) {}
#endif
explicit __call_once_param(_Fp& __f) : __f_(__f) {}
_LIBCPP_INLINE_VISIBILITY
void operator()()
@@ -496,7 +500,7 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __execute(__tuple_indices<_Indices...>)
{
__invoke(_VSTD::move(_VSTD::get<0>(__f_)), _VSTD::move(_VSTD::get<_Indices>(__f_))...);
__invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...);
}
};
@@ -505,15 +509,10 @@ private:
template <class _Fp>
class __call_once_param
{
_Fp __f_;
_Fp& __f_;
public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
explicit __call_once_param(_Fp&& __f) : __f_(_VSTD::move(__f)) {}
#else
_LIBCPP_INLINE_VISIBILITY
explicit __call_once_param(const _Fp& __f) : __f_(__f) {}
#endif
explicit __call_once_param(_Fp& __f) : __f_(__f) {}
_LIBCPP_INLINE_VISIBILITY
void operator()()
@@ -541,11 +540,11 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
{
if (__flag.__state_ != ~0ul)
if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
{
typedef tuple<typename decay<_Callable>::type, typename decay<_Args>::type...> _Gp;
__call_once_param<_Gp> __p(_Gp(__decay_copy(_VSTD::forward<_Callable>(__func)),
__decay_copy(_VSTD::forward<_Args>(__args))...));
typedef tuple<_Callable&&, _Args&&...> _Gp;
_Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
__call_once_param<_Gp> __p(__f);
__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);
}
}
@@ -555,15 +554,27 @@ call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
template<class _Callable>
inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable __func)
call_once(once_flag& __flag, _Callable& __func)
{
if (__flag.__state_ != ~0ul)
if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
{
__call_once_param<_Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
}
}
template<class _Callable>
inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, const _Callable& __func)
{
if (__flag.__state_ != ~0ul)
{
__call_once_param<const _Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
}
}
#endif // _LIBCPP_HAS_NO_VARIADICS
_LIBCPP_END_NAMESPACE_STD

View File

@@ -52,16 +52,12 @@ void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // repla
void operator delete(void* ptr) noexcept; // replaceable
void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete(void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete(void* ptr, std::size_t size,
const std::nothrow_t&) noexcept; // replaceable, C++14
void* operator new[](std::size_t size); // replaceable
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
void operator delete[](void* ptr) noexcept; // replaceable
void operator delete[](void* ptr, std::size_t size) noexcept; // replaceable, C++14
void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // replaceable
void operator delete[](void* ptr, std::size_t size,
const std::nothrow_t&) noexcept; // replaceable, C++14
void* operator new (std::size_t size, void* ptr) noexcept;
void* operator new[](std::size_t size, void* ptr) noexcept;
@@ -140,9 +136,9 @@ _LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz)
_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
(defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
#endif
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
@@ -153,9 +149,9 @@ _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14
#if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14 || \
(defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309)
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
#endif
inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}

View File

@@ -1004,7 +1004,7 @@ basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
{
sentry __s(*this);
if (__s)
if (!this->fail())
{
if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
this->setstate(ios_base::failbit);
@@ -1018,7 +1018,7 @@ basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
{
sentry __s(*this);
if (__s)
if (!this->fail())
{
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
this->setstate(ios_base::failbit);

View File

@@ -3475,9 +3475,9 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
class _LIBCPP_TYPE_VIS random_device
{
#if !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
#ifdef _LIBCPP_USING_DEV_RANDOM
int __f_;
#endif // !(defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM))
#endif // defined(_LIBCPP_USING_DEV_RANDOM)
public:
// types
typedef unsigned result_type;
@@ -6044,9 +6044,6 @@ basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
discrete_distribution<_IT>& __x)
{
typedef discrete_distribution<_IT> _Eng;
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
__is.flags(ios_base::dec | ios_base::skipws);
size_t __n;
@@ -6358,7 +6355,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
{
typedef piecewise_constant_distribution<_RT> _Eng;
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
__is.flags(ios_base::dec | ios_base::skipws);
size_t __n;
@@ -6698,7 +6694,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
{
typedef piecewise_linear_distribution<_RT> _Eng;
typedef typename _Eng::result_type result_type;
typedef typename _Eng::param_type param_type;
__save_flags<_CharT, _Traits> __lx(__is);
__is.flags(ios_base::dec | ios_base::skipws);
size_t __n;

View File

@@ -21,8 +21,8 @@ template <intmax_t N, intmax_t D = 1>
class ratio
{
public:
static const intmax_t num;
static const intmax_t den;
static constexpr intmax_t num;
static constexpr intmax_t den;
typedef ratio<num, den> type;
};
@@ -236,19 +236,22 @@ class _LIBCPP_TYPE_VIS_ONLY ratio
static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
static_assert(_Den != 0, "ratio divide by 0");
static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");
static const intmax_t __na = __static_abs<_Num>::value;
static const intmax_t __da = __static_abs<_Den>::value;
static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
static const intmax_t __gcd = __static_gcd<__na, __da>::value;
static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value;
static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value;
static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value;
public:
static const intmax_t num = __s * __na / __gcd;
static const intmax_t den = __da / __gcd;
static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
typedef ratio<num, den> type;
};
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num;
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den;
template <intmax_t _Num, intmax_t _Den>
_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
template <intmax_t _Num, intmax_t _Den>
_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
template <class _Tp> struct __is_ratio : false_type {};
template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type {};
@@ -398,11 +401,11 @@ struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_equal
: public integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> {};
: public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal
: public integral_constant<bool, !ratio_equal<_R1, _R2>::value> {};
: public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {};
// ratio_less
@@ -461,19 +464,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL>
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_less
: public integral_constant<bool, __ratio_less<_R1, _R2>::value> {};
: public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal
: public integral_constant<bool, !ratio_less<_R2, _R1>::value> {};
: public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_greater
: public integral_constant<bool, ratio_less<_R2, _R1>::value> {};
: public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {};
template <class _R1, class _R2>
struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal
: public integral_constant<bool, !ratio_less<_R1, _R2>::value> {};
: public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {};
template <class _R1, class _R2>
struct __ratio_gcd

View File

@@ -955,6 +955,15 @@ public:
regex_constants::error_type code() const {return __code_;}
};
template <regex_constants::error_type _Ev>
_LIBCPP_ALWAYS_INLINE
void __throw_regex_error()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(_Ev);
#endif
}
template <class _CharT>
struct _LIBCPP_TYPE_VIS_ONLY regex_traits
{
@@ -1956,7 +1965,8 @@ template <class _CharT>
void
__l_anchor<_CharT>::__exec(__state& __s) const
{
if (__s.__at_first_ && __s.__current_ == __s.__first_)
if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
!(__s.__flags_ & regex_constants::match_not_bol))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -1990,7 +2000,8 @@ template <class _CharT>
void
__r_anchor<_CharT>::__exec(__state& __s) const
{
if (__s.__current_ == __s.__last_)
if (__s.__current_ == __s.__last_ &&
!(__s.__flags_ & regex_constants::match_not_eol))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -2263,10 +2274,8 @@ public:
}
else
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__b.size() != 1 || __e.size() != 1)
throw regex_error(regex_constants::error_collate);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_collate>();
if (__icase_)
{
__b[0] = __traits_.translate_nocase(__b[0]);
@@ -2959,7 +2968,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
__lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
: base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {}
: base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
virtual void __exec(__state&) const;
};
@@ -3019,10 +3028,8 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
case egrep:
__first = __parse_egrep(__first, __last);
break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default:
throw regex_error(regex_constants::__re_err_grammar);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::__re_err_grammar>();
}
return __first;
}
@@ -3053,10 +3060,8 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
}
}
}
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first != __last)
throw regex_error(regex_constants::__re_err_empty);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::__re_err_empty>();
}
return __first;
}
@@ -3069,19 +3074,15 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
{
__owns_one_state<_CharT>* __sa = __end_;
_ForwardIterator __temp = __parse_ERE_branch(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::__re_err_empty>();
__first = __temp;
while (__first != __last && *__first == '|')
{
__owns_one_state<_CharT>* __sb = __end_;
__temp = __parse_ERE_branch(++__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::__re_err_empty>();
__push_alternation(__sa, __sb);
__first = __temp;
}
@@ -3095,10 +3096,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
_ForwardIterator __last)
{
_ForwardIterator __temp = __parse_ERE_expression(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::__re_err_empty>();
do
{
__first = __temp;
@@ -3133,10 +3132,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
unsigned __temp_count = __marked_count_;
++__open_count_;
__temp = __parse_extended_reg_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
__push_end_marked_subexpression(__temp_count);
--__open_count_;
++__temp;
@@ -3201,10 +3198,8 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
unsigned __temp_count = __marked_count_;
__first = __parse_RE_expression(__temp, __last);
__temp = __parse_Back_close_paren(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
__push_end_marked_subexpression(__temp_count);
__first = __temp;
}
@@ -3518,22 +3513,16 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __min = 0;
__first = __temp;
__temp = __parse_DUP_COUNT(__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
__first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
if (*__first != ',')
{
__temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
true);
__first = __temp;
@@ -3544,18 +3533,14 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __max = -1;
__first = __parse_DUP_COUNT(__first, __last, __max);
__temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
if (__max == -1)
__push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
else
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min)
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
true);
}
@@ -3615,15 +3600,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{
int __min;
_ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
__first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
switch (*__first)
{
case '}':
@@ -3638,10 +3619,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
break;
case ',':
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
if (*__first == '}')
{
++__first;
@@ -3657,20 +3636,14 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{
int __max = -1;
__temp = __parse_DUP_COUNT(__first, __last, __max);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first)
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
__first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != '}')
throw regex_error(regex_constants::error_brace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brace>();
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min)
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
if (__grammar == ECMAScript && __first != __last && *__first == '?')
{
++__first;
@@ -3680,10 +3653,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
}
break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default:
throw regex_error(regex_constants::error_badbrace);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_badbrace>();
}
}
break;
@@ -3701,10 +3672,8 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
if (__first != __last && *__first == '[')
{
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
bool __negate = false;
if (*__first == '^')
{
@@ -3713,29 +3682,23 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
}
__bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
// __ml owned by *this
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
{
__ml->__add_char(']');
++__first;
}
__first = __parse_follow_list(__first, __last, __ml);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
if (*__first == '-')
{
__ml->__add_char('-');
++__first;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ']')
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
++__first;
}
return __first;
@@ -3855,10 +3818,8 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
basic_string<_CharT>& __str,
__bracket_expression<_CharT, _Traits>* __ml)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
switch (*__first)
{
case 0:
@@ -3899,10 +3860,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
_ForwardIterator __last,
basic_string<_CharT>* __str)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
switch (*__first)
{
case '\\':
@@ -3970,10 +3929,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
else
__push_char(_CharT(__val));
}
#ifndef _LIBCPP_NO_EXCEPTIONS
else
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
return __first;
}
@@ -3989,18 +3946,14 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
value_type _Equal_close[2] = {'=', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close,
_Equal_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
// [__first, __temp) contains all text in [= ... =]
typedef typename _Traits::string_type string_type;
string_type __collate_name =
__traits_.lookup_collatename(__first, __temp);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__collate_name.empty())
throw regex_error(regex_constants::error_collate);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_collate>();
string_type __equiv_name =
__traits_.transform_primary(__collate_name.begin(),
__collate_name.end());
@@ -4016,10 +3969,8 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
case 2:
__ml->__add_digraph(__collate_name[0], __collate_name[1]);
break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default:
throw regex_error(regex_constants::error_collate);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_collate>();
}
}
__first = _VSTD::next(__temp, 2);
@@ -4038,18 +3989,14 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
value_type _Colon_close[2] = {':', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close,
_Colon_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
// [__first, __temp) contains all text in [: ... :]
typedef typename _Traits::char_class_type char_class_type;
char_class_type __class_type =
__traits_.lookup_classname(__first, __temp, __flags_ & icase);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__class_type == 0)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
__ml->__add_class(__class_type);
__first = _VSTD::next(__temp, 2);
return __first;
@@ -4067,22 +4014,17 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
value_type _Dot_close[2] = {'.', ']'};
_ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close,
_Dot_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last)
throw regex_error(regex_constants::error_brack);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_brack>();
// [__first, __temp) contains all text in [. ... .]
typedef typename _Traits::string_type string_type;
__col_sym = __traits_.lookup_collatename(__first, __temp);
switch (__col_sym.size())
{
case 1:
case 2:
break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default:
throw regex_error(regex_constants::error_collate);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_collate>();
}
__first = _VSTD::next(__temp, 2);
return __first;
@@ -4226,10 +4168,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
unsigned __mexp = __exp.__marked_count_;
__push_lookahead(_VSTD::move(__exp), false, __marked_count_);
__marked_count_ += __mexp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
__first = ++__temp;
}
break;
@@ -4241,10 +4181,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
unsigned __mexp = __exp.__marked_count_;
__push_lookahead(_VSTD::move(__exp), true, __marked_count_);
__marked_count_ += __mexp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
__first = ++__temp;
}
break;
@@ -4281,19 +4219,15 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
case '(':
{
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
_ForwardIterator __temp = _VSTD::next(__first);
if (__temp != __last && *__first == '?' && *__temp == ':')
{
++__open_count_;
__first = __parse_ecma_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
--__open_count_;
++__first;
}
@@ -4303,16 +4237,20 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
unsigned __temp_count = __marked_count_;
++__open_count_;
__first = __parse_ecma_exp(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_paren>();
__push_end_marked_subexpression(__temp_count);
--__open_count_;
++__first;
}
}
break;
case '*':
case '+':
case '?':
case '{':
__throw_regex_error<regex_constants::error_badrepeat>();
break;
default:
__first = __parse_pattern_character(__first, __last);
break;
@@ -4367,10 +4305,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
unsigned __v = *__first - '0';
for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
__v = 10 * __v + *__first - '0';
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__v > mark_count())
throw regex_error(regex_constants::error_backref);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_backref>();
__push_back_ref(__v);
}
}
@@ -4486,62 +4422,42 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(_CharT(*__t % 32));
__first = ++__t;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
else
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
}
#ifndef _LIBCPP_NO_EXCEPTIONS
else
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
break;
case 'u':
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
// drop through
case 'x':
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1)
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
if (__str)
*__str = _CharT(__sum);
@@ -4565,10 +4481,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(*__first);
++__first;
}
#ifndef _LIBCPP_NO_EXCEPTIONS
else
throw regex_error(regex_constants::error_escape);
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_regex_error<regex_constants::error_escape>();
break;
}
}
@@ -5429,8 +5343,8 @@ match_results<_BidirectionalIterator, _Allocator>::match_results(
__unmatched_(),
__prefix_(),
__suffix_(),
__position_start_(),
__ready_(false)
__ready_(false),
__position_start_()
{
}
@@ -5655,9 +5569,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
__states.pop_back();
break;
default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown);
#endif
__throw_regex_error<regex_constants::__re_err_unknown>();
break;
}
@@ -5727,9 +5639,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
__states.pop_back();
break;
default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown);
#endif
__throw_regex_error<regex_constants::__re_err_unknown>();
break;
}
} while (!__states.empty());
@@ -5815,9 +5725,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
__states.pop_back();
break;
default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown);
#endif
__throw_regex_error<regex_constants::__re_err_unknown>();
break;
}
} while (!__states.empty());

View File

@@ -38,6 +38,7 @@ public:
typedef see below propagate_on_container_copy_assignment;
typedef see below propagate_on_container_move_assignment;
typedef see below propagate_on_container_swap;
typedef see below is_always_equal;
template <class Tp>
struct rebind
@@ -170,6 +171,22 @@ struct __get_poc_swap<_A0, _Allocs...>
__get_poc_swap<_Allocs...>::value;
};
template <class ..._Allocs> struct __get_is_always_equal;
template <class _A0>
struct __get_is_always_equal<_A0>
{
static const bool value = allocator_traits<_A0>::is_always_equal::value;
};
template <class _A0, class ..._Allocs>
struct __get_is_always_equal<_A0, _Allocs...>
{
static const bool value =
allocator_traits<_A0>::is_always_equal::value &&
__get_is_always_equal<_Allocs...>::value;
};
template <class ..._Allocs>
class __scoped_allocator_storage;
@@ -397,6 +414,11 @@ public:
bool,
__get_poc_swap<outer_allocator_type, _InnerAllocs...>::value
> propagate_on_container_swap;
typedef integral_constant
<
bool,
__get_is_always_equal<outer_allocator_type, _InnerAllocs...>::value
> is_always_equal;
template <class _Tp>
struct rebind

View File

@@ -116,6 +116,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -297,6 +298,7 @@ public:
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;

View File

@@ -19,6 +19,29 @@
namespace std
{
class shared_mutex // C++17
{
public:
shared_mutex();
~shared_mutex();
shared_mutex(const shared_mutex&) = delete;
shared_mutex& operator=(const shared_mutex&) = delete;
// Exclusive ownership
void lock(); // blocking
bool try_lock();
void unlock();
// Shared ownership
void lock_shared(); // blocking
bool try_lock_shared();
void unlock_shared();
typedef implementation-defined native_handle_type; // See 30.2.3
native_handle_type native_handle(); // See 30.2.3
};
class shared_timed_mutex
{
public:
@@ -118,7 +141,7 @@ template <class Mutex>
_LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS shared_timed_mutex
struct _LIBCPP_TYPE_VIS __shared_mutex_base
{
mutex __mut_;
condition_variable __gate1_;
@@ -127,6 +150,58 @@ class _LIBCPP_TYPE_VIS shared_timed_mutex
static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
static const unsigned __n_readers_ = ~__write_entered_;
__shared_mutex_base();
_LIBCPP_INLINE_VISIBILITY ~__shared_mutex_base() = default;
__shared_mutex_base(const __shared_mutex_base&) = delete;
__shared_mutex_base& operator=(const __shared_mutex_base&) = delete;
// Exclusive ownership
void lock(); // blocking
bool try_lock();
void unlock();
// Shared ownership
void lock_shared(); // blocking
bool try_lock_shared();
void unlock_shared();
// typedef implementation-defined native_handle_type; // See 30.2.3
// native_handle_type native_handle(); // See 30.2.3
};
#if _LIBCPP_STD_VER > 14
class _LIBCPP_TYPE_VIS shared_mutex
{
__shared_mutex_base __base;
public:
shared_mutex() : __base() {}
_LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default;
shared_mutex(const shared_mutex&) = delete;
shared_mutex& operator=(const shared_mutex&) = delete;
// Exclusive ownership
_LIBCPP_INLINE_VISIBILITY void lock() { return __base.lock(); }
_LIBCPP_INLINE_VISIBILITY bool try_lock() { return __base.try_lock(); }
_LIBCPP_INLINE_VISIBILITY void unlock() { return __base.unlock(); }
// Shared ownership
_LIBCPP_INLINE_VISIBILITY void lock_shared() { return __base.lock_shared(); }
_LIBCPP_INLINE_VISIBILITY bool try_lock_shared() { return __base.try_lock_shared(); }
_LIBCPP_INLINE_VISIBILITY void unlock_shared() { return __base.unlock_shared(); }
// typedef __shared_mutex_base::native_handle_type native_handle_type;
// _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() { return __base::unlock_shared(); }
};
#endif
class _LIBCPP_TYPE_VIS shared_timed_mutex
{
__shared_mutex_base __base;
public:
shared_timed_mutex();
_LIBCPP_INLINE_VISIBILITY ~shared_timed_mutex() = default;
@@ -170,29 +245,30 @@ bool
shared_timed_mutex::try_lock_until(
const chrono::time_point<_Clock, _Duration>& __abs_time)
{
unique_lock<mutex> __lk(__mut_);
if (__state_ & __write_entered_)
unique_lock<mutex> __lk(__base.__mut_);
if (__base.__state_ & __base.__write_entered_)
{
while (true)
{
cv_status __status = __gate1_.wait_until(__lk, __abs_time);
if ((__state_ & __write_entered_) == 0)
cv_status __status = __base.__gate1_.wait_until(__lk, __abs_time);
if ((__base.__state_ & __base.__write_entered_) == 0)
break;
if (__status == cv_status::timeout)
return false;
}
}
__state_ |= __write_entered_;
if (__state_ & __n_readers_)
__base.__state_ |= __base.__write_entered_;
if (__base.__state_ & __base.__n_readers_)
{
while (true)
{
cv_status __status = __gate2_.wait_until(__lk, __abs_time);
if ((__state_ & __n_readers_) == 0)
cv_status __status = __base.__gate2_.wait_until(__lk, __abs_time);
if ((__base.__state_ & __base.__n_readers_) == 0)
break;
if (__status == cv_status::timeout)
{
__state_ &= ~__write_entered_;
__base.__state_ &= ~__base.__write_entered_;
__base.__gate1_.notify_all();
return false;
}
}
@@ -205,22 +281,22 @@ bool
shared_timed_mutex::try_lock_shared_until(
const chrono::time_point<_Clock, _Duration>& __abs_time)
{
unique_lock<mutex> __lk(__mut_);
if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
unique_lock<mutex> __lk(__base.__mut_);
if ((__base.__state_ & __base.__write_entered_) || (__base.__state_ & __base.__n_readers_) == __base.__n_readers_)
{
while (true)
{
cv_status status = __gate1_.wait_until(__lk, __abs_time);
if ((__state_ & __write_entered_) == 0 &&
(__state_ & __n_readers_) < __n_readers_)
cv_status status = __base.__gate1_.wait_until(__lk, __abs_time);
if ((__base.__state_ & __base.__write_entered_) == 0 &&
(__base.__state_ & __base.__n_readers_) < __base.__n_readers_)
break;
if (status == cv_status::timeout)
return false;
}
}
unsigned __num_readers = (__state_ & __n_readers_) + 1;
__state_ &= ~__n_readers_;
__state_ |= __num_readers;
unsigned __num_readers = (__base.__state_ & __base.__n_readers_) + 1;
__base.__state_ &= ~__base.__n_readers_;
__base.__state_ |= __num_readers;
return true;
}

View File

@@ -220,8 +220,8 @@ public:
basic_string substr(size_type pos = 0, size_type n = npos) const;
void swap(basic_string& str)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
const value_type* c_str() const noexcept;
const value_type* data() const noexcept;
@@ -742,7 +742,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
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(0xDFFF);}
{return int_type(0xFFFF);}
};
inline _LIBCPP_INLINE_VISIBILITY
@@ -1322,13 +1322,26 @@ public:
_LIBCPP_INLINE_VISIBILITY basic_string()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
basic_string(const basic_string& __str);
basic_string(const basic_string& __str, const allocator_type& __a);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
basic_string(basic_string&& __str)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
_LIBCPP_INLINE_VISIBILITY
basic_string(basic_string&& __str, const allocator_type& __a);
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -1591,8 +1604,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
__is_nothrow_swappable<allocator_type>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
const value_type* c_str() const _NOEXCEPT {return data();}
@@ -1855,24 +1872,6 @@ private:
_NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type&, allocator_type&, false_type) _NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type);
@@ -1937,7 +1936,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string()
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a)
: __r_(__a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __r_(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
@@ -2070,7 +2074,11 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __r_(_VSTD::move(__str.__r_))
{
__str.__zero();
@@ -3349,8 +3357,12 @@ template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
__is_nothrow_swappable<allocator_type>::value)
#endif
{
#if _LIBCPP_DEBUG_LEVEL >= 2
if (!__is_long())
@@ -3360,7 +3372,7 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str)
__get_db()->swap(this, &__str);
#endif
_VSTD::swap(__r_.first(), __str.__r_.first());
__swap_alloc(__alloc(), __str.__alloc());
__swap_allocator(__alloc(), __str.__alloc());
}
// find

View File

@@ -161,10 +161,8 @@ using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
// __tuple_leaf
template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
#if __has_feature(is_final)
&& !__is_final(_Hp)
#endif
template <size_t _Ip, class _Hp,
bool=is_empty<_Hp>::value && !__libcpp_is_final<_Hp>::value
>
class __tuple_leaf;
@@ -846,8 +844,6 @@ struct __ignore_t
namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
template <class _Tp>
struct __make_tuple_return_impl
{

View File

@@ -19,8 +19,13 @@ namespace std
// helper class:
template <class T, T v> struct integral_constant;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
typedef integral_constant<bool, true> true_type; // C++11
typedef integral_constant<bool, false> false_type; // C++11
template <bool B> // C++14
using bool_constant = integral_constant<bool, B>; // C++14
typedef bool_constant<true> true_type; // C++14
typedef bool_constant<false> false_type; // C++14
// helper traits
template <bool, class T = void> struct enable_if;
@@ -211,10 +216,11 @@ namespace std
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class...>
template <class>
struct __void_t { typedef void type; };
#endif
template <class _Tp>
struct __identity { typedef _Tp type; };
template <class _Tp, bool>
struct _LIBCPP_TYPE_VIS_ONLY __dependent_type : public _Tp {};
@@ -260,8 +266,16 @@ struct _LIBCPP_TYPE_VIS_ONLY integral_constant
template <class _Tp, _Tp __v>
_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
#if _LIBCPP_STD_VER > 14
template <bool __b>
using bool_constant = integral_constant<bool, __b>;
#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)>
#else
#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)>
#endif
typedef _LIBCPP_BOOL_CONSTANT(true) true_type;
typedef _LIBCPP_BOOL_CONSTANT(false) false_type;
// is_const
@@ -460,25 +474,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function
// template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {};
//
template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr>
template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
struct __member_pointer_traits_imp
{ // forward declaration; specializations later
};
namespace __libcpp_is_member_function_pointer_imp {
template <typename _Tp>
char __test(typename std::__member_pointer_traits_imp<_Tp, true, false>::_FnType *);
template <typename>
std::__two __test(...);
};
template <class _Tp> struct __libcpp_is_member_function_pointer
: public integral_constant<bool, sizeof(__libcpp_is_member_function_pointer_imp::__test<_Tp>(nullptr)) == 1> {};
: public false_type {};
template <class _Ret, class _Class>
struct __libcpp_is_member_function_pointer<_Ret _Class::*>
: public is_function<_Ret> {};
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer
: public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type> {};
: public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {};
// is_member_pointer
@@ -679,7 +689,7 @@ template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type;
// is_signed
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_signed_impl : public integral_constant<bool, _Tp(-1) < _Tp(0)> {};
struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {};
template <class _Tp>
struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
@@ -694,7 +704,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is
// is_unsigned
template <class _Tp, bool = is_integral<_Tp>::value>
struct __libcpp_is_unsigned_impl : public integral_constant<bool, _Tp(0) < _Tp(-1)> {};
struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {};
template <class _Tp>
struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point
@@ -796,7 +806,15 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_
// is_final
#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
#if defined(_LIBCPP_HAS_IS_FINAL)
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
__libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};
#else
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
__libcpp_is_final : public false_type {};
#endif
#if defined(_LIBCPP_HAS_IS_FINAL) && _LIBCPP_STD_VER > 11
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
is_final : public integral_constant<bool, __is_final(_Tp)> {};
#endif
@@ -838,7 +856,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of
// is_convertible
#if __has_feature(is_convertible_to)
#if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK)
template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
: public integral_constant<bool, __is_convertible_to(_T1, _T2) &&
@@ -848,7 +866,16 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible
namespace __is_convertible_imp
{
template <class _Tp> char __test(_Tp);
template <class _Tp> void __test_convert(_Tp);
template <class _From, class _To, class = void>
struct __is_convertible_test : public false_type {};
template <class _From, class _To>
struct __is_convertible_test<_From, _To,
decltype(__test_convert<_To>(_VSTD::declval<_From>()))> : public true_type
{};
template <class _Tp> __two __test(...);
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _Tp> _Tp&& __source();
@@ -883,10 +910,8 @@ template <class _T1, class _T2,
unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value>
struct __is_convertible
: public integral_constant<bool,
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
#else
sizeof(__is_convertible_imp::__test<_T2>(__is_convertible_imp::__source<_T1>())) == 1
__is_convertible_imp::__is_convertible_test<_T1, _T2>::value
#if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
&& !(!is_function<_T1>::value && !is_reference<_T1>::value && is_reference<_T2>::value
&& (!is_const<typename remove_reference<_T2>::type>::value
|| is_volatile<typename remove_reference<_T2>::type>::value)
@@ -900,6 +925,7 @@ struct __is_convertible
template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 0> : false_type {};
template <class _T1> struct __is_convertible<_T1, const _T1&, 1, 0> : true_type {};
template <class _T1> struct __is_convertible<const _T1, const _T1&, 1, 0> : true_type {};
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class _T1> struct __is_convertible<_T1, _T1&&, 1, 0> : true_type {};
template <class _T1> struct __is_convertible<_T1, const _T1&&, 1, 0> : true_type {};
@@ -1525,7 +1551,7 @@ template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::va
struct __is_assignable_imp
: public common_type
<
decltype(__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
decltype(_VSTD::__is_assignable_test(declval<_Tp>(), declval<_Arg>()))
>::type {};
template <class _Tp, class _Arg>
@@ -1772,7 +1798,8 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
typedef _Rp (_FnType) (_Param..., ...);
};
#if __has_feature(cxx_reference_qualified_functions)
#if __has_feature(cxx_reference_qualified_functions) || \
(defined(_GNUC_VER) && _GNUC_VER >= 409)
template <class _Rp, class _Class, class ..._Param>
struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false>
@@ -1902,7 +1929,7 @@ struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatil
typedef _Rp (_FnType) (_Param..., ...);
};
#endif // __has_feature(cxx_reference_qualified_functions)
#endif // __has_feature(cxx_reference_qualified_functions) || _GNUC_VER >= 409
#else // _LIBCPP_HAS_NO_VARIADICS
@@ -2228,7 +2255,7 @@ struct __result_of_mp;
template <class _MP, class _Tp>
struct __result_of_mp<_MP, _Tp, true>
: public common_type<typename __member_pointer_traits<_MP>::_ReturnType>
: public __identity<typename __member_pointer_traits<_MP>::_ReturnType>
{
};
@@ -2296,7 +2323,7 @@ template <class _Fn>
class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()>
: public __result_of<_Fn(),
is_class<typename remove_reference<_Fn>::type>::value ||
is_function<typename remove_reference<_Fn>::type>::value,
is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
is_member_pointer<typename remove_reference<_Fn>::type>::value
>
{
@@ -2306,7 +2333,7 @@ template <class _Fn, class _A0>
class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)>
: public __result_of<_Fn(_A0),
is_class<typename remove_reference<_Fn>::type>::value ||
is_function<typename remove_reference<_Fn>::type>::value,
is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
is_member_pointer<typename remove_reference<_Fn>::type>::value
>
{
@@ -2316,7 +2343,7 @@ template <class _Fn, class _A0, class _A1>
class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)>
: public __result_of<_Fn(_A0, _A1),
is_class<typename remove_reference<_Fn>::type>::value ||
is_function<typename remove_reference<_Fn>::type>::value,
is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
is_member_pointer<typename remove_reference<_Fn>::type>::value
>
{
@@ -2326,7 +2353,7 @@ template <class _Fn, class _A0, class _A1, class _A2>
class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)>
: public __result_of<_Fn(_A0, _A1, _A2),
is_class<typename remove_reference<_Fn>::type>::value ||
is_function<typename remove_reference<_Fn>::type>::value,
is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value,
is_member_pointer<typename remove_reference<_Fn>::type>::value
>
{
@@ -2674,7 +2701,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible
#ifndef _LIBCPP_HAS_NO_VARIADICS
#if __has_feature(is_trivially_constructible)
#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
template <class _Tp, class... _Args>
struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
@@ -2733,7 +2760,7 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible
{
};
#if __has_feature(is_trivially_constructible)
#if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat,
@@ -2821,7 +2848,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl
// is_trivially_assignable
#if __has_feature(is_trivially_assignable)
#if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501
template <class _Tp, class _Arg>
struct is_trivially_assignable
@@ -2890,6 +2917,9 @@ template <class _Tp> struct __libcpp_trivial_destructor
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible
: public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {};
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]>
: public false_type {};
#endif
// is_nothrow_constructible
@@ -3214,6 +3244,10 @@ template <class _Tp> struct __libcpp_nothrow_destructor
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible
: public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {};
template <class _Tp>
struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]>
: public false_type {};
#endif
// is_pod
@@ -3259,6 +3293,8 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
#if __has_feature(is_trivially_copyable)
: public integral_constant<bool, __is_trivially_copyable(_Tp)>
#elif _GNUC_VER >= 501
: public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)>
#else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value>
#endif
@@ -3267,7 +3303,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable
// is_trivial;
template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial
#if __has_feature(is_trivial) || (_GNUC_VER >= 407)
#if __has_feature(is_trivial) || _GNUC_VER >= 407
: public integral_constant<bool, __is_trivial(_Tp)>
#else
: integral_constant<bool, is_trivially_copyable<_Tp>::value &&

View File

@@ -122,7 +122,25 @@ public:
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
template <class... Args>
pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
template <class... Args>
pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
template <class... Args>
iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
template <class... Args>
iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
template <class M>
pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
template <class M>
pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
template <class M>
iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
template <class M>
iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -287,6 +305,7 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
@@ -359,10 +378,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
#if __has_feature(is_final)
&& !__is_final(_Hash)
#endif
template <class _Key, class _Cp, class _Hash,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
>
class __unordered_map_hasher
: private _Hash
@@ -384,6 +401,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Key& __x) const
{return static_cast<const _Hash&>(*this)(__x);}
void swap(__unordered_map_hasher&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
{
using _VSTD::swap;
swap(static_cast<const _Hash&>(*this), static_cast<const _Hash&>(__y));
}
};
template <class _Key, class _Cp, class _Hash>
@@ -408,12 +431,26 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const _Key& __x) const
{return __hash_(__x);}
void swap(__unordered_map_hasher&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Hash>::value)
{
using _VSTD::swap;
swap(__hash_, __y.__hash_);
}
};
template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
#if __has_feature(is_final)
&& !__is_final(_Pred)
#endif
template <class _Key, class _Cp, class _Hash, bool __b>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
template <class _Key, class _Cp, class _Pred,
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
>
class __unordered_map_equal
: private _Pred
@@ -438,6 +475,12 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _Cp& __y) const
{return static_cast<const _Pred&>(*this)(__x, __y.__cc.first);}
void swap(__unordered_map_equal&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
{
using _VSTD::swap;
swap(static_cast<const _Pred&>(*this), static_cast<const _Pred&>(__y));
}
};
template <class _Key, class _Cp, class _Pred>
@@ -465,8 +508,24 @@ public:
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _Key& __x, const _Cp& __y) const
{return __pred_(__x, __y.__cc.first);}
void swap(__unordered_map_equal&__y)
_NOEXCEPT_(__is_nothrow_swappable<_Pred>::value)
{
using _VSTD::swap;
swap(__pred_, __y.__pred_);
}
};
template <class _Key, class _Cp, class _Pred, bool __b>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(__unordered_map_equal<_Key, _Cp, _Pred, __b>& __x,
__unordered_map_equal<_Key, _Cp, _Pred, __b>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y)))
{
__x.swap(__y);
}
template <class _Alloc>
class __hash_map_node_destructor
{
@@ -551,7 +610,7 @@ union __hash_value_type
_LIBCPP_INLINE_VISIBILITY
__hash_value_type(__hash_value_type&& __v)
: __nc(std::move(__v.__nc)) {}
: __nc(_VSTD::move(__v.__nc)) {}
_LIBCPP_INLINE_VISIBILITY
__hash_value_type& operator=(const __hash_value_type& __v)
@@ -559,7 +618,7 @@ union __hash_value_type
_LIBCPP_INLINE_VISIBILITY
__hash_value_type& operator=(__hash_value_type&& __v)
{__nc = std::move(__v.__nc); return *this;}
{__nc = _VSTD::move(__v.__nc); return *this;}
_LIBCPP_INLINE_VISIBILITY
~__hash_value_type() {__cc.~value_type();}
@@ -730,13 +789,8 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -946,9 +1000,125 @@ public:
{insert(__il.begin(), __il.end());}
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
#if _LIBCPP_STD_VER > 14
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return _VSTD::make_pair(__p, false);
else
return _VSTD::make_pair(
emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
true);
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return _VSTD::make_pair(__p, false);
else
return _VSTD::make_pair(
emplace_hint(__p,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)),
true);
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return __p;
else
return emplace_hint(__h,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(__k),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class... _Args>
_LIBCPP_INLINE_VISIBILITY
iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args)
{
iterator __p = __table_.find(__k);
if ( __p != end())
return __p;
else
return emplace_hint(__h,
_VSTD::piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__k)),
_VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...));
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return _VSTD::make_pair(__p, false);
}
return _VSTD::make_pair(emplace_hint(__p, __k, _VSTD::forward<_Vp>(__v)), true);
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return _VSTD::make_pair(__p, false);
}
return _VSTD::make_pair(emplace_hint(__p, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v)), true);
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return __p;
}
return emplace_hint(__h, __k, _VSTD::forward<_Vp>(__v));
}
template <class _Vp>
_LIBCPP_INLINE_VISIBILITY
iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v)
{
iterator __p = __table_.find(__k);
if ( __p != end())
{
__p->second = _VSTD::move(__v);
return __p;
}
return emplace_hint(__h, _VSTD::forward<key_type>(__k), _VSTD::forward<_Vp>(__v));
}
#endif
#endif
#endif
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __first, const_iterator __last)
@@ -1469,13 +1639,8 @@ private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher;
typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>,
__value_type>::type __allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
@@ -1654,6 +1819,8 @@ public:
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(iterator __p) {return __table_.erase(__p.__i_);}
_LIBCPP_INLINE_VISIBILITY
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
iterator erase(const_iterator __first, const_iterator __last)

View File

@@ -114,16 +114,15 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(unordered_set&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
hasher hash_function() const;
key_equal key_eq() const;
@@ -263,16 +262,15 @@ public:
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
iterator erase(iterator position); // C++14
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear() noexcept;
void swap(unordered_multiset&)
noexcept(
(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value) &&
__is_nothrow_swappable<hasher>::value &&
__is_nothrow_swappable<key_equal>::value);
noexcept(allocator_traits<Allocator>::is_always_equal::value &&
noexcept(swap(declval<hasher&>(), declval<hasher&>())) &&
noexcept(swap(declval<key_equal&>(), declval<key_equal&>()))); // C++17
hasher hash_function() const;
key_equal key_eq() const;

View File

@@ -512,10 +512,6 @@ template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_size<const pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> >
{
@@ -530,20 +526,6 @@ public:
typedef _T2 type;
};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> >
{
public:
typedef const _T1 type;
};
template <class _T1, class _T2>
class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> >
{
public:
typedef const _T2 type;
};
template <size_t _Ip> struct __get_pair;
template <>

View File

@@ -119,8 +119,8 @@ public:
void resize(size_type sz, const value_type& c);
void swap(vector&)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
bool __invariants() const;
};
@@ -237,8 +237,8 @@ public:
void resize(size_type sz, value_type x);
void swap(vector&)
noexcept(!allocator_type::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value); // C++17
void flip() noexcept;
bool __invariants() const;
@@ -385,14 +385,6 @@ protected:
is_nothrow_move_assignable<allocator_type>::value)
{__move_assign_alloc(__c, integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y)
_NOEXCEPT_(
!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());}
private:
_LIBCPP_INLINE_VISIBILITY
void __copy_assign_alloc(const __vector_base& __c, true_type)
@@ -421,18 +413,6 @@ private:
void __move_assign_alloc(__vector_base&, false_type)
_NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type& __x, allocator_type& __y, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(allocator_type&, allocator_type&, false_type)
_NOEXCEPT
{}
};
template <class _Tp, class _Allocator>
@@ -500,14 +480,18 @@ public:
"Allocator::value_type must be same type as value_type");
_LIBCPP_INLINE_VISIBILITY
vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->__insert_c(this);
#endif
}
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __base(__a)
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -569,7 +553,11 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __x, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
@@ -756,8 +744,12 @@ public:
void resize(size_type __sz, const_reference __x);
void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
__is_nothrow_swappable<allocator_type>::value);
#endif
bool __invariants() const;
@@ -783,7 +775,7 @@ private:
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
void __append(size_type __n);
void __append(size_type __n, const_reference __x);
_LIBCPP_INLINE_VISIBILITY
@@ -868,17 +860,17 @@ private:
// but if an exception is thrown after that the annotation has to be undone.
struct __RAII_IncreaseAnnotator {
__RAII_IncreaseAnnotator(const vector &__v, size_type __n = 1)
: __commit(false), __v(__v), __n(__n) {
: __commit(false), __v(__v), __old_size(__v.size() + __n) {
__v.__annotate_increase(__n);
}
void __done() { __commit = true; }
~__RAII_IncreaseAnnotator() {
if (__commit) return;
__v.__annotate_shrink(__v.size() + __n);
__v.__annotate_shrink(__old_size);
}
bool __commit;
size_type __n;
const vector &__v;
size_type __old_size;
};
#else
struct __RAII_IncreaseAnnotator {
@@ -1021,16 +1013,12 @@ typename enable_if
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
{
allocator_type& __a = this->__alloc();
for (; __first != __last; ++__first)
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first);
__annotator.__done();
++this->__end_;
}
__RAII_IncreaseAnnotator __annotator(*this, __n);
__alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_);
__annotator.__done();
}
// Default constructs __n objects starting at __end_
@@ -1177,7 +1165,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
if (__n > 0)
{
allocate(__n);
__construct_at_end(__first, __last);
__construct_at_end(__first, __last, __n);
}
}
@@ -1197,7 +1185,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
if (__n > 0)
{
allocate(__n);
__construct_at_end(__first, __last);
__construct_at_end(__first, __last, __n);
}
}
@@ -1212,7 +1200,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
if (__n > 0)
{
allocate(__n);
__construct_at_end(__x.__begin_, __x.__end_);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
@@ -1227,7 +1215,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
if (__n > 0)
{
allocate(__n);
__construct_at_end(__x.__begin_, __x.__end_);
__construct_at_end(__x.__begin_, __x.__end_, __n);
}
}
@@ -1236,7 +1224,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a)
template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<_Tp, _Allocator>::vector(vector&& __x)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
: __base(_VSTD::move(__x.__alloc()))
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1286,7 +1278,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
if (__il.size() > 0)
{
allocate(__il.size());
__construct_at_end(__il.begin(), __il.end());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
@@ -1301,7 +1293,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
if (__il.size() > 0)
{
allocate(__il.size());
__construct_at_end(__il.begin(), __il.end());
__construct_at_end(__il.begin(), __il.end(), __il.size());
}
}
@@ -1394,12 +1386,12 @@ typename enable_if
>::type
vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last)
{
typename iterator_traits<_ForwardIterator>::difference_type __new_size = _VSTD::distance(__first, __last);
if (static_cast<size_type>(__new_size) <= capacity())
size_type __new_size = static_cast<size_type>(_VSTD::distance(__first, __last));
if (__new_size <= capacity())
{
_ForwardIterator __mid = __last;
bool __growing = false;
if (static_cast<size_type>(__new_size) > size())
if (__new_size > size())
{
__growing = true;
__mid = __first;
@@ -1407,15 +1399,15 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
}
pointer __m = _VSTD::copy(__first, __mid, this->__begin_);
if (__growing)
__construct_at_end(__mid, __last);
__construct_at_end(__mid, __last, __new_size - size());
else
this->__destruct_at_end(__m);
}
else
{
deallocate();
allocate(__recommend(static_cast<size_type>(__new_size)));
__construct_at_end(__first, __last);
allocate(__recommend(__new_size));
__construct_at_end(__first, __last, __new_size);
}
}
@@ -1905,9 +1897,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
pointer __old_last = this->__end_;
for (; this->__end_ != this->__end_cap() && __first != __last; ++__first)
{
__RAII_IncreaseAnnotator __annotator(*this);
__alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_),
*__first);
++this->__end_;
__annotator.__done();
}
__split_buffer<value_type, allocator_type&> __v(__a);
if (__first != __last)
@@ -1967,8 +1961,9 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
if (__n > __dx)
{
__m = __first;
_VSTD::advance(__m, this->__end_ - __p);
__construct_at_end(__m, __last);
difference_type __diff = this->__end_ - __p;
_VSTD::advance(__m, __diff);
__construct_at_end(__m, __last, __n - __diff);
__n = __dx;
}
if (__n > 0)
@@ -2015,8 +2010,12 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
template <class _Tp, class _Allocator>
void
vector<_Tp, _Allocator>::swap(vector& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
_LIBCPP_ASSERT(__alloc_traits::propagate_on_container_swap::value ||
this->__alloc() == __x.__alloc(),
@@ -2025,7 +2024,8 @@ vector<_Tp, _Allocator>::swap(vector& __x)
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__end_, __x.__end_);
_VSTD::swap(this->__end_cap(), __x.__end_cap());
__base::__swap_alloc(this->__alloc(), __x.__alloc());
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>());
#if _LIBCPP_DEBUG_LEVEL >= 2
__get_db()->swap(this, &__x);
#endif // _LIBCPP_DEBUG_LEVEL >= 2
@@ -2128,13 +2128,7 @@ public:
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
private:
typedef typename __alloc_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__storage_type>
#else
rebind_alloc<__storage_type>::other
#endif
__storage_allocator;
typedef typename __rebind_alloc_helper<__alloc_traits, __storage_type>::type __storage_allocator;
typedef allocator_traits<__storage_allocator> __storage_traits;
typedef typename __storage_traits::pointer __storage_pointer;
typedef typename __storage_traits::const_pointer __const_storage_pointer;
@@ -2170,9 +2164,14 @@ private:
public:
_LIBCPP_INLINE_VISIBILITY
vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a);
vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
_LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
#else
_NOEXCEPT;
#endif
~vector();
explicit vector(size_type __n);
#if _LIBCPP_STD_VER > 11
@@ -2206,7 +2205,11 @@ public:
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
_LIBCPP_INLINE_VISIBILITY
vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT;
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
#endif
vector(vector&& __v, const allocator_type& __a);
_LIBCPP_INLINE_VISIBILITY
vector& operator=(vector&& __v)
@@ -2354,8 +2357,12 @@ public:
void clear() _NOEXCEPT {__size_ = 0;}
void swap(vector&)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
__is_nothrow_swappable<allocator_type>::value);
#endif
void resize(size_type __sz, value_type __x = false);
void flip() _NOEXCEPT;
@@ -2433,26 +2440,6 @@ private:
_NOEXCEPT
{}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y)
_NOEXCEPT_(
!__storage_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
{__swap_alloc(__x, __y, integral_constant<bool,
__storage_traits::propagate_on_container_swap::value>());}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__storage_allocator& __x, __storage_allocator& __y, true_type)
_NOEXCEPT_(__is_nothrow_swappable<allocator_type>::value)
{
using _VSTD::swap;
swap(__x, __y);
}
_LIBCPP_INLINE_VISIBILITY
static void __swap_alloc(__storage_allocator&, __storage_allocator&, false_type)
_NOEXCEPT
{}
size_t __hash_code() const _NOEXCEPT;
friend class __bit_reference<vector>;
@@ -2559,7 +2546,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector()
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
_NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0)
@@ -2569,6 +2556,11 @@ vector<bool, _Allocator>::vector()
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector(const allocator_type& __a)
#if _LIBCPP_STD_VER <= 14
_NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
#else
_NOEXCEPT
#endif
: __begin_(nullptr),
__size_(0),
__cap_alloc_(0, static_cast<__storage_allocator>(__a))
@@ -2807,7 +2799,11 @@ vector<bool, _Allocator>::operator=(const vector& __v)
template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
vector<bool, _Allocator>::vector(vector&& __v)
#if _LIBCPP_STD_VER > 14
_NOEXCEPT
#else
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
#endif
: __begin_(__v.__begin_),
__size_(__v.__size_),
__cap_alloc_(__v.__cap_alloc_)
@@ -3150,13 +3146,18 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
template <class _Allocator>
void
vector<bool, _Allocator>::swap(vector& __x)
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
_VSTD::swap(this->__begin_, __x.__begin_);
_VSTD::swap(this->__size_, __x.__size_);
_VSTD::swap(this->__cap(), __x.__cap());
__swap_alloc(this->__alloc(), __x.__alloc());
__swap_allocator(this->__alloc(), __x.__alloc(),
integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
}
template <class _Allocator>

View File

@@ -1,3 +1,5 @@
set(LIBCXX_LIB_CMAKEFILES_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}" PARENT_SCOPE)
# Get sources
file(GLOB LIBCXX_SOURCES ../src/*.cpp)
if(WIN32)
@@ -23,58 +25,70 @@ if (MSVC_IDE OR XCODE)
endif()
if (LIBCXX_ENABLE_SHARED)
add_library(cxx SHARED
${LIBCXX_SOURCES}
${LIBCXX_HEADERS}
)
add_library(cxx SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
else()
add_library(cxx STATIC
${LIBCXX_SOURCES}
${LIBCXX_HEADERS}
)
endif()
#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH)
target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
add_library(cxx STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
endif()
if (DEFINED LIBCXX_CXX_ABI_DEPS)
add_dependencies(cxx LIBCXX_CXX_ABI_DEPS)
endif()
set(libraries "")
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
# TODO(ericwf): Remove these GNU specific linker flags and let CMake do the
# configuration. This will be more portable.
list(APPEND libraries "-Wl,--whole-archive" "-Wl,-Bstatic")
list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
list(APPEND libraries "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
else()
list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}")
#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path.
add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
if (APPLE AND LLVM_USE_SANITIZER)
if ("${LLVM_USE_SANITIZER}" STREQUAL "Address")
set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
else()
message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X")
endif()
if (LIBFILE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result)
if (NOT ${Result} EQUAL "0")
message(FATAL "Failed to find library resource directory")
endif()
string(STRIP "${LIBDIR}" LIBDIR)
set(LIBDIR "${LIBDIR}/darwin/")
if (NOT IS_DIRECTORY "${LIBDIR}")
message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER")
endif()
set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}")
set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE)
message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}")
add_library_flags("${LIBCXX_SANITIZER_LIBRARY}")
add_link_flags("-Wl,-rpath,${LIBDIR}")
endif()
endif()
# Generate library list.
append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
append_if(libraries LIBCXX_HAS_C_LIB c)
append_if(libraries LIBCXX_HAS_M_LIB m)
append_if(libraries LIBCXX_HAS_RT_LIB rt)
append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
target_link_libraries(cxx ${libraries})
add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
add_library_flags_if(LIBCXX_HAS_C_LIB c)
add_library_flags_if(LIBCXX_HAS_M_LIB m)
add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
# Setup flags.
append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC)
append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
add_flags_if_supported(-fPIC)
add_link_flags_if_supported(-nodefaultlibs)
if ( APPLE )
if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
set(LIBCXX_LIBCPPABI_VERSION "2")
endif()
if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" )
list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__")
list(APPEND LIBCXX_LINK_FLAGS
add_definitions(-D__STRICT_ANSI__)
add_link_flags(
"-compatibility_version 1"
"-current_version 1"
"-install_name /usr/lib/libc++.1.dylib"
@@ -96,7 +110,7 @@ if ( APPLE )
set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
endif()
list(APPEND LIBCXX_LINK_FLAGS
add_link_flags(
"-compatibility_version 1"
"-install_name /usr/lib/libc++.1.dylib"
"-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp"
@@ -106,8 +120,9 @@ if ( APPLE )
endif()
endif()
string(REPLACE ";" " " LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}")
string(REPLACE ";" " " LIBCXX_LINK_FLAGS "${LIBCXX_LINK_FLAGS}")
target_link_libraries(cxx ${LIBCXX_LIBRARIES})
split_list(LIBCXX_COMPILE_FLAGS)
split_list(LIBCXX_LINK_FLAGS)
set_target_properties(cxx
PROPERTIES

View File

@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#include "algorithm"
#include "random"
#include "mutex"

22
src/any.cpp Normal file
View File

@@ -0,0 +1,22 @@
//===---------------------------- any.cpp ---------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "experimental/any"
_LIBCPP_BEGIN_NAMESPACE_LFTS
// TODO(EricWF) Enable or delete these
//bad_any_cast::bad_any_cast() _NOEXCEPT {}
//bad_any_cast::~bad_any_cast() _NOEXCEPT {}
const char* bad_any_cast::what() const _NOEXCEPT {
return "bad any cast";
}
_LIBCPP_END_NAMESPACE_LFTS

View File

@@ -8,14 +8,21 @@
//===----------------------------------------------------------------------===//
#include "chrono"
#include <sys/time.h> //for gettimeofday and timeval
#ifdef __APPLE__
#include "cerrno" // errno
#include "system_error" // __throw_system_error
#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
#if !defined(CLOCK_REALTIME)
#include <sys/time.h> // for gettimeofday and timeval
#endif
#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(CLOCK_MONOTONIC)
#if __APPLE__
#include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
#else /* !__APPLE__ */
#include <cerrno> // errno
#include <system_error> // __throw_system_error
#include <time.h> // clock_gettime, CLOCK_MONOTONIC
#endif // __APPLE__
#else
#error "Monotonic clock not implemented"
#endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -29,9 +36,16 @@ const bool system_clock::is_steady;
system_clock::time_point
system_clock::now() _NOEXCEPT
{
#ifdef CLOCK_REALTIME
struct timespec tp;
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
#else // !CLOCK_REALTIME
timeval tv;
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
#endif // CLOCK_REALTIME
}
time_t
@@ -48,10 +62,26 @@ system_clock::from_time_t(time_t t) _NOEXCEPT
#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
// steady_clock
//
// Warning: If this is not truly steady, then it is non-conforming. It is
// better for it to not exist and have the rest of libc++ use system_clock
// instead.
const bool steady_clock::is_steady;
#ifdef __APPLE__
#ifdef CLOCK_MONOTONIC
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
#elif defined(__APPLE__)
// mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
// nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom
// are run time constants supplied by the OS. This clock has no relationship
@@ -108,23 +138,9 @@ steady_clock::now() _NOEXCEPT
return time_point(duration(fp()));
}
#else // __APPLE__
// FIXME: if _LIBCPP_HAS_NO_MONOTONIC_CLOCK, then clock_gettime isn't going to
// work. It may be possible to fall back on something else, depending on the system.
// Warning: If this is not truly steady, then it is non-conforming. It is
// better for it to not exist and have the rest of libc++ use system_clock
// instead.
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
#endif // __APPLE__
#else
#error "Monotonic clock not implemented"
#endif
#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK

View File

@@ -214,10 +214,10 @@ __libcpp_db::__erase_i(void* __i)
else
q->__next_ = p->__next_;
__c_node* c = p->__c_;
free(p);
--__isz_;
if (c != nullptr)
c->__remove(p);
free(p);
}
}
}

View File

@@ -29,7 +29,7 @@
#define __terminate_handler __cxxabiapple::__cxa_terminate_handler
#define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler
#endif // _LIBCPPABI_VERSION
#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include(<cxxabi.h>)
#include <cxxabi.h>
using namespace __cxxabiv1;
#if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION)
@@ -90,14 +90,14 @@ terminate() _NOEXCEPT
#endif // _LIBCPP_NO_EXCEPTIONS
(*get_terminate())();
// handler should not return
printf("terminate_handler unexpectedly returned\n");
fprintf(stderr, "terminate_handler unexpectedly returned\n");
::abort();
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
// handler should not throw exception
printf("terminate_handler unexpectedly threw an exception\n");
fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
::abort();
}
#endif // _LIBCPP_NO_EXCEPTIONS
@@ -106,18 +106,24 @@ terminate() _NOEXCEPT
#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
bool uncaught_exception() _NOEXCEPT
bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
int uncaught_exceptions() _NOEXCEPT
{
#if defined(__APPLE__) || defined(_LIBCPPABI_VERSION)
// on Darwin, there is a helper function so __cxa_get_globals is private
return __cxa_uncaught_exception();
// on Darwin, there is a helper function so __cxa_get_globals is private
# if _LIBCPPABI_VERSION > 1101
return __cxa_uncaught_exceptions();
# else
return __cxa_uncaught_exception() ? 1 : 0;
# endif
#else // __APPLE__
# if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("uncaught_exception not yet implemented")
_LIBCPP_WARNING("uncaught_exceptions not yet implemented")
# else
# warning uncaught_exception not yet implemented
# endif
printf("uncaught_exception not yet implemented\n");
fprintf(stderr, "uncaught_exceptions not yet implemented\n");
::abort();
#endif // __APPLE__
}
@@ -190,7 +196,7 @@ exception_ptr::~exception_ptr() _NOEXCEPT
# else
# warning exception_ptr not yet implemented
# endif
printf("exception_ptr not yet implemented\n");
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#endif
}
@@ -209,7 +215,7 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
# else
# warning exception_ptr not yet implemented
# endif
printf("exception_ptr not yet implemented\n");
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#endif
}
@@ -234,7 +240,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
# else
# warning exception_ptr not yet implemented
# endif
printf("exception_ptr not yet implemented\n");
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#endif
}
@@ -278,7 +284,7 @@ exception_ptr current_exception() _NOEXCEPT
# else
# warning exception_ptr not yet implemented
# endif
printf("exception_ptr not yet implemented\n");
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#endif
}
@@ -300,7 +306,7 @@ void rethrow_exception(exception_ptr p)
# else
# warning exception_ptr not yet implemented
# endif
printf("exception_ptr not yet implemented\n");
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#endif
}

View File

@@ -98,7 +98,6 @@ __assoc_sub_state::set_value()
#endif
__state_ |= __constructed | ready;
__cv_.notify_all();
__lk.unlock();
}
void
@@ -111,7 +110,6 @@ __assoc_sub_state::set_value_at_thread_exit()
#endif
__state_ |= __constructed;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
}
void
@@ -124,7 +122,6 @@ __assoc_sub_state::set_exception(exception_ptr __p)
#endif
__exception_ = __p;
__state_ |= ready;
__lk.unlock();
__cv_.notify_all();
}
@@ -138,7 +135,6 @@ __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
#endif
__exception_ = __p;
__thread_local_data()->__make_ready_at_thread_exit(this);
__lk.unlock();
}
void
@@ -146,7 +142,6 @@ __assoc_sub_state::__make_ready()
{
unique_lock<mutex> __lk(__mut_);
__state_ |= ready;
__lk.unlock();
__cv_.notify_all();
}

View File

@@ -13,55 +13,75 @@
_LIBCPP_BEGIN_NAMESPACE_STD
static mbstate_t state_types[6] = {};
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wchar_t>)];
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
#ifndef _LIBCPP_HAS_NO_STDIN
_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)];
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)];
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)];
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
static mbstate_t mb_cin;
_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)];
_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wchar_t>)];
static mbstate_t mb_wcin;
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
static mbstate_t mb_cout;
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)];
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
static mbstate_t mb_wcout;
#endif
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)];
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
static mbstate_t mb_cerr;
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)];
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
static mbstate_t mb_wcerr;
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)];
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)];
ios_base::Init __start_std_streams;
ios_base::Init::Init()
{
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, state_types+0) );
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, state_types+1));
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, state_types+2));
#ifndef _LIBCPP_HAS_NO_STDIN
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin));
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin));
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
#endif
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
::new(clog) ostream(cerr_ptr->rdbuf());
cin_ptr->tie(cout_ptr);
_VSTD::unitbuf(*cerr_ptr);
cerr_ptr->tie(cout_ptr);
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, state_types+3) );
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, state_types+4));
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, state_types+5));
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
::new(wclog) wostream(wcerr_ptr->rdbuf());
#if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT)
cin_ptr->tie(cout_ptr);
wcin_ptr->tie(wcout_ptr);
#endif
_VSTD::unitbuf(*cerr_ptr);
_VSTD::unitbuf(*wcerr_ptr);
#ifndef _LIBCPP_HAS_NO_STDOUT
cerr_ptr->tie(cout_ptr);
wcerr_ptr->tie(wcout_ptr);
#endif
}
ios_base::Init::~Init()
{
#ifndef _LIBCPP_HAS_NO_STDOUT
ostream* cout_ptr = reinterpret_cast<ostream*>(cout);
ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
cout_ptr->flush();
clog_ptr->flush();
wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);
wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
cout_ptr->flush();
wcout_ptr->flush();
#endif
ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
clog_ptr->flush();
wclog_ptr->flush();
}

View File

@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
// On Solaris, we need to define something to make the C99 parts of localeconv
// visible.
#ifdef __sun__
@@ -29,7 +27,7 @@
#include "cwctype"
#include "__sso_allocator"
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
#include <support/win32/locale_win32.h>
#include "support/win32/locale_win32.h"
#elif !defined(__ANDROID__)
#include <langinfo.h>
#endif
@@ -577,8 +575,10 @@ locale::global(const locale& loc)
locale& g = __global();
locale r = g;
g = loc;
#ifndef __CloudABI__
if (g.name() != "*")
setlocale(LC_ALL, g.name().c_str());
#endif
return r;
}
@@ -815,7 +815,7 @@ ctype<wchar_t>::do_toupper(char_type c) const
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
#else
return (isascii(c) && iswlower_l(c, __cloc())) ? c-L'a'+L'A' : c;
return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
#endif
}
@@ -829,7 +829,7 @@ ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
*low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
: *low;
#else
*low = (isascii(*low) && islower_l(*low, __cloc())) ? (*low-L'a'+L'A') : *low;
*low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low;
#endif
return low;
}
@@ -842,7 +842,7 @@ ctype<wchar_t>::do_tolower(char_type c) const
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
#else
return (isascii(c) && isupper_l(c, __cloc())) ? c-L'A'+'a' : c;
return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
#endif
}
@@ -856,7 +856,7 @@ ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
*low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
: *low;
#else
*low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-L'A'+L'a' : *low;
*low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low;
#endif
return low;
}
@@ -925,7 +925,7 @@ ctype<char>::do_toupper(char_type c) const
return isascii(c) ?
static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
#else
return (isascii(c) && islower_l(c, __cloc())) ? c-'a'+'A' : c;
return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
#endif
}
@@ -942,7 +942,7 @@ ctype<char>::do_toupper(char_type* low, const char_type* high) const
*low = isascii(*low) ?
static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
#else
*low = (isascii(*low) && islower_l(*low, __cloc())) ? *low-'a'+'A' : *low;
*low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low;
#endif
return low;
}
@@ -959,7 +959,7 @@ ctype<char>::do_tolower(char_type c) const
return isascii(c) ?
static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
#else
return (isascii(c) && isupper_l(c, __cloc())) ? c-'A'+'a' : c;
return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c;
#endif
}
@@ -974,7 +974,7 @@ ctype<char>::do_tolower(char_type* low, const char_type* high) const
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
*low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
#else
*low = (isascii(*low) && isupper_l(*low, __cloc())) ? *low-'A'+'a' : *low;
*low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
#endif
return low;
}
@@ -1107,7 +1107,7 @@ ctype<char>::classic_table() _NOEXCEPT
#elif defined(__NetBSD__)
return _C_ctype_tab_ + 1;
#elif defined(__GLIBC__)
return __cloc()->__ctype_b;
return _LIBCPP_GET_C_LOCALE->__ctype_b;
#elif __sun__
return __ctype_mask;
#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
@@ -1136,13 +1136,13 @@ ctype<char>::classic_table() _NOEXCEPT
const int*
ctype<char>::__classic_lower_table() _NOEXCEPT
{
return __cloc()->__ctype_tolower;
return _LIBCPP_GET_C_LOCALE->__ctype_tolower;
}
const int*
ctype<char>::__classic_upper_table() _NOEXCEPT
{
return __cloc()->__ctype_toupper;
return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
}
#elif __NetBSD__
const short*
@@ -1265,16 +1265,16 @@ ctype_byname<wchar_t>::do_is(mask m, char_type c) const
#else
bool result = false;
wint_t ch = static_cast<wint_t>(c);
if (m & space) result |= (iswspace_l(ch, __l) != 0);
if (m & print) result |= (iswprint_l(ch, __l) != 0);
if (m & cntrl) result |= (iswcntrl_l(ch, __l) != 0);
if (m & upper) result |= (iswupper_l(ch, __l) != 0);
if (m & lower) result |= (iswlower_l(ch, __l) != 0);
if (m & alpha) result |= (iswalpha_l(ch, __l) != 0);
if (m & digit) result |= (iswdigit_l(ch, __l) != 0);
if (m & punct) result |= (iswpunct_l(ch, __l) != 0);
if (m & xdigit) result |= (iswxdigit_l(ch, __l) != 0);
if (m & blank) result |= (iswblank_l(ch, __l) != 0);
if ((m & space) == space) result |= (iswspace_l(ch, __l) != 0);
if ((m & print) == print) result |= (iswprint_l(ch, __l) != 0);
if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l) != 0);
if ((m & upper) == upper) result |= (iswupper_l(ch, __l) != 0);
if ((m & lower) == lower) result |= (iswlower_l(ch, __l) != 0);
if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l) != 0);
if ((m & digit) == digit) result |= (iswdigit_l(ch, __l) != 0);
if ((m & punct) == punct) result |= (iswpunct_l(ch, __l) != 0);
if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l) != 0);
if ((m & blank) == blank) result |= (iswblank_l(ch, __l) != 0);
return result;
#endif
}
@@ -1292,22 +1292,32 @@ ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask*
wint_t ch = static_cast<wint_t>(*low);
if (iswspace_l(ch, __l))
*vec |= space;
#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
if (iswprint_l(ch, __l))
*vec |= print;
#endif
if (iswcntrl_l(ch, __l))
*vec |= cntrl;
if (iswupper_l(ch, __l))
*vec |= upper;
if (iswlower_l(ch, __l))
*vec |= lower;
#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
if (iswalpha_l(ch, __l))
*vec |= alpha;
#endif
if (iswdigit_l(ch, __l))
*vec |= digit;
if (iswpunct_l(ch, __l))
*vec |= punct;
#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
if (iswxdigit_l(ch, __l))
*vec |= xdigit;
#endif
#if !defined(__sun__)
if (iswblank_l(ch, __l))
*vec |= blank;
#endif
}
}
return low;
@@ -1323,16 +1333,16 @@ ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type*
break;
#else
wint_t ch = static_cast<wint_t>(*low);
if (m & space && iswspace_l(ch, __l)) break;
if (m & print && iswprint_l(ch, __l)) break;
if (m & cntrl && iswcntrl_l(ch, __l)) break;
if (m & upper && iswupper_l(ch, __l)) break;
if (m & lower && iswlower_l(ch, __l)) break;
if (m & alpha && iswalpha_l(ch, __l)) break;
if (m & digit && iswdigit_l(ch, __l)) break;
if (m & punct && iswpunct_l(ch, __l)) break;
if (m & xdigit && iswxdigit_l(ch, __l)) break;
if (m & blank && iswblank_l(ch, __l)) break;
if ((m & space) == space && iswspace_l(ch, __l)) break;
if ((m & print) == print && iswprint_l(ch, __l)) break;
if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) break;
if ((m & upper) == upper && iswupper_l(ch, __l)) break;
if ((m & lower) == lower && iswlower_l(ch, __l)) break;
if ((m & alpha) == alpha && iswalpha_l(ch, __l)) break;
if ((m & digit) == digit && iswdigit_l(ch, __l)) break;
if ((m & punct) == punct && iswpunct_l(ch, __l)) break;
if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) break;
if ((m & blank) == blank && iswblank_l(ch, __l)) break;
#endif
}
return low;
@@ -1348,16 +1358,16 @@ ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type
break;
#else
wint_t ch = static_cast<wint_t>(*low);
if (m & space && iswspace_l(ch, __l)) continue;
if (m & print && iswprint_l(ch, __l)) continue;
if (m & cntrl && iswcntrl_l(ch, __l)) continue;
if (m & upper && iswupper_l(ch, __l)) continue;
if (m & lower && iswlower_l(ch, __l)) continue;
if (m & alpha && iswalpha_l(ch, __l)) continue;
if (m & digit && iswdigit_l(ch, __l)) continue;
if (m & punct && iswpunct_l(ch, __l)) continue;
if (m & xdigit && iswxdigit_l(ch, __l)) continue;
if (m & blank && iswblank_l(ch, __l)) continue;
if ((m & space) == space && iswspace_l(ch, __l)) continue;
if ((m & print) == print && iswprint_l(ch, __l)) continue;
if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l)) continue;
if ((m & upper) == upper && iswupper_l(ch, __l)) continue;
if ((m & lower) == lower && iswlower_l(ch, __l)) continue;
if ((m & alpha) == alpha && iswalpha_l(ch, __l)) continue;
if ((m & digit) == digit && iswdigit_l(ch, __l)) continue;
if ((m & punct) == punct && iswpunct_l(ch, __l)) continue;
if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l)) continue;
if ((m & blank) == blank && iswblank_l(ch, __l)) continue;
break;
#endif
}
@@ -1649,7 +1659,7 @@ codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
frm_nxt = frm;
return frm_nxt == frm_end ? ok : partial;
}
if (n == 0)
if (n == size_t(-1))
return error;
to_nxt += n;
if (to_nxt == to_end)
@@ -1699,22 +1709,23 @@ codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
int
codecvt<wchar_t, char, mbstate_t>::do_encoding() const _NOEXCEPT
{
#ifndef __CloudABI__
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
if (mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
#else
if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) == 0)
if (__mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l) != 0)
#endif
{
// stateless encoding
return -1;
#endif
// stateless encoding
#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
if (__l == 0 || MB_CUR_MAX_L(__l) == 1) // there are no known constant length encodings
if (__l == 0 || MB_CUR_MAX_L(__l) == 1) // there are no known constant length encodings
#else
if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings
if (__l == 0 || __mb_cur_max_l(__l) == 1) // there are no known constant length encodings
#endif
return 1; // which take more than 1 char to form a wchar_t
return 0;
}
return -1;
return 1; // which take more than 1 char to form a wchar_t
return 0;
}
bool

View File

@@ -13,24 +13,28 @@
#include "mutex"
#include "thread"
#endif
#include "support/atomic_support.h"
_LIBCPP_BEGIN_NAMESPACE_STD
namespace
{
// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
// should be sufficient for thread safety.
// See https://llvm.org/bugs/show_bug.cgi?id=22803
template <class T>
inline T
increment(T& t) _NOEXCEPT
{
return __sync_add_and_fetch(&t, 1);
return __libcpp_atomic_add(&t, 1, _AO_Relaxed);
}
template <class T>
inline T
decrement(T& t) _NOEXCEPT
{
return __sync_add_and_fetch(&t, -1);
return __libcpp_atomic_add(&t, -1, _AO_Acq_Rel);
}
} // namespace
@@ -99,14 +103,13 @@ __shared_weak_count::__release_weak() _NOEXCEPT
__shared_weak_count*
__shared_weak_count::lock() _NOEXCEPT
{
long object_owners = __shared_owners_;
long object_owners = __libcpp_atomic_load(&__shared_owners_);
while (object_owners != -1)
{
if (__sync_bool_compare_and_swap(&__shared_owners_,
object_owners,
object_owners+1))
if (__libcpp_atomic_compare_exchange(&__shared_owners_,
&object_owners,
object_owners+1))
return this;
object_owners = __shared_owners_;
}
return 0;
}

View File

@@ -12,6 +12,7 @@
#include "limits"
#include "system_error"
#include "cassert"
#include "support/atomic_support.h"
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_THREADS
@@ -220,6 +221,9 @@ static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t cv = PTHREAD_COND_INITIALIZER;
#endif
/// NOTE: Changes to flag are done via relaxed atomic stores
/// even though the accesses are protected by a mutex because threads
/// just entering 'call_once` concurrently read from flag.
void
__call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
{
@@ -252,11 +256,11 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
try
{
#endif // _LIBCPP_NO_EXCEPTIONS
flag = 1;
__libcpp_relaxed_store(&flag, 1ul);
pthread_mutex_unlock(&mut);
func(arg);
pthread_mutex_lock(&mut);
flag = ~0ul;
__libcpp_relaxed_store(&flag, ~0ul);
pthread_mutex_unlock(&mut);
pthread_cond_broadcast(&cv);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -264,7 +268,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
catch (...)
{
pthread_mutex_lock(&mut);
flag = 0ul;
__libcpp_relaxed_store(&flag, 0ul);
pthread_mutex_unlock(&mut);
pthread_cond_broadcast(&cv);
throw;

View File

@@ -138,13 +138,6 @@ operator delete(void* ptr, size_t) _NOEXCEPT
::operator delete(ptr);
}
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
void
operator delete(void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
{
::operator delete(ptr, nt);
}
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
void
operator delete[] (void* ptr) _NOEXCEPT
@@ -166,13 +159,6 @@ operator delete[] (void* ptr, size_t) _NOEXCEPT
::operator delete[](ptr);
}
_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
void
operator delete[] (void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
{
::operator delete[](ptr, nt);
}
#endif // !__GLIBCXX__
namespace std

View File

@@ -7,11 +7,10 @@
//
//===----------------------------------------------------------------------===//
#if defined(_WIN32)
#if defined(_LIBCPP_USING_WIN32_RANDOM)
// Must be defined before including stdlib.h to enable rand_s().
#define _CRT_RAND_S
#include <stdio.h>
#endif // defined(_WIN32)
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
#include "random"
#include "system_error"
@@ -19,46 +18,27 @@
#if defined(__sun__)
#define rename solaris_headers_are_broken
#endif // defined(__sun__)
#if !defined(_WIN32)
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#if defined(_LIBCPP_USING_DEV_RANDOM)
#include <fcntl.h>
#include <unistd.h>
#endif // !defined(_WIN32)
#include <errno.h>
#if defined(_LIBCPP_USING_NACL_RANDOM)
#elif defined(_LIBCPP_USING_NACL_RANDOM)
#include <nacl/nacl_random.h>
#endif // defined(_LIBCPP_USING_NACL_RANDOM)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_WIN32)
random_device::random_device(const string&)
{
}
random_device::~random_device()
{
}
unsigned
random_device::operator()()
{
unsigned r;
errno_t err = rand_s(&r);
if (err)
__throw_system_error(err, "random_device rand_s failed.");
return r;
}
#elif defined(_LIBCPP_USING_NACL_RANDOM)
#if defined(_LIBCPP_USING_ARC4_RANDOM)
random_device::random_device(const string& __token)
{
if (__token != "/dev/urandom")
__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
int error = nacl_secure_random_init();
if (error)
__throw_system_error(error, ("random device failed to open " + __token).c_str());
}
random_device::~random_device()
@@ -68,18 +48,10 @@ random_device::~random_device()
unsigned
random_device::operator()()
{
unsigned r;
size_t n = sizeof(r);
size_t bytes_written;
int error = nacl_secure_random(&r, n, &bytes_written);
if (error != 0)
__throw_system_error(error, "random_device failed getting bytes");
else if (bytes_written != n)
__throw_runtime_error("random_device failed to obtain enough bytes");
return r;
return arc4random();
}
#else // !defined(_WIN32) && !defined(_LIBCPP_USING_NACL_RANDOM)
#elif defined(_LIBCPP_USING_DEV_RANDOM)
random_device::random_device(const string& __token)
: __f_(open(__token.c_str(), O_RDONLY))
@@ -116,7 +88,60 @@ random_device::operator()()
return r;
}
#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)
#elif defined(_LIBCPP_USING_NACL_RANDOM)
random_device::random_device(const string& __token)
{
if (__token != "/dev/urandom")
__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
int error = nacl_secure_random_init();
if (error)
__throw_system_error(error, ("random device failed to open " + __token).c_str());
}
random_device::~random_device()
{
}
unsigned
random_device::operator()()
{
unsigned r;
size_t n = sizeof(r);
size_t bytes_written;
int error = nacl_secure_random(&r, n, &bytes_written);
if (error != 0)
__throw_system_error(error, "random_device failed getting bytes");
else if (bytes_written != n)
__throw_runtime_error("random_device failed to obtain enough bytes");
return r;
}
#elif defined(_LIBCPP_USING_WIN32_RANDOM)
random_device::random_device(const string& __token)
{
if (__token != "/dev/urandom")
__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
}
random_device::~random_device()
{
}
unsigned
random_device::operator()()
{
unsigned r;
errno_t err = rand_s(&r);
if (err)
__throw_system_error(err, "random_device rand_s failed.");
return r;
}
#else
#error "Random device not implemented for this architecture"
#endif
double
random_device::entropy() const _NOEXCEPT

View File

@@ -15,7 +15,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
shared_timed_mutex::shared_timed_mutex()
// Shared Mutex Base
__shared_mutex_base::__shared_mutex_base()
: __state_(0)
{
}
@@ -23,7 +24,7 @@ shared_timed_mutex::shared_timed_mutex()
// Exclusive ownership
void
shared_timed_mutex::lock()
__shared_mutex_base::lock()
{
unique_lock<mutex> lk(__mut_);
while (__state_ & __write_entered_)
@@ -34,7 +35,7 @@ shared_timed_mutex::lock()
}
bool
shared_timed_mutex::try_lock()
__shared_mutex_base::try_lock()
{
unique_lock<mutex> lk(__mut_);
if (__state_ == 0)
@@ -46,7 +47,7 @@ shared_timed_mutex::try_lock()
}
void
shared_timed_mutex::unlock()
__shared_mutex_base::unlock()
{
lock_guard<mutex> _(__mut_);
__state_ = 0;
@@ -56,7 +57,7 @@ shared_timed_mutex::unlock()
// Shared ownership
void
shared_timed_mutex::lock_shared()
__shared_mutex_base::lock_shared()
{
unique_lock<mutex> lk(__mut_);
while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_)
@@ -67,7 +68,7 @@ shared_timed_mutex::lock_shared()
}
bool
shared_timed_mutex::try_lock_shared()
__shared_mutex_base::try_lock_shared()
{
unique_lock<mutex> lk(__mut_);
unsigned num_readers = __state_ & __n_readers_;
@@ -82,7 +83,7 @@ shared_timed_mutex::try_lock_shared()
}
void
shared_timed_mutex::unlock_shared()
__shared_mutex_base::unlock_shared()
{
lock_guard<mutex> _(__mut_);
unsigned num_readers = (__state_ & __n_readers_) - 1;
@@ -101,6 +102,16 @@ shared_timed_mutex::unlock_shared()
}
// Shared Timed Mutex
// These routines are here for ABI stability
shared_timed_mutex::shared_timed_mutex() : __base() {}
void shared_timed_mutex::lock() { return __base.lock(); }
bool shared_timed_mutex::try_lock() { return __base.try_lock(); }
void shared_timed_mutex::unlock() { return __base.unlock(); }
void shared_timed_mutex::lock_shared() { return __base.lock_shared(); }
bool shared_timed_mutex::try_lock_shared() { return __base.try_lock_shared(); }
void shared_timed_mutex::unlock_shared() { return __base.unlock_shared(); }
_LIBCPP_END_NAMESPACE_STD
#endif // !_LIBCPP_HAS_NO_THREADS

View File

@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#include "string"
#include "cstdlib"
#include "cwchar"
@@ -41,7 +39,7 @@ void throw_helper( const string& msg )
#ifndef _LIBCPP_NO_EXCEPTIONS
throw T( msg );
#else
printf("%s\n", msg.c_str());
fprintf(stderr, "%s\n", msg.c_str());
abort();
#endif
}

View File

@@ -0,0 +1,142 @@
#ifndef ATOMIC_SUPPORT_H
#define ATOMIC_SUPPORT_H
#include "__config"
#include "memory" // for __libcpp_relaxed_load
#if defined(__clang__) && __has_builtin(__atomic_load_n) \
&& __has_builtin(__atomic_store_n) \
&& __has_builtin(__atomic_add_fetch) \
&& __has_builtin(__atomic_compare_exchange_n) \
&& defined(__ATOMIC_RELAXED) \
&& defined(__ATOMIC_CONSUME) \
&& defined(__ATOMIC_ACQUIRE) \
&& defined(__ATOMIC_RELEASE) \
&& defined(__ATOMIC_ACQ_REL) \
&& defined(__ATOMIC_SEQ_CST)
# define _LIBCPP_HAS_ATOMIC_BUILTINS
#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
# define _LIBCPP_HAS_ATOMIC_BUILTINS
#endif
#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
# if defined(_MSC_VER) && !defined(__clang__)
_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
# else
# warning Building libc++ without __atomic builtins is unsupported
# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
namespace {
#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
enum __libcpp_atomic_order {
_AO_Relaxed = __ATOMIC_RELAXED,
_AO_Consume = __ATOMIC_CONSUME,
_AO_Aquire = __ATOMIC_ACQUIRE,
_AO_Release = __ATOMIC_RELEASE,
_AO_Acq_Rel = __ATOMIC_ACQ_REL,
_AO_Seq = __ATOMIC_SEQ_CST
};
template <class _ValueType, class _FromType>
inline _LIBCPP_INLINE_VISIBILITY
void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
int __order = _AO_Seq)
{
__atomic_store_n(__dest, __val, __order);
}
template <class _ValueType, class _FromType>
inline _LIBCPP_INLINE_VISIBILITY
void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
{
__atomic_store_n(__dest, __val, _AO_Relaxed);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_atomic_load(_ValueType const* __val,
int __order = _AO_Seq)
{
return __atomic_load_n(__val, __order);
}
template <class _ValueType, class _AddType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
int __order = _AO_Seq)
{
return __atomic_add_fetch(__val, __a, __order);
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
_ValueType* __expected, _ValueType __after,
int __success_order = _AO_Seq,
int __fail_order = _AO_Seq)
{
return __atomic_compare_exchange_n(__val, __expected, __after, true,
__success_order, __fail_order);
}
#else // _LIBCPP_HAS_NO_THREADS
enum __libcpp_atomic_order {
_AO_Relaxed,
_AO_Consume,
_AO_Acquire,
_AO_Release,
_AO_Acq_Rel,
_AO_Seq
};
template <class _ValueType, class _FromType>
inline _LIBCPP_INLINE_VISIBILITY
void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
int = 0)
{
*__dest = __val;
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_atomic_load(_ValueType const* __val,
int = 0)
{
return *__val;
}
template <class _ValueType, class _AddType>
inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
int = 0)
{
return *__val += __a;
}
template <class _ValueType>
inline _LIBCPP_INLINE_VISIBILITY
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
_ValueType* __expected, _ValueType __after,
int = 0, int = 0)
{
if (*__val == *__expected) {
*__val = __after;
return true;
}
*__expected = *__val;
return false;
}
#endif // _LIBCPP_HAS_NO_THREADS
} // end namespace
_LIBCPP_END_NAMESPACE_STD
#endif // ATOMIC_SUPPORT_H

View File

@@ -152,7 +152,7 @@ system_error::__init(const error_code& ec, string what_arg)
what_arg += ": ";
what_arg += ec.message();
}
return _VSTD::move(what_arg);
return what_arg;
}
system_error::system_error(error_code ec, const string& what_arg)

View File

@@ -17,9 +17,9 @@
#include "limits"
#include <sys/types.h>
#if !defined(_WIN32)
# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__)
# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
# include <sys/sysctl.h>
# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__)
# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX) && !defined(__native_client__) && !defined(__CloudABI__)
# include <unistd.h>
#endif // !_WIN32

View File

@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
#include "valarray"
_LIBCPP_BEGIN_NAMESPACE_STD

View File

@@ -6,69 +6,48 @@ macro(pythonize_bool var)
endif()
endmacro()
set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's llvm-lit.")
set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
"Configuration variant to use for LIT.")
if(LIBCXX_BUILT_STANDALONE)
# Make sure we can use the console pool for recent cmake and ninja > 1.5
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()
else()
include(FindPythonInterp)
if(PYTHONINTERP_FOUND)
set(LIT_EXECUTABLE
${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/lit/lit.py)
else()
message(WARNING "Could not find Python, cannot set LIT_EXECUTABLE.")
endif()
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_RTTI)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE)
pythonize_bool(LIBCXX_ENABLE_STDIN)
pythonize_bool(LIBCXX_ENABLE_STDOUT)
pythonize_bool(LIBCXX_ENABLE_THREADS)
pythonize_bool(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
pythonize_bool(LIBCXX_GENERATE_COVERAGE)
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
# The tests shouldn't link to any ABI library when it has been linked into
# libc++ statically.
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif()
set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
"TargetInfo to use when setting up test environment.")
set(LIBCXX_EXECUTOR "None" CACHE STRING
"Executor to use when running tests.")
if (LIT_EXECUTABLE)
set(LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail")
if (MSVC OR XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
CACHE STRING "Default options for lit")
set(LIT_ARGS "${LLVM_LIT_ARGS}")
separate_arguments(LIT_ARGS)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
"Configuration variant to use for LIT.")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ONLY)
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
pythonize_bool(LIBCXX_ENABLE_RTTI)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBCXX_BUILD_32_BITS)
pythonize_bool(LIBCXX_ENABLE_THREADS)
pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK)
# The tests shouldn't link to any ABI library when it has been linked into
# libc++ statically.
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
set(LIBCXX_CXX_ABI_LIBNAME "none")
endif()
set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
"TargetInfo to use when setting up test environment.")
set(LIBCXX_EXECUTOR "None" CACHE STRING
"Executor to use when running tests.")
add_lit_testsuite(check-libcxx
"Running libcxx tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxx)
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ONLY)
add_custom_target(check-libcxx
COMMAND ${LIT_EXECUTABLE}
${LIT_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxx
COMMENT "Running libcxx tests"
${cmake_3_2_USES_TERMINAL})
else()
message(WARNING
"LIT_EXECUTABLE not set, no check-libcxx target will be available!")
if (LIBCXX_GENERATE_COVERAGE)
include(CodeCoverage)
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${CMAKE_CURRENT_BINARY_DIR}")
set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
endif()

View File

@@ -107,12 +107,15 @@ class CXXCompiler(object):
# Otherwise wrap the filename in a context manager function.
with_fn = lambda: libcxx.util.nullContext(object_file)
with with_fn() as object_file:
cmd, output, err, rc = self.compile(source_file, object_file,
flags=flags, env=env, cwd=cwd)
cc_cmd, cc_stdout, cc_stderr, rc = self.compile(
source_file, object_file, flags=flags, env=env, cwd=cwd)
if rc != 0:
return cmd, output, err, rc
return self.link(object_file, out=out, flags=flags, env=env,
cwd=cwd)
return cc_cmd, cc_stdout, cc_stderr, rc
link_cmd, link_stdout, link_stderr, rc = self.link(
object_file, out=out, flags=flags, env=env, cwd=cwd)
return (cc_cmd + ['&&'] + link_cmd, cc_stdout + link_stdout,
cc_stderr + link_stderr, rc)
def dumpMacros(self, source_files=None, flags=[], env=None, cwd=None):
if source_files is None:
@@ -134,3 +137,27 @@ class CXXCompiler(object):
def getTriple(self):
cmd = [self.path] + self.flags + ['-dumpmachine']
return lit.util.capture(cmd).strip()
def hasCompileFlag(self, flag):
if isinstance(flag, list):
flags = list(flag)
else:
flags = [flag]
# Add -Werror to ensure that an unrecognized flag causes a non-zero
# exit code. -Werror is supported on all known compiler types.
if self.type is not None:
flags += ['-Werror']
cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
flags=flags)
return rc == 0
def addCompileFlagIfSupported(self, flag):
if isinstance(flag, list):
flags = list(flag)
else:
flags = [flag]
if self.hasCompileFlag(flags):
self.compile_flags += flags
return True
else:
return False

View File

@@ -15,15 +15,18 @@
#include <cassert>
#include <cstdlib>
#include "min_allocator.h"
#include "asan_testing.h"
#include "min_allocator.h"
#include "test_iterators.h"
#include "test_macros.h"
#ifndef _LIBCPP_HAS_NO_ASAN
extern "C" void __asan_set_error_exit_code(int);
int main()
{
#if __cplusplus >= 201103L
#if TEST_STD_VER >= 11
{
typedef int T;
typedef std::vector<T, min_allocator<T>> C;
@@ -34,6 +37,17 @@ int main()
}
#endif
{
typedef input_iterator<int*> MyInputIter;
// Sould not trigger ASan.
std::vector<int> v;
v.reserve(1);
int i[] = {42};
v.insert(v.begin(), MyInputIter(i), MyInputIter(i + 1));
assert(v[0] == 42);
assert(is_contiguous_container_asan_correct(v));
}
__asan_set_error_exit_code(0);
{
typedef int T;

View File

@@ -37,6 +37,22 @@ private:
char a;
};
class ThrowOnCopy {
public:
ThrowOnCopy() : should_throw(false) {}
explicit ThrowOnCopy(bool should_throw) : should_throw(should_throw) {}
ThrowOnCopy(ThrowOnCopy const & other)
: should_throw(other.should_throw)
{
if (should_throw) {
throw 0;
}
}
bool should_throw;
};
void test_push_back() {
std::vector<X> v;
v.reserve(2);
@@ -157,6 +173,23 @@ void test_insert_n() {
assert(0);
}
void test_insert_n2() {
std::vector<ThrowOnCopy> v(10);
v.reserve(100);
assert(v.size() == 10);
v[6].should_throw = true;
try {
v.insert(v.cbegin(), 5, ThrowOnCopy());
assert(0);
} catch (int e) {
assert(v.size() == 11);
assert(is_contiguous_container_asan_correct(v));
return;
}
assert(0);
}
void test_resize() {
std::vector<X> v;
v.reserve(3);
@@ -193,6 +226,7 @@ int main() {
test_emplace();
test_insert_range2();
test_insert_n();
test_insert_n2();
test_resize();
test_resize_param();
}

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// Check that we don't allocate when trying to insert a duplicate value into a
// unordered_set. See PR12999 http://llvm.org/bugs/show_bug.cgi?id=12999
#include <cassert>
#include <unordered_set>
#include "count_new.hpp"
#include "MoveOnly.h"
int main()
{
{
std::unordered_set<int> s;
assert(globalMemCounter.checkNewCalledEq(0));
for(int i=0; i < 100; ++i)
s.insert(3);
assert(s.size() == 1);
assert(s.count(3) == 1);
assert(globalMemCounter.checkNewCalledEq(2));
}
assert(globalMemCounter.checkOutstandingNewEq(0));
globalMemCounter.reset();
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::unordered_set<MoveOnly> s;
assert(globalMemCounter.checkNewCalledEq(0));
for(int i=0; i<100; i++)
s.insert(MoveOnly(3));
assert(s.size() == 1);
assert(s.count(MoveOnly(3)) == 1);
assert(globalMemCounter.checkNewCalledEq(2));
}
assert(globalMemCounter.checkOutstandingNewEq(0));
globalMemCounter.reset();
#endif
}

View File

@@ -49,6 +49,7 @@
#include <cwctype>
#include <deque>
#include <exception>
#include <experimental/algorithm>
#include <experimental/chrono>
#include <experimental/dynarray>
#include <experimental/optional>

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <experimental/algorithm>
#include <experimental/algorithm>
#ifndef _LIBCPP_ALGORITHM
# error "<experimental/algorithm> must include <algorithm>"
#endif
int main()
{
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <experimental/algorithm>
#include <experimental/algorithm>
#ifndef _LIBCPP_VERSION
# error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/any>
// Check that the size and alignment of any are what we expect.
#include <experimental/any>
int main()
{
using std::experimental::any;
static_assert(sizeof(any) == sizeof(void*)*4, "");
static_assert(alignof(any) == alignof(void*), "");
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// <experimental/any>
// Check that the size and alignment of any are what we expect.
#include <experimental/any>
#include "any_helpers.h"
class SmallThrowsDtor
{
public:
SmallThrowsDtor() {}
SmallThrowsDtor(SmallThrowsDtor const &) noexcept {}
SmallThrowsDtor(SmallThrowsDtor &&) noexcept {}
~SmallThrowsDtor() noexcept(false) {}
};
int main()
{
using std::experimental::any;
using std::experimental::__any_imp::_IsSmallObject;
static_assert(_IsSmallObject<small>::value, "");
static_assert(_IsSmallObject<void*>::value, "");
static_assert(!_IsSmallObject<SmallThrowsDtor>::value, "");
static_assert(!_IsSmallObject<large>::value, "");
// long double is over aligned.
static_assert(sizeof(long double) <= sizeof(void*) * 3, "");
static_assert(alignof(long double) > alignof(void*), "");
static_assert(!_IsSmallObject<long double>::value, "");
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <experimental/any>
#include <experimental/any>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

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