Merge to upstream r324534.
am: f835096310
Change-Id: I1dcdaca4370f82d8f02b97a93fe79149b5af5c0f
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"project_id" : "libcxx",
|
||||
"repository.callsign" : "CXX",
|
||||
"conduit_uri" : "https://reviews.llvm.org/"
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
project(libcxx CXX C)
|
||||
|
||||
set(PACKAGE_NAME libcxx)
|
||||
set(PACKAGE_VERSION 5.0.0svn)
|
||||
set(PACKAGE_VERSION 7.0.0svn)
|
||||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org")
|
||||
|
||||
@@ -99,6 +99,9 @@ cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
|
||||
"LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
|
||||
set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
|
||||
option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
|
||||
option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
|
||||
option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
|
||||
set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
|
||||
option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
|
||||
|
||||
if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
|
||||
@@ -118,7 +121,9 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
|
||||
cxxabi.h
|
||||
PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include
|
||||
${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
|
||||
${LLVM_MAIN_SRC_DIR}/../libcxxabi/include
|
||||
NO_DEFAULT_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
)
|
||||
if (LIBCXX_TARGETING_MSVC)
|
||||
# FIXME: Figure out how to configure the ABI library on Windows.
|
||||
@@ -198,6 +203,7 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
|
||||
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
|
||||
option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF)
|
||||
option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF)
|
||||
option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF)
|
||||
option(LIBCXX_HAS_EXTERNAL_THREAD_API
|
||||
"Build libc++ with an externalized threading API.
|
||||
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
|
||||
@@ -269,6 +275,10 @@ if(NOT LIBCXX_ENABLE_THREADS)
|
||||
message(FATAL_ERROR "LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY can only be set "
|
||||
"to ON when LIBCXX_ENABLE_THREADS is also set to ON.")
|
||||
endif()
|
||||
if (LIBCXX_HAS_WIN32_THREAD_API)
|
||||
message(FATAL_ERROR "LIBCXX_HAS_WIN32_THREAD_API can only be set to ON"
|
||||
" when LIBCXX_ENABLE_THREADS is also set to ON.")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -283,6 +293,19 @@ if (LIBCXX_HAS_EXTERNAL_THREAD_API)
|
||||
"and LIBCXX_HAS_PTHREAD_API cannot be both"
|
||||
"set to ON at the same time.")
|
||||
endif()
|
||||
if (LIBCXX_HAS_WIN32_THREAD_API)
|
||||
message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
|
||||
"and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
|
||||
"set to ON at the same time.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (LIBCXX_HAS_PTHREAD_API)
|
||||
if (LIBCXX_HAS_WIN32_THREAD_API)
|
||||
message(FATAL_ERROR "The options LIBCXX_HAS_PTHREAD_API"
|
||||
"and LIBCXX_HAS_WIN32_THREAD_API cannot be both"
|
||||
"set to ON at the same time.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
|
||||
@@ -336,6 +359,10 @@ if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
|
||||
"when building for Musl with LIBCXX_HAS_MUSL_LIBC.")
|
||||
endif()
|
||||
|
||||
if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT)
|
||||
message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.")
|
||||
endif ()
|
||||
|
||||
#===============================================================================
|
||||
# Configure System
|
||||
#===============================================================================
|
||||
@@ -351,6 +378,13 @@ else()
|
||||
endif()
|
||||
file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}")
|
||||
|
||||
set(LIBCXX_INSTALL_PREFIX "" CACHE STRING
|
||||
"Define libc++ destination prefix.")
|
||||
|
||||
if (NOT LIBCXX_INSTALL_PREFIX MATCHES "^$|.*/")
|
||||
message(FATAL_ERROR "LIBCXX_INSTALL_PREFIX has to end with \"/\".")
|
||||
endif()
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
|
||||
@@ -586,6 +620,8 @@ if (NOT LIBCXX_ABI_VERSION EQUAL "1")
|
||||
config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
|
||||
endif()
|
||||
config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
|
||||
config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
|
||||
config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
|
||||
|
||||
config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE)
|
||||
config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN)
|
||||
@@ -596,8 +632,22 @@ config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THRE
|
||||
|
||||
config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
|
||||
config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32)
|
||||
config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
|
||||
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
|
||||
config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
|
||||
|
||||
if (LIBCXX_ABI_DEFINES)
|
||||
set(abi_defines)
|
||||
foreach (abi_define ${LIBCXX_ABI_DEFINES})
|
||||
if (NOT abi_define MATCHES "^_LIBCPP_ABI_")
|
||||
message(SEND_ERROR "Invalid ABI macro ${abi_define} in LIBCXX_ABI_DEFINES")
|
||||
endif()
|
||||
list(APPEND abi_defines "#define ${abi_define}")
|
||||
endforeach()
|
||||
string(REPLACE ";" "\n" abi_defines "${abi_defines}")
|
||||
config_define(${abi_defines} _LIBCPP_ABI_DEFINES)
|
||||
endif()
|
||||
|
||||
# By default libc++ on Windows expects to use a shared library, which requires
|
||||
# the headers to use DLL import/export semantics. However when building a
|
||||
@@ -607,9 +657,10 @@ if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED)
|
||||
config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||
endif()
|
||||
|
||||
set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site")
|
||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
configure_file("include/__config_site.in"
|
||||
"${LIBCXX_BINARY_DIR}/__config_site"
|
||||
"${site_config_path}"
|
||||
@ONLY)
|
||||
|
||||
# Provide the config definitions by included the generated __config_site
|
||||
@@ -619,6 +670,11 @@ if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
else()
|
||||
add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
|
||||
endif()
|
||||
else()
|
||||
if (EXISTS "${site_config_path}")
|
||||
message(STATUS "Removing stale site configuration ${site_config_path}")
|
||||
file(REMOVE "${site_config_path}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
@@ -639,6 +695,7 @@ endif()
|
||||
#
|
||||
# However, since some submission systems strip test/ subdirectories, check for
|
||||
# it before adding it.
|
||||
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test")
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
@@ -646,6 +703,16 @@ if (LIBCXX_INCLUDE_TESTS)
|
||||
add_subdirectory(lib/abi)
|
||||
endif()
|
||||
|
||||
if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
|
||||
include(AddLLVM) # for get_llvm_lit_path
|
||||
# Make sure the llvm-lit script is generated into the bin directory, and do
|
||||
# it after adding all tests, since the generated script will only work
|
||||
# correctly discovered tests against test locations from the source tree that
|
||||
# have already been discovered.
|
||||
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit
|
||||
${CMAKE_CURRENT_BINARY_DIR}/llvm-lit)
|
||||
endif()
|
||||
|
||||
if (LIBCXX_INCLUDE_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif()
|
||||
|
||||
@@ -41,6 +41,10 @@ N: Jonathan B Coe
|
||||
E: jbcoe@me.com
|
||||
D: Implementation of propagate_const.
|
||||
|
||||
N: Glen Joseph Fernandes
|
||||
E: glenjofe@gmail.com
|
||||
D: Implementation of to_address.
|
||||
|
||||
N: Eric Fiselier
|
||||
E: eric@efcs.ca
|
||||
D: LFTS support, patches and bug fixes.
|
||||
@@ -97,7 +101,7 @@ E: nico.rieck@gmail.com
|
||||
D: Windows fixes
|
||||
|
||||
N: Jon Roelofs
|
||||
E: jonathan@codesourcery.com
|
||||
E: jroelofS@jroelofs.com
|
||||
D: Remote testing, Newlib port, baremetal/single-threaded support.
|
||||
|
||||
N: Jonathan Sauer
|
||||
|
||||
@@ -9,7 +9,7 @@ cd C:\projects\deps
|
||||
:: Setup Compiler
|
||||
::###########################################################################
|
||||
if NOT EXIST llvm-installer.exe (
|
||||
appveyor DownloadFile http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r303050-win32.exe -FileName llvm-installer.exe
|
||||
appveyor DownloadFile http://prereleases.llvm.org/win-snapshots/LLVM-6.0.0-r316086-win32.exe -FileName llvm-installer.exe
|
||||
)
|
||||
if "%CLANG_VERSION%"=="ToT" (
|
||||
START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"
|
||||
|
||||
@@ -59,6 +59,7 @@ if (LIBCXX_BENCHMARK_NATIVE_STDLIB)
|
||||
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF)
|
||||
endif()
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# Benchmark tests configuration
|
||||
#==============================================================================
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
namespace ContainerBenchmarks {
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
#include "GenerateInput.hpp"
|
||||
|
||||
constexpr std::size_t TestNumInputs = 1024;
|
||||
@@ -59,4 +59,4 @@ BENCHMARK_CAPTURE(BM_Sort, single_element_strings,
|
||||
getDuplicateStringInputs)->Arg(TestNumInputs);
|
||||
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <experimental/filesystem>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
#include "GenerateInput.hpp"
|
||||
#include "test_iterators.h"
|
||||
|
||||
@@ -135,4 +135,4 @@ void BM_PathIterateOnceBackwards(benchmark::State &st, GenInputs gen) {
|
||||
BENCHMARK_CAPTURE(BM_PathIterateOnceBackwards, iterate_elements,
|
||||
getRandomStringInputs)->Arg(TestNumInputs);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
#include "GenerateInput.hpp"
|
||||
|
||||
constexpr std::size_t MAX_STRING_LEN = 8 << 14;
|
||||
@@ -46,4 +46,4 @@ static void BM_StringFindMatch2(benchmark::State &state) {
|
||||
}
|
||||
BENCHMARK(BM_StringFindMatch2)->Range(1, MAX_STRING_LEN / 4);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
38
benchmarks/stringstream.bench.cpp
Normal file
38
benchmarks/stringstream.bench.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
#include <sstream>
|
||||
double __attribute__((noinline)) istream_numbers();
|
||||
|
||||
double istream_numbers() {
|
||||
const char *a[] = {
|
||||
"-6 69 -71 2.4882e-02 -100 101 -2.00005 5000000 -50000000",
|
||||
"-25 71 7 -9.3262e+01 -100 101 -2.00005 5000000 -50000000",
|
||||
"-14 53 46 -6.7026e-02 -100 101 -2.00005 5000000 -50000000"
|
||||
};
|
||||
|
||||
int a1, a2, a3, a4, a5, a6, a7;
|
||||
double f1 = 0.0, f2 = 0.0, q = 0.0;
|
||||
for (int i=0; i < 3; i++) {
|
||||
std::istringstream s(a[i]);
|
||||
s >> a1
|
||||
>> a2
|
||||
>> a3
|
||||
>> f1
|
||||
>> a4
|
||||
>> a5
|
||||
>> f2
|
||||
>> a6
|
||||
>> a7;
|
||||
q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2)/1000000;
|
||||
}
|
||||
return q;
|
||||
}
|
||||
|
||||
static void BM_Istream_numbers(benchmark::State &state) {
|
||||
double i = 0;
|
||||
while (state.KeepRunning())
|
||||
benchmark::DoNotOptimize(i += istream_numbers());
|
||||
}
|
||||
|
||||
BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
|
||||
BENCHMARK_MAIN();
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
#include "ContainerBenchmarks.hpp"
|
||||
#include "GenerateInput.hpp"
|
||||
@@ -303,4 +303,4 @@ BENCHMARK_CAPTURE(BM_EmplaceDuplicate,
|
||||
std::unordered_set<std::string>{},
|
||||
getRandomCStringInputs)->Arg(TestNumInputs);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
|
||||
static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
|
||||
while (st.KeepRunning()) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_SharedPtrCreateDestroy);
|
||||
|
||||
static void BM_SharedPtrIncDecRef(benchmark::State& st) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
while (st.KeepRunning()) {
|
||||
std::shared_ptr<int> sp2(sp);
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_SharedPtrIncDecRef);
|
||||
|
||||
static void BM_WeakPtrIncDecRef(benchmark::State& st) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
while (st.KeepRunning()) {
|
||||
std::weak_ptr<int> wp(sp);
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_WeakPtrIncDecRef);
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
|
||||
while (st.KeepRunning()) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_SharedPtrCreateDestroy);
|
||||
|
||||
static void BM_SharedPtrIncDecRef(benchmark::State& st) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
while (st.KeepRunning()) {
|
||||
std::shared_ptr<int> sp2(sp);
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_SharedPtrIncDecRef);
|
||||
|
||||
static void BM_WeakPtrIncDecRef(benchmark::State& st) {
|
||||
auto sp = std::make_shared<int>(42);
|
||||
benchmark::DoNotOptimize(sp.get());
|
||||
while (st.KeepRunning()) {
|
||||
std::weak_ptr<int> wp(sp);
|
||||
benchmark::ClobberMemory();
|
||||
}
|
||||
}
|
||||
BENCHMARK(BM_WeakPtrIncDecRef);
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
|
||||
#include "ContainerBenchmarks.hpp"
|
||||
#include "GenerateInput.hpp"
|
||||
@@ -29,4 +29,4 @@ BENCHMARK_CAPTURE(BM_ConstructIterIter,
|
||||
getRandomStringInputs)->Arg(TestNumInputs);
|
||||
|
||||
|
||||
BENCHMARK_MAIN()
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
@@ -9,7 +9,7 @@ INCLUDE(CheckCXXSourceCompiles)
|
||||
|
||||
function(check_cxx_atomics varname)
|
||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS "-nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs -std=c++11 -nostdinc++ -isystem ${LIBCXX_SOURCE_DIR}/include")
|
||||
if (${LIBCXX_GCC_TOOLCHAIN})
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} --gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
@@ -55,8 +55,8 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
|
||||
)
|
||||
if (LIBCXX_INSTALL_HEADERS)
|
||||
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
|
||||
DESTINATION include/c++/v1/${dstdir}
|
||||
COMPONENT libcxx
|
||||
DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
|
||||
COMPONENT cxx-headers
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -106,14 +106,22 @@ macro(configure_out_of_tree_llvm)
|
||||
set(LLVM_ENABLE_SPHINX OFF)
|
||||
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")
|
||||
# In a standalone build, we don't have llvm to automatically generate the
|
||||
# llvm-lit script for us. So we need to provide an explicit directory that
|
||||
# the configurator should write the script into.
|
||||
set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
|
||||
|
||||
if (LLVM_INCLUDE_TESTS)
|
||||
# Required LIT Configuration ------------------------------------------------
|
||||
# Define the default arguments to use with 'lit', and an option for the user
|
||||
# to override.
|
||||
set(LLVM_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
|
||||
set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
|
||||
if (MSVC OR XCODE)
|
||||
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
||||
endif()
|
||||
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
||||
endif()
|
||||
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
||||
|
||||
# Required doc configuration
|
||||
if (LLVM_ENABLE_SPHINX)
|
||||
|
||||
@@ -130,7 +130,7 @@ just specify a toolset.
|
||||
-DCMAKE_SYSTEM_NAME=Windows ^
|
||||
-DCMAKE_C_COMPILER=clang-cl ^
|
||||
-DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^
|
||||
-DCMAKE_CXX_COMPILER=clang-c ^
|
||||
-DCMAKE_CXX_COMPILER=clang-cl ^
|
||||
-DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^
|
||||
-DLLVM_PATH=/path/to/llvm/tree ^
|
||||
-DLIBCXX_ENABLE_SHARED=YES ^
|
||||
@@ -216,6 +216,11 @@ libc++ specific options
|
||||
Extra suffix to append to the directory where libraries are to be installed.
|
||||
This option overrides `LLVM_LIBDIR_SUFFIX`.
|
||||
|
||||
.. option:: LIBCXX_INSTALL_PREFIX:STRING
|
||||
|
||||
**Default**: ``""``
|
||||
|
||||
Define libc++ destination prefix.
|
||||
|
||||
.. _libc++experimental options:
|
||||
|
||||
@@ -342,6 +347,13 @@ The following options allow building libc++ for a different ABI version.
|
||||
Build the "unstable" ABI version of libc++. Includes all ABI changing features
|
||||
on top of the current stable version.
|
||||
|
||||
.. option:: LIBCXX_ABI_DEFINES:STRING
|
||||
|
||||
**Default**: ``""``
|
||||
|
||||
A semicolon-separated list of ABI macros to persist in the site config header.
|
||||
See ``include/__config`` for the list of ABI macros.
|
||||
|
||||
.. _LLVM-specific variables:
|
||||
|
||||
LLVM-specific options
|
||||
|
||||
@@ -66,6 +66,10 @@ Threading Configuration Macros
|
||||
This macro is defined when libc++ should use POSIX threads to implement the
|
||||
internal threading API.
|
||||
|
||||
**_LIBCPP_HAS_THREAD_API_WIN32**
|
||||
This macro is defined when libc++ should use Win32 threads to implement the
|
||||
internal threading API.
|
||||
|
||||
**_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL**
|
||||
This macro is defined when libc++ expects the definitions of the internal
|
||||
threading API to be provided by an external library. When defined
|
||||
|
||||
@@ -90,20 +90,21 @@ Visibility Macros
|
||||
The macro has an empty definition with GCC.
|
||||
|
||||
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
|
||||
incompatible *on a template class* on Windows; the former suppresses
|
||||
incompatible *on a class template* on Windows; the former suppresses
|
||||
instantiation, while the latter forces it. Specifying both on the same
|
||||
declaration makes the template class be instantiated, which is not desirable
|
||||
declaration makes the class template be instantiated, which is not desirable
|
||||
inside headers. This macro therefore expands to `dllimport` outside of libc++
|
||||
but nothing inside of it (rather than expanding to `dllexport`); instead, the
|
||||
explicit instantiations themselves are marked as exported. Note that this
|
||||
applies *only* to extern template *classes*. Extern template *functions* obey
|
||||
applies *only* to extern *class* templates. Extern *function* templates obey
|
||||
regular import/export semantics, and applying `dllexport` directly to the
|
||||
extern template declaration is the correct thing to do for them.
|
||||
extern template declaration (i.e. using `_LIBCPP_FUNC_VIS`) is the correct
|
||||
thing to do for them.
|
||||
|
||||
**_LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS**
|
||||
Mark the member functions, typeinfo, and vtable of an explicit instantiation
|
||||
of a class template as being exported by the libc++ library. This attribute
|
||||
must be specified on all template class explicit instantiations.
|
||||
must be specified on all class template explicit instantiations.
|
||||
|
||||
It is only necessary to mark the explicit instantiation itself (as opposed to
|
||||
the extern template declaration) as exported on Windows, as discussed above.
|
||||
|
||||
@@ -112,7 +112,7 @@ configuration. Passing the option on the command line will override the default.
|
||||
|
||||
.. option:: std=<standard version>
|
||||
|
||||
**Values**: c++98, c++03, c++11, c++14, c++1z
|
||||
**Values**: c++98, c++03, c++11, c++14, c++17, c++2a
|
||||
|
||||
Change the standard version used when building the tests.
|
||||
|
||||
|
||||
@@ -185,6 +185,26 @@ thread safety annotations.
|
||||
* Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
|
||||
const callable.
|
||||
|
||||
**_LIBCPP_NO_VCRUNTIME**:
|
||||
Microsoft's C and C++ headers are fairly entangled, and some of their C++
|
||||
headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets pulled
|
||||
in from a lot of other headers and provides definitions which clash with
|
||||
libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
|
||||
there's no way for libc++ to provide a compatible definition, since you can't
|
||||
have multiple definitions).
|
||||
|
||||
By default, libc++ solves this problem by deferring to Microsoft's vcruntime
|
||||
headers where needed. However, it may be undesirable to depend on vcruntime
|
||||
headers, since they may not always be available in cross-compilation setups,
|
||||
or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
|
||||
prevents libc++ from depending on vcruntime headers. Consequently, it also
|
||||
prevents libc++ headers from being interoperable with vcruntime headers (from
|
||||
the aforementioned clashes), so users of this macro are promising to not
|
||||
attempt to combine libc++ headers with the problematic vcruntime headers. This
|
||||
macro also currently prevents certain `operator new`/`operator delete`
|
||||
replacement scenarios from working, e.g. replacing `operator new` and
|
||||
expecting a non-replaced `operator new[]` to call the replaced `operator new`.
|
||||
|
||||
C++17 Specific Configuration Macros
|
||||
-----------------------------------
|
||||
**_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
|
||||
|
||||
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '5.0'
|
||||
version = '7.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '5.0'
|
||||
release = '7.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
20
fuzzing/RoutineNames.txt
Normal file
20
fuzzing/RoutineNames.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
sort
|
||||
stable_sort
|
||||
partition
|
||||
partition_copy
|
||||
stable_partition
|
||||
unique
|
||||
unique_copy
|
||||
nth_element
|
||||
partial_sort
|
||||
partial_sort_copy
|
||||
make_heap
|
||||
push_heap
|
||||
pop_heap
|
||||
regex_ECMAScript
|
||||
regex_POSIX
|
||||
regex_extended
|
||||
regex_awk
|
||||
regex_grep
|
||||
regex_egrep
|
||||
search
|
||||
195
fuzzing/fuzz_test.cpp
Normal file
195
fuzzing/fuzz_test.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- fuzz_test.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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// A simple program for running regressions on the fuzzing routines.
|
||||
// This code is not part of any shipping product.
|
||||
//
|
||||
// To build:
|
||||
// clang++ -std=c++11 fuzz_test.cpp fuzzing.cpp
|
||||
//
|
||||
// To use:
|
||||
// fuzz_test -r partial_sort [-v] files...
|
||||
//
|
||||
// Each file should contain a test case.
|
||||
|
||||
// TODO: should add some memory tracking, too.
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <chrono>
|
||||
|
||||
#include "fuzzing.h"
|
||||
|
||||
// ==== Count memory allocations ====
|
||||
|
||||
struct MemoryCounters {
|
||||
size_t totalAllocationCount;
|
||||
size_t netAllocationCount;
|
||||
size_t totalBytesAllocated;
|
||||
};
|
||||
|
||||
MemoryCounters gMemoryCounters;
|
||||
|
||||
void ZeroMemoryCounters() {
|
||||
gMemoryCounters.totalAllocationCount = 0;
|
||||
gMemoryCounters.netAllocationCount = 0;
|
||||
gMemoryCounters.totalBytesAllocated = 0;
|
||||
}
|
||||
|
||||
void* operator new(std::size_t size)
|
||||
{
|
||||
if (size == 0) size = 1;
|
||||
void *p = ::malloc(size);
|
||||
if (p == NULL)
|
||||
throw std::bad_alloc();
|
||||
gMemoryCounters.totalAllocationCount += 1;
|
||||
gMemoryCounters.netAllocationCount += 1;
|
||||
gMemoryCounters.totalBytesAllocated += size;
|
||||
return p;
|
||||
}
|
||||
|
||||
void* operator new(std::size_t size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
try { return operator new(size); }
|
||||
catch (const std::bad_alloc &) {}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* operator new[](std::size_t size)
|
||||
{
|
||||
return ::operator new(size);
|
||||
}
|
||||
|
||||
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
try { return operator new(size); }
|
||||
catch (const std::bad_alloc &) {}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void operator delete(void* ptr) noexcept
|
||||
{
|
||||
if (ptr)
|
||||
::free(ptr);
|
||||
gMemoryCounters.netAllocationCount -= 1;
|
||||
}
|
||||
|
||||
void operator delete(void* ptr, const std::nothrow_t&) noexcept
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr) noexcept
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
void operator delete[](void* ptr, const std::nothrow_t&) noexcept
|
||||
{
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
// ==== End count memory allocations ====
|
||||
|
||||
|
||||
typedef int (*FuzzProc) (const uint8_t *data, size_t size);
|
||||
|
||||
const std::map<std::string, FuzzProc> procs = {
|
||||
{"sort", fuzzing::sort},
|
||||
{"stable_sort", fuzzing::stable_sort},
|
||||
{"partition", fuzzing::partition},
|
||||
{"partition_copy", fuzzing::partition_copy},
|
||||
{"stable_partition", fuzzing::stable_partition},
|
||||
{"unique", fuzzing::unique},
|
||||
{"unique_copy", fuzzing::unique_copy},
|
||||
{"nth_element", fuzzing::nth_element},
|
||||
{"partial_sort", fuzzing::partial_sort},
|
||||
{"partial_sort_copy", fuzzing::partial_sort_copy},
|
||||
{"make_heap", fuzzing::make_heap},
|
||||
{"push_heap", fuzzing::push_heap},
|
||||
{"pop_heap", fuzzing::pop_heap},
|
||||
{"regex_ECMAScript", fuzzing::regex_ECMAScript},
|
||||
{"regex_POSIX", fuzzing::regex_POSIX},
|
||||
{"regex_extended", fuzzing::regex_extended},
|
||||
{"regex_awk", fuzzing::regex_awk},
|
||||
{"regex_grep", fuzzing::regex_grep},
|
||||
{"regex_egrep", fuzzing::regex_egrep},
|
||||
{"search", fuzzing::search}
|
||||
};
|
||||
|
||||
|
||||
|
||||
bool verbose = false;
|
||||
|
||||
void test_one(const char *filename, FuzzProc fp)
|
||||
{
|
||||
std::vector<uint8_t> v;
|
||||
std::ifstream f (filename, std::ios::binary);
|
||||
if (!f.is_open())
|
||||
std::cerr << "## Can't open '" << filename << "'" << std::endl;
|
||||
else
|
||||
{
|
||||
typedef std::istream_iterator<uint8_t> Iter;
|
||||
std::copy(Iter(f), Iter(), std::back_inserter(v));
|
||||
if (verbose)
|
||||
std::cout << "File '" << filename << "' contains " << v.size() << " entries" << std::endl;
|
||||
ZeroMemoryCounters();
|
||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||
int ret = fp (v.data(), v.size());
|
||||
const auto finish_time = std::chrono::high_resolution_clock::now();
|
||||
MemoryCounters mc = gMemoryCounters;
|
||||
if (ret != 0)
|
||||
std::cerr << "## Failure code: " << ret << std::endl;
|
||||
if (verbose)
|
||||
{
|
||||
std::cout << "Execution time: "
|
||||
<< std::chrono::duration_cast<std::chrono::milliseconds>(finish_time - start_time).count()
|
||||
<< " milliseconds" << std::endl;
|
||||
std::cout << "Memory: "
|
||||
<< mc.totalBytesAllocated << " bytes allocated ("
|
||||
<< mc.totalAllocationCount << " allocations); "
|
||||
<< mc.netAllocationCount << " allocations remain" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usage (const char *name)
|
||||
{
|
||||
std::cout << "Usage: " << name << " -r proc [-v] files..." << std::endl;
|
||||
std::cout << "Supported routines:" << std::endl;
|
||||
for (const auto &p : procs)
|
||||
std::cout << " " << p.first << std::endl;
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
// Poor man's command-line options
|
||||
const std::string dashR("-r");
|
||||
const std::string dashV("-v");
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 4 || dashR != argv[1] || procs.find(argv[2]) == procs.end())
|
||||
usage(argv[0]);
|
||||
else {
|
||||
FuzzProc fp = procs.find(argv[2])->second;
|
||||
int firstFile = 3;
|
||||
if (dashV == argv[firstFile])
|
||||
{
|
||||
verbose = true;
|
||||
++firstFile;
|
||||
}
|
||||
for (int i = firstFile; i < argc; ++i)
|
||||
test_one(argv[i], fp);
|
||||
}
|
||||
}
|
||||
605
fuzzing/fuzzing.cpp
Normal file
605
fuzzing/fuzzing.cpp
Normal file
@@ -0,0 +1,605 @@
|
||||
// -*- C++ -*-
|
||||
//===------------------------- fuzzing.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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// A set of routines to use when fuzzing the algorithms in libc++
|
||||
// Each one tests a single algorithm.
|
||||
//
|
||||
// They all have the form of:
|
||||
// int `algorithm`(const uint8_t *data, size_t size);
|
||||
//
|
||||
// They perform the operation, and then check to see if the results are correct.
|
||||
// If so, they return zero, and non-zero otherwise.
|
||||
//
|
||||
// For example, sort calls std::sort, then checks two things:
|
||||
// (1) The resulting vector is sorted
|
||||
// (2) The resulting vector contains the same elements as the original data.
|
||||
|
||||
|
||||
|
||||
#include "fuzzing.h"
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <regex>
|
||||
#include <cassert>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// If we had C++14, we could use the four iterator version of is_permutation and equal
|
||||
|
||||
namespace fuzzing {
|
||||
|
||||
// This is a struct we can use to test the stable_XXX algorithms.
|
||||
// perform the operation on the key, then check the order of the payload.
|
||||
|
||||
struct stable_test {
|
||||
uint8_t key;
|
||||
size_t payload;
|
||||
|
||||
stable_test(uint8_t k) : key(k), payload(0) {}
|
||||
stable_test(uint8_t k, size_t p) : key(k), payload(p) {}
|
||||
};
|
||||
|
||||
void swap(stable_test &lhs, stable_test &rhs)
|
||||
{
|
||||
using std::swap;
|
||||
swap(lhs.key, rhs.key);
|
||||
swap(lhs.payload, rhs.payload);
|
||||
}
|
||||
|
||||
struct key_less
|
||||
{
|
||||
bool operator () (const stable_test &lhs, const stable_test &rhs) const
|
||||
{
|
||||
return lhs.key < rhs.key;
|
||||
}
|
||||
};
|
||||
|
||||
struct payload_less
|
||||
{
|
||||
bool operator () (const stable_test &lhs, const stable_test &rhs) const
|
||||
{
|
||||
return lhs.payload < rhs.payload;
|
||||
}
|
||||
};
|
||||
|
||||
struct total_less
|
||||
{
|
||||
bool operator () (const stable_test &lhs, const stable_test &rhs) const
|
||||
{
|
||||
return lhs.key == rhs.key ? lhs.payload < rhs.payload : lhs.key < rhs.key;
|
||||
}
|
||||
};
|
||||
|
||||
bool operator==(const stable_test &lhs, const stable_test &rhs)
|
||||
{
|
||||
return lhs.key == rhs.key && lhs.payload == rhs.payload;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct is_even
|
||||
{
|
||||
bool operator () (const T &t) const
|
||||
{
|
||||
return t % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct is_even<stable_test>
|
||||
{
|
||||
bool operator () (const stable_test &t) const
|
||||
{
|
||||
return t.key % 2 == 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<uint8_t> Vec;
|
||||
typedef std::vector<stable_test> StableVec;
|
||||
typedef StableVec::const_iterator SVIter;
|
||||
|
||||
// Cheap version of is_permutation
|
||||
// Builds a set of buckets for each of the key values.
|
||||
// Sums all the payloads.
|
||||
// Not 100% perfect, but _way_ faster
|
||||
bool is_permutation(SVIter first1, SVIter last1, SVIter first2)
|
||||
{
|
||||
size_t xBuckets[256] = {0};
|
||||
size_t xPayloads[256] = {0};
|
||||
size_t yBuckets[256] = {0};
|
||||
size_t yPayloads[256] = {0};
|
||||
|
||||
for (; first1 != last1; ++first1, ++first2)
|
||||
{
|
||||
xBuckets [first1->key]++;
|
||||
xPayloads[first1->key] += first1->payload;
|
||||
|
||||
yBuckets [first2->key]++;
|
||||
yPayloads[first2->key] += first2->payload;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 256; ++i)
|
||||
{
|
||||
if (xBuckets[i] != yBuckets[i])
|
||||
return false;
|
||||
if (xPayloads[i] != yPayloads[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Iter1, typename Iter2>
|
||||
bool is_permutation(Iter1 first1, Iter1 last1, Iter2 first2)
|
||||
{
|
||||
static_assert((std::is_same<typename std::iterator_traits<Iter1>::value_type, uint8_t>::value), "");
|
||||
static_assert((std::is_same<typename std::iterator_traits<Iter2>::value_type, uint8_t>::value), "");
|
||||
|
||||
size_t xBuckets[256] = {0};
|
||||
size_t yBuckets[256] = {0};
|
||||
|
||||
for (; first1 != last1; ++first1, ++first2)
|
||||
{
|
||||
xBuckets [*first1]++;
|
||||
yBuckets [*first2]++;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 256; ++i)
|
||||
if (xBuckets[i] != yBuckets[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// == sort ==
|
||||
int sort(const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec working(data, data + size);
|
||||
std::sort(working.begin(), working.end());
|
||||
|
||||
if (!std::is_sorted(working.begin(), working.end())) return 1;
|
||||
if (!fuzzing::is_permutation(data, data + size, working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// == stable_sort ==
|
||||
int stable_sort(const uint8_t *data, size_t size)
|
||||
{
|
||||
StableVec input;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
input.push_back(stable_test(data[i], i));
|
||||
StableVec working = input;
|
||||
std::stable_sort(working.begin(), working.end(), key_less());
|
||||
|
||||
if (!std::is_sorted(working.begin(), working.end(), key_less())) return 1;
|
||||
auto iter = working.begin();
|
||||
while (iter != working.end())
|
||||
{
|
||||
auto range = std::equal_range(iter, working.end(), *iter, key_less());
|
||||
if (!std::is_sorted(range.first, range.second, total_less())) return 2;
|
||||
iter = range.second;
|
||||
}
|
||||
if (!fuzzing::is_permutation(input.cbegin(), input.cend(), working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// == partition ==
|
||||
int partition(const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec working(data, data + size);
|
||||
auto iter = std::partition(working.begin(), working.end(), is_even<uint8_t>());
|
||||
|
||||
if (!std::all_of (working.begin(), iter, is_even<uint8_t>())) return 1;
|
||||
if (!std::none_of(iter, working.end(), is_even<uint8_t>())) return 2;
|
||||
if (!fuzzing::is_permutation(data, data + size, working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// == partition_copy ==
|
||||
int partition_copy(const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec v1, v2;
|
||||
auto iter = std::partition_copy(data, data + size,
|
||||
std::back_inserter<Vec>(v1), std::back_inserter<Vec>(v2),
|
||||
is_even<uint8_t>());
|
||||
|
||||
// The two vectors should add up to the original size
|
||||
if (v1.size() + v2.size() != size) return 1;
|
||||
|
||||
// All of the even values should be in the first vector, and none in the second
|
||||
if (!std::all_of (v1.begin(), v1.end(), is_even<uint8_t>())) return 2;
|
||||
if (!std::none_of(v2.begin(), v2.end(), is_even<uint8_t>())) return 3;
|
||||
|
||||
// Every value in both vectors has to be in the original
|
||||
for (auto v: v1)
|
||||
if (std::find(data, data + size, v) == data + size) return 4;
|
||||
|
||||
for (auto v: v2)
|
||||
if (std::find(data, data + size, v) == data + size) return 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// == stable_partition ==
|
||||
int stable_partition (const uint8_t *data, size_t size)
|
||||
{
|
||||
StableVec input;
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
input.push_back(stable_test(data[i], i));
|
||||
StableVec working = input;
|
||||
auto iter = std::stable_partition(working.begin(), working.end(), is_even<stable_test>());
|
||||
|
||||
if (!std::all_of (working.begin(), iter, is_even<stable_test>())) return 1;
|
||||
if (!std::none_of(iter, working.end(), is_even<stable_test>())) return 2;
|
||||
if (!std::is_sorted(working.begin(), iter, payload_less())) return 3;
|
||||
if (!std::is_sorted(iter, working.end(), payload_less())) return 4;
|
||||
if (!fuzzing::is_permutation(input.cbegin(), input.cend(), working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// == nth_element ==
|
||||
// use the first element as a position into the data
|
||||
int nth_element (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size <= 1) return 0;
|
||||
const size_t partition_point = data[0] % size;
|
||||
Vec working(data + 1, data + size);
|
||||
const auto partition_iter = working.begin() + partition_point;
|
||||
std::nth_element(working.begin(), partition_iter, working.end());
|
||||
|
||||
// nth may be the end iterator, in this case nth_element has no effect.
|
||||
if (partition_iter == working.end())
|
||||
{
|
||||
if (!std::equal(data + 1, data + size, working.begin())) return 98;
|
||||
}
|
||||
else
|
||||
{
|
||||
const uint8_t nth = *partition_iter;
|
||||
if (!std::all_of(working.begin(), partition_iter, [=](uint8_t v) { return v <= nth; }))
|
||||
return 1;
|
||||
if (!std::all_of(partition_iter, working.end(), [=](uint8_t v) { return v >= nth; }))
|
||||
return 2;
|
||||
if (!fuzzing::is_permutation(data + 1, data + size, working.cbegin())) return 99;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// == partial_sort ==
|
||||
// use the first element as a position into the data
|
||||
int partial_sort (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size <= 1) return 0;
|
||||
const size_t sort_point = data[0] % size;
|
||||
Vec working(data + 1, data + size);
|
||||
const auto sort_iter = working.begin() + sort_point;
|
||||
std::partial_sort(working.begin(), sort_iter, working.end());
|
||||
|
||||
if (sort_iter != working.end())
|
||||
{
|
||||
const uint8_t nth = *std::min_element(sort_iter, working.end());
|
||||
if (!std::all_of(working.begin(), sort_iter, [=](uint8_t v) { return v <= nth; }))
|
||||
return 1;
|
||||
if (!std::all_of(sort_iter, working.end(), [=](uint8_t v) { return v >= nth; }))
|
||||
return 2;
|
||||
}
|
||||
if (!std::is_sorted(working.begin(), sort_iter)) return 3;
|
||||
if (!fuzzing::is_permutation(data + 1, data + size, working.cbegin())) return 99;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// == partial_sort_copy ==
|
||||
// use the first element as a count
|
||||
int partial_sort_copy (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size <= 1) return 0;
|
||||
const size_t num_results = data[0] % size;
|
||||
Vec results(num_results);
|
||||
(void) std::partial_sort_copy(data + 1, data + size, results.begin(), results.end());
|
||||
|
||||
// The results have to be sorted
|
||||
if (!std::is_sorted(results.begin(), results.end())) return 1;
|
||||
// All the values in results have to be in the original data
|
||||
for (auto v: results)
|
||||
if (std::find(data + 1, data + size, v) == data + size) return 2;
|
||||
|
||||
// The things in results have to be the smallest N in the original data
|
||||
Vec sorted(data + 1, data + size);
|
||||
std::sort(sorted.begin(), sorted.end());
|
||||
if (!std::equal(results.begin(), results.end(), sorted.begin())) return 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// The second sequence has been "uniqued"
|
||||
template <typename Iter1, typename Iter2>
|
||||
static bool compare_unique(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2)
|
||||
{
|
||||
assert(first1 != last1 && first2 != last2);
|
||||
if (*first1 != *first2) return false;
|
||||
|
||||
uint8_t last_value = *first1;
|
||||
++first1; ++first2;
|
||||
while(first1 != last1 && first2 != last2)
|
||||
{
|
||||
// Skip over dups in the first sequence
|
||||
while (*first1 == last_value)
|
||||
if (++first1 == last1) return false;
|
||||
if (*first1 != *first2) return false;
|
||||
last_value = *first1;
|
||||
++first1; ++first2;
|
||||
}
|
||||
|
||||
// Still stuff left in the 'uniqued' sequence - oops
|
||||
if (first1 == last1 && first2 != last2) return false;
|
||||
|
||||
// Still stuff left in the original sequence - better be all the same
|
||||
while (first1 != last1)
|
||||
{
|
||||
if (*first1 != last_value) return false;
|
||||
++first1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// == unique ==
|
||||
int unique (const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec working(data, data + size);
|
||||
std::sort(working.begin(), working.end());
|
||||
Vec results = working;
|
||||
Vec::iterator new_end = std::unique(results.begin(), results.end());
|
||||
Vec::iterator it; // scratch iterator
|
||||
|
||||
// Check the size of the unique'd sequence.
|
||||
// it should only be zero if the input sequence was empty.
|
||||
if (results.begin() == new_end)
|
||||
return working.size() == 0 ? 0 : 1;
|
||||
|
||||
// 'results' is sorted
|
||||
if (!std::is_sorted(results.begin(), new_end)) return 2;
|
||||
|
||||
// All the elements in 'results' must be different
|
||||
it = results.begin();
|
||||
uint8_t prev_value = *it++;
|
||||
for (; it != new_end; ++it)
|
||||
{
|
||||
if (*it == prev_value) return 3;
|
||||
prev_value = *it;
|
||||
}
|
||||
|
||||
// Every element in 'results' must be in 'working'
|
||||
for (it = results.begin(); it != new_end; ++it)
|
||||
if (std::find(working.begin(), working.end(), *it) == working.end())
|
||||
return 4;
|
||||
|
||||
// Every element in 'working' must be in 'results'
|
||||
for (auto v : working)
|
||||
if (std::find(results.begin(), new_end, v) == new_end)
|
||||
return 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// == unique_copy ==
|
||||
int unique_copy (const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec working(data, data + size);
|
||||
std::sort(working.begin(), working.end());
|
||||
Vec results;
|
||||
(void) std::unique_copy(working.begin(), working.end(),
|
||||
std::back_inserter<Vec>(results));
|
||||
Vec::iterator it; // scratch iterator
|
||||
|
||||
// Check the size of the unique'd sequence.
|
||||
// it should only be zero if the input sequence was empty.
|
||||
if (results.size() == 0)
|
||||
return working.size() == 0 ? 0 : 1;
|
||||
|
||||
// 'results' is sorted
|
||||
if (!std::is_sorted(results.begin(), results.end())) return 2;
|
||||
|
||||
// All the elements in 'results' must be different
|
||||
it = results.begin();
|
||||
uint8_t prev_value = *it++;
|
||||
for (; it != results.end(); ++it)
|
||||
{
|
||||
if (*it == prev_value) return 3;
|
||||
prev_value = *it;
|
||||
}
|
||||
|
||||
// Every element in 'results' must be in 'working'
|
||||
for (auto v : results)
|
||||
if (std::find(working.begin(), working.end(), v) == working.end())
|
||||
return 4;
|
||||
|
||||
// Every element in 'working' must be in 'results'
|
||||
for (auto v : working)
|
||||
if (std::find(results.begin(), results.end(), v) == results.end())
|
||||
return 5;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// -- regex fuzzers
|
||||
static int regex_helper(const uint8_t *data, size_t size, std::regex::flag_type flag)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string s((const char *)data, size);
|
||||
std::regex re(s, flag);
|
||||
return std::regex_match(s, re) ? 1 : 0;
|
||||
}
|
||||
catch (std::regex_error &ex) {}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int regex_ECMAScript (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::ECMAScript);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regex_POSIX (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::basic);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regex_extended (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::extended);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regex_awk (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::awk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regex_grep (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::grep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int regex_egrep (const uint8_t *data, size_t size)
|
||||
{
|
||||
(void) regex_helper(data, size, std::regex_constants::egrep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -- heap fuzzers
|
||||
int make_heap (const uint8_t *data, size_t size)
|
||||
{
|
||||
Vec working(data, data + size);
|
||||
std::make_heap(working.begin(), working.end());
|
||||
|
||||
if (!std::is_heap(working.begin(), working.end())) return 1;
|
||||
if (!fuzzing::is_permutation(data, data + size, working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int push_heap (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < 2) return 0;
|
||||
|
||||
// Make a heap from the first half of the data
|
||||
Vec working(data, data + size);
|
||||
auto iter = working.begin() + (size / 2);
|
||||
std::make_heap(working.begin(), iter);
|
||||
if (!std::is_heap(working.begin(), iter)) return 1;
|
||||
|
||||
// Now push the rest onto the heap, one at a time
|
||||
++iter;
|
||||
for (; iter != working.end(); ++iter) {
|
||||
std::push_heap(working.begin(), iter);
|
||||
if (!std::is_heap(working.begin(), iter)) return 2;
|
||||
}
|
||||
|
||||
if (!fuzzing::is_permutation(data, data + size, working.cbegin())) return 99;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pop_heap (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < 2) return 0;
|
||||
Vec working(data, data + size);
|
||||
std::make_heap(working.begin(), working.end());
|
||||
|
||||
// Pop things off, one at a time
|
||||
auto iter = --working.end();
|
||||
while (iter != working.begin()) {
|
||||
std::pop_heap(working.begin(), iter);
|
||||
if (!std::is_heap(working.begin(), --iter)) return 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// -- search fuzzers
|
||||
int search (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < 2) return 0;
|
||||
|
||||
const size_t pat_size = data[0] * (size - 1) / std::numeric_limits<uint8_t>::max();
|
||||
assert(pat_size <= size - 1);
|
||||
const uint8_t *pat_begin = data + 1;
|
||||
const uint8_t *pat_end = pat_begin + pat_size;
|
||||
const uint8_t *data_end = data + size;
|
||||
assert(pat_end <= data_end);
|
||||
// std::cerr << "data[0] = " << size_t(data[0]) << " ";
|
||||
// std::cerr << "Pattern size = " << pat_size << "; corpus is " << size - 1 << std::endl;
|
||||
auto it = std::search(pat_end, data_end, pat_begin, pat_end);
|
||||
if (it != data_end) // not found
|
||||
if (!std::equal(pat_begin, pat_end, it))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static int search_helper (const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < 2) return 0;
|
||||
|
||||
const size_t pat_size = data[0] * (size - 1) / std::numeric_limits<uint8_t>::max();
|
||||
const uint8_t *pat_begin = data + 1;
|
||||
const uint8_t *pat_end = pat_begin + pat_size;
|
||||
const uint8_t *data_end = data + size;
|
||||
|
||||
auto it = std::search(pat_end, data_end, S(pat_begin, pat_end));
|
||||
if (it != data_end) // not found
|
||||
if (!std::equal(pat_begin, pat_end, it))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// These are still in std::experimental
|
||||
// int search_boyer_moore (const uint8_t *data, size_t size)
|
||||
// {
|
||||
// return search_helper<std::boyer_moore_searcher<const uint8_t *>>(data, size);
|
||||
// }
|
||||
//
|
||||
// int search_boyer_moore_horspool (const uint8_t *data, size_t size)
|
||||
// {
|
||||
// return search_helper<std::boyer_moore_horspool_searcher<const uint8_t *>>(data, size);
|
||||
// }
|
||||
|
||||
|
||||
// -- set operation fuzzers
|
||||
template <typename S>
|
||||
static void set_helper (const uint8_t *data, size_t size, Vec &v1, Vec &v2)
|
||||
{
|
||||
assert(size > 1);
|
||||
|
||||
const size_t pat_size = data[0] * (size - 1) / std::numeric_limits<uint8_t>::max();
|
||||
const uint8_t *pat_begin = data + 1;
|
||||
const uint8_t *pat_end = pat_begin + pat_size;
|
||||
const uint8_t *data_end = data + size;
|
||||
v1.assign(pat_begin, pat_end);
|
||||
v2.assign(pat_end, data_end);
|
||||
|
||||
std::sort(v1.begin(), v1.end());
|
||||
std::sort(v2.begin(), v2.end());
|
||||
}
|
||||
|
||||
} // namespace fuzzing
|
||||
62
fuzzing/fuzzing.h
Normal file
62
fuzzing/fuzzing.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// -*- C++ -*-
|
||||
//===-------------------------- fuzzing.h --------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_FUZZING
|
||||
#define _LIBCPP_FUZZING
|
||||
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdint> // for uint8_t
|
||||
|
||||
namespace fuzzing {
|
||||
|
||||
// These all return 0 on success; != 0 on failure
|
||||
int sort (const uint8_t *data, size_t size);
|
||||
int stable_sort (const uint8_t *data, size_t size);
|
||||
int partition (const uint8_t *data, size_t size);
|
||||
int partition_copy (const uint8_t *data, size_t size);
|
||||
int stable_partition (const uint8_t *data, size_t size);
|
||||
int unique (const uint8_t *data, size_t size);
|
||||
int unique_copy (const uint8_t *data, size_t size);
|
||||
|
||||
// partition and stable_partition take Bi-Di iterators.
|
||||
// Should test those, too
|
||||
int nth_element (const uint8_t *data, size_t size);
|
||||
int partial_sort (const uint8_t *data, size_t size);
|
||||
int partial_sort_copy (const uint8_t *data, size_t size);
|
||||
|
||||
// Heap operations
|
||||
int make_heap (const uint8_t *data, size_t size);
|
||||
int push_heap (const uint8_t *data, size_t size);
|
||||
int pop_heap (const uint8_t *data, size_t size);
|
||||
|
||||
// Various flavors of regex
|
||||
int regex_ECMAScript (const uint8_t *data, size_t size);
|
||||
int regex_POSIX (const uint8_t *data, size_t size);
|
||||
int regex_extended (const uint8_t *data, size_t size);
|
||||
int regex_awk (const uint8_t *data, size_t size);
|
||||
int regex_grep (const uint8_t *data, size_t size);
|
||||
int regex_egrep (const uint8_t *data, size_t size);
|
||||
|
||||
// Searching
|
||||
int search (const uint8_t *data, size_t size);
|
||||
// int search_boyer_moore (const uint8_t *data, size_t size);
|
||||
// int search_boyer_moore_horspool (const uint8_t *data, size_t size);
|
||||
|
||||
// Set operations
|
||||
// int includes (const uint8_t *data, size_t size);
|
||||
// int set_union (const uint8_t *data, size_t size);
|
||||
// int set_intersection (const uint8_t *data, size_t size);
|
||||
// int set_difference (const uint8_t *data, size_t size);
|
||||
// int set_symmetric_difference (const uint8_t *data, size_t size);
|
||||
// int merge (const uint8_t *data, size_t size);
|
||||
|
||||
} // namespace fuzzing
|
||||
|
||||
#endif // _LIBCPP_FUZZING
|
||||
@@ -20,7 +20,7 @@ endif()
|
||||
|
||||
if (LIBCXX_INSTALL_HEADERS)
|
||||
install(DIRECTORY .
|
||||
DESTINATION include/c++/v1
|
||||
DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
|
||||
COMPONENT cxx-headers
|
||||
FILES_MATCHING
|
||||
${LIBCXX_HEADER_PATTERN}
|
||||
@@ -44,7 +44,7 @@ if (LIBCXX_INSTALL_HEADERS)
|
||||
set(generated_config_deps generate_config_header)
|
||||
# Install the generated header as __config.
|
||||
install(FILES ${LIBCXX_BINARY_DIR}/__generated_config
|
||||
DESTINATION include/c++/v1
|
||||
DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||
RENAME __config
|
||||
COMPONENT cxx-headers)
|
||||
@@ -58,9 +58,12 @@ if (LIBCXX_INSTALL_HEADERS)
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DCMAKE_INSTALL_COMPONENT=cxx-headers
|
||||
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
||||
# Stripping is a no-op for headers
|
||||
add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
|
||||
|
||||
add_custom_target(libcxx-headers)
|
||||
add_custom_target(install-libcxx-headers DEPENDS install-cxx-headers)
|
||||
add_custom_target(install-libcxx-headers-stripped DEPENDS install-cxx-headers-stripped)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
|
||||
181
include/__config
181
include/__config
@@ -33,7 +33,7 @@
|
||||
#define _GNUC_VER_NEW 0
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_VERSION 5000
|
||||
#define _LIBCPP_VERSION 7000
|
||||
|
||||
#ifndef _LIBCPP_ABI_VERSION
|
||||
#define _LIBCPP_ABI_VERSION 1
|
||||
@@ -45,6 +45,8 @@
|
||||
#define _LIBCPP_OBJECT_FORMAT_MACHO 1
|
||||
#elif defined(_WIN32)
|
||||
#define _LIBCPP_OBJECT_FORMAT_COFF 1
|
||||
#elif defined(__wasm__)
|
||||
#define _LIBCPP_OBJECT_FORMAT_WASM 1
|
||||
#else
|
||||
#error Unknown object file format
|
||||
#endif
|
||||
@@ -55,11 +57,11 @@
|
||||
#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
|
||||
// Fix deque iterator type in order to support incomplete types.
|
||||
#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
|
||||
// Fix undefined behavior in how std::list stores it's linked nodes.
|
||||
// Fix undefined behavior in how std::list stores its linked nodes.
|
||||
#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
|
||||
// Fix undefined behavior in how __tree stores its end and parent nodes.
|
||||
#define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
|
||||
// Fix undefined behavior in how __hash_table stores it's pointer types
|
||||
// Fix undefined behavior in how __hash_table stores its pointer types.
|
||||
#define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
|
||||
#define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
|
||||
#define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
|
||||
@@ -76,6 +78,11 @@
|
||||
// its vtable and typeinfo to libc++ rather than having all other libraries
|
||||
// using that class define their own copies.
|
||||
#define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
|
||||
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
|
||||
#define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
// Use the smallest possible integer type to represent the index of the variant.
|
||||
// Previously libc++ used "unsigned int" exclusivly.
|
||||
#define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
|
||||
#elif _LIBCPP_ABI_VERSION == 1
|
||||
#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
|
||||
// Enable compiling copies of now inline methods into the dylib to support
|
||||
@@ -118,6 +125,9 @@
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(__x) 0
|
||||
#endif
|
||||
#ifndef __has_cpp_attribute
|
||||
#define __has_cpp_attribute(__x) 0
|
||||
#endif
|
||||
// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
|
||||
// the compiler and '1' otherwise.
|
||||
#ifndef __is_identifier
|
||||
@@ -154,53 +164,59 @@
|
||||
|
||||
// FIXME: ABI detection should be done via compiler builtin macros. This
|
||||
// is just a placeholder until Clang implements such macros. For now assume
|
||||
// that Windows compilers pretending to be MSVC++ target the microsoft ABI.
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
|
||||
// and allow the user to explicitly specify the ABI to handle cases where this
|
||||
// heuristic falls short.
|
||||
#if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT)
|
||||
# error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined"
|
||||
#elif defined(_LIBCPP_ABI_FORCE_ITANIUM)
|
||||
# define _LIBCPP_ABI_ITANIUM
|
||||
#elif defined(_LIBCPP_ABI_FORCE_MICROSOFT)
|
||||
# define _LIBCPP_ABI_MICROSOFT
|
||||
#else
|
||||
# define _LIBCPP_ABI_ITANIUM
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
# define _LIBCPP_ABI_MICROSOFT
|
||||
# else
|
||||
# define _LIBCPP_ABI_ITANIUM
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Need to detect which libc we're using if we're on Linux.
|
||||
#if defined(__linux__)
|
||||
#include <features.h>
|
||||
#if !defined(__GLIBC_PREREQ)
|
||||
#define __GLIBC_PREREQ(a, b) 0
|
||||
#endif // !defined(__GLIBC_PREREQ)
|
||||
#if defined(__GLIBC_PREREQ)
|
||||
#define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
|
||||
#else
|
||||
#define _LIBCPP_GLIBC_PREREQ(a, b) 0
|
||||
#endif // defined(__GLIBC_PREREQ)
|
||||
#endif // defined(__linux__)
|
||||
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
#if __LITTLE_ENDIAN__
|
||||
#define _LIBCPP_LITTLE_ENDIAN 1
|
||||
#define _LIBCPP_BIG_ENDIAN 0
|
||||
#define _LIBCPP_LITTLE_ENDIAN
|
||||
#endif // __LITTLE_ENDIAN__
|
||||
#endif // __LITTLE_ENDIAN__
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#if __BIG_ENDIAN__
|
||||
#define _LIBCPP_LITTLE_ENDIAN 0
|
||||
#define _LIBCPP_BIG_ENDIAN 1
|
||||
#define _LIBCPP_BIG_ENDIAN
|
||||
#endif // __BIG_ENDIAN__
|
||||
#endif // __BIG_ENDIAN__
|
||||
|
||||
#ifdef __BYTE_ORDER__
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define _LIBCPP_LITTLE_ENDIAN 1
|
||||
#define _LIBCPP_BIG_ENDIAN 0
|
||||
#define _LIBCPP_LITTLE_ENDIAN
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define _LIBCPP_LITTLE_ENDIAN 0
|
||||
#define _LIBCPP_BIG_ENDIAN 1
|
||||
#define _LIBCPP_BIG_ENDIAN
|
||||
#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#endif // __BYTE_ORDER__
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <sys/endian.h>
|
||||
# if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# else // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 0
|
||||
# define _LIBCPP_BIG_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# ifndef __LONG_LONG_SUPPORTED
|
||||
# define _LIBCPP_HAS_NO_LONG_LONG
|
||||
@@ -210,29 +226,28 @@
|
||||
#ifdef __NetBSD__
|
||||
# include <sys/endian.h>
|
||||
# if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# else // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 0
|
||||
# define _LIBCPP_BIG_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define _LIBCPP_HAS_QUICK_EXIT
|
||||
#endif // __NetBSD__
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define _LIBCPP_WIN32API
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# define _LIBCPP_SHORT_WCHAR 1
|
||||
// Both MinGW and native MSVC provide a "MSVC"-like enviroment
|
||||
# define _LIBCPP_MSVCRT_LIKE
|
||||
// If mingw not explicitly detected, assume using MS C runtime only.
|
||||
# ifndef __MINGW32__
|
||||
// If mingw not explicitly detected, assume using MS C runtime only if
|
||||
// a MS compatibility version is specified.
|
||||
# if defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
|
||||
# endif
|
||||
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
|
||||
# define _LIBCPP_HAS_BITSCAN64
|
||||
# endif
|
||||
# define _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
# if defined(_LIBCPP_MSVCRT)
|
||||
# define _LIBCPP_HAS_QUICK_EXIT
|
||||
# endif
|
||||
@@ -251,11 +266,9 @@
|
||||
#ifdef __sun__
|
||||
# include <sys/isa_defs.h>
|
||||
# ifdef _LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# else
|
||||
# define _LIBCPP_LITTLE_ENDIAN 0
|
||||
# define _LIBCPP_BIG_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# endif
|
||||
#endif // __sun__
|
||||
|
||||
@@ -265,6 +278,8 @@
|
||||
// random data even when using sandboxing mechanisms such as chroots,
|
||||
// Capsicum, etc.
|
||||
# define _LIBCPP_USING_ARC4_RANDOM
|
||||
#elif defined(__Fuchsia__)
|
||||
# define _LIBCPP_USING_GETENTROPY
|
||||
#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
|
||||
@@ -276,20 +291,18 @@
|
||||
# define _LIBCPP_USING_DEV_RANDOM
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
|
||||
#if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
|
||||
# include <endian.h>
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN 0
|
||||
# define _LIBCPP_LITTLE_ENDIAN
|
||||
# elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define _LIBCPP_LITTLE_ENDIAN 0
|
||||
# define _LIBCPP_BIG_ENDIAN 1
|
||||
# define _LIBCPP_BIG_ENDIAN
|
||||
# else // __BYTE_ORDER == __BIG_ENDIAN
|
||||
# error unable to determine endian
|
||||
# endif
|
||||
#endif // !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
|
||||
#endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN)
|
||||
|
||||
#if __has_attribute(__no_sanitize__)
|
||||
#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
|
||||
#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
|
||||
#else
|
||||
#define _LIBCPP_NO_CFI
|
||||
@@ -406,10 +419,10 @@ typedef __char32_t char32_t;
|
||||
#define _LIBCPP_HAS_C11_FEATURES
|
||||
#elif defined(__linux__)
|
||||
#if !defined(_LIBCPP_HAS_MUSL_LIBC)
|
||||
#if __GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
|
||||
#if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
|
||||
#define _LIBCPP_HAS_QUICK_EXIT
|
||||
#endif
|
||||
#if __GLIBC_PREREQ(2, 17)
|
||||
#if _LIBCPP_GLIBC_PREREQ(2, 17)
|
||||
#define _LIBCPP_HAS_C11_FEATURES
|
||||
#endif
|
||||
#else // defined(_LIBCPP_HAS_MUSL_LIBC)
|
||||
@@ -450,6 +463,14 @@ namespace std {
|
||||
#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_launder)
|
||||
#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
|
||||
#endif
|
||||
|
||||
#if !__is_identifier(__has_unique_object_representations)
|
||||
#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
|
||||
#endif
|
||||
|
||||
#elif defined(_LIBCPP_COMPILER_GCC)
|
||||
|
||||
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
|
||||
@@ -532,6 +553,14 @@ namespace std {
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER >= 700
|
||||
#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER >= 700
|
||||
#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
|
||||
#endif
|
||||
|
||||
#elif defined(_LIBCPP_COMPILER_MSVC)
|
||||
|
||||
#define _LIBCPP_TOSTRING2(x) #x
|
||||
@@ -598,6 +627,12 @@ namespace std {
|
||||
#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
|
||||
|
||||
#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
|
||||
#ifdef _DLL
|
||||
# define _LIBCPP_CRT_FUNC __declspec(dllimport)
|
||||
#else
|
||||
# define _LIBCPP_CRT_FUNC
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
|
||||
# define _LIBCPP_DLL_VIS
|
||||
# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
|
||||
@@ -622,7 +657,6 @@ namespace std {
|
||||
#define _LIBCPP_HIDDEN
|
||||
#define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
|
||||
#define _LIBCPP_TEMPLATE_VIS
|
||||
#define _LIBCPP_FUNC_VIS_ONLY
|
||||
#define _LIBCPP_ENUM_VIS
|
||||
|
||||
#if defined(_LIBCPP_COMPILER_MSVC)
|
||||
@@ -681,10 +715,6 @@ namespace std {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_FUNC_VIS_ONLY
|
||||
# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_EXTERN_VIS
|
||||
# define _LIBCPP_EXTERN_VIS
|
||||
#endif
|
||||
@@ -763,8 +793,13 @@ namespace std {
|
||||
# if !defined(_LIBCPP_DEBUG)
|
||||
# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
|
||||
# endif
|
||||
# define _NOEXCEPT_DEBUG noexcept(false)
|
||||
# define _NOEXCEPT_DEBUG_(x) noexcept(false)
|
||||
# ifdef _LIBCPP_HAS_NO_NOEXCEPT
|
||||
# define _NOEXCEPT_DEBUG
|
||||
# define _NOEXCEPT_DEBUG_(x)
|
||||
# else
|
||||
# define _NOEXCEPT_DEBUG noexcept(false)
|
||||
# define _NOEXCEPT_DEBUG_(x) noexcept(false)
|
||||
#endif
|
||||
#else
|
||||
# define _NOEXCEPT_DEBUG _NOEXCEPT
|
||||
# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
|
||||
@@ -881,7 +916,7 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT) || \
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
|
||||
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
|
||||
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
#endif
|
||||
@@ -922,8 +957,10 @@ template <unsigned> struct __static_assert_check {};
|
||||
# define _LIBCPP_STD_VER 11
|
||||
# elif __cplusplus <= 201402L
|
||||
# define _LIBCPP_STD_VER 14
|
||||
# elif __cplusplus <= 201703L
|
||||
# define _LIBCPP_STD_VER 17
|
||||
# else
|
||||
# define _LIBCPP_STD_VER 16 // current year, or date of c++17 ratification
|
||||
# define _LIBCPP_STD_VER 18 // current year, or date of c++2a ratification
|
||||
# endif
|
||||
#endif // _LIBCPP_STD_VER
|
||||
|
||||
@@ -953,9 +990,22 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
#endif
|
||||
|
||||
// FIXME: Remove all usages of this macro once compilers catch up.
|
||||
#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606L)
|
||||
# define _LIBCPP_HAS_NO_INLINE_VARIABLES
|
||||
#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR)
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr
|
||||
#else
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
#endif
|
||||
|
||||
#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17)
|
||||
#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
|
||||
#else
|
||||
#define _LIBCPP_NODISCARD_AFTER_CXX17
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
|
||||
# define _LIBCPP_INLINE_VAR inline
|
||||
#else
|
||||
# define _LIBCPP_INLINE_VAR
|
||||
#endif
|
||||
|
||||
#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
||||
@@ -1132,8 +1182,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# define _LIBCPP_HAS_NO_COROUTINES
|
||||
#endif
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
// Decide whether to use availability macros.
|
||||
#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
|
||||
!defined(_LIBCPP_DISABLE_AVAILABILITY) && \
|
||||
@@ -1153,6 +1201,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
__attribute__((availability(watchos,strict,introduced=3.0)))
|
||||
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((unavailable))
|
||||
#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH __attribute__((unavailable))
|
||||
#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST __attribute__((unavailable))
|
||||
#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \
|
||||
__attribute__((availability(macosx,strict,introduced=10.12))) \
|
||||
__attribute__((availability(ios,strict,introduced=10.0))) \
|
||||
@@ -1178,6 +1227,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
#define _LIBCPP_AVAILABILITY_SHARED_MUTEX
|
||||
#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
#define _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
|
||||
#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
|
||||
#define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS
|
||||
#define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE
|
||||
#define _LIBCPP_AVAILABILITY_FUTURE_ERROR
|
||||
@@ -1190,9 +1240,12 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
#ifdef _LIBCPP_NO_EXCEPTIONS
|
||||
#define _LIBCPP_AVAILABILITY_DYNARRAY
|
||||
#define _LIBCPP_AVAILABILITY_FUTURE
|
||||
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
|
||||
#else
|
||||
#define _LIBCPP_AVAILABILITY_DYNARRAY _LIBCPP_AVAILABILITY_BAD_ARRAY_LENGTH
|
||||
#define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR
|
||||
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST \
|
||||
_LIBCPP_AVAILABILITY_BAD_ANY_CAST
|
||||
#endif
|
||||
|
||||
// Availability of stream API in the dylib got dropped and re-added. The
|
||||
@@ -1201,9 +1254,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
// availability(ios,introduced=7.0)
|
||||
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \
|
||||
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1090) || \
|
||||
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
|
||||
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
|
||||
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ <= 70000))
|
||||
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
|
||||
#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
|
||||
#endif
|
||||
|
||||
@@ -1237,4 +1290,16 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# endif
|
||||
#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
|
||||
|
||||
#ifndef _LIBCPP_NO_AUTO_LINK
|
||||
# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# if defined(_DLL)
|
||||
# pragma comment(lib, "c++.lib")
|
||||
# else
|
||||
# pragma comment(lib, "libc++.lib")
|
||||
# endif
|
||||
# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
#endif // _LIBCPP_NO_AUTO_LINK
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // _LIBCPP_CONFIG
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@
|
||||
#cmakedefine _LIBCPP_ABI_UNSTABLE
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_ITANIUM
|
||||
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
|
||||
#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDIN
|
||||
#cmakedefine _LIBCPP_HAS_NO_STDOUT
|
||||
@@ -21,7 +23,11 @@
|
||||
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_WIN32
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
|
||||
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#cmakedefine _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
@_LIBCPP_ABI_DEFINES@
|
||||
|
||||
#endif // _LIBCPP_CONFIG_SITE
|
||||
|
||||
@@ -704,7 +704,7 @@ function<_Rp()>::target()
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (_Tp*)0;
|
||||
return (_Tp*)__f_->target(typeid(_Tp));
|
||||
return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
|
||||
}
|
||||
|
||||
template<class _Rp>
|
||||
@@ -980,7 +980,7 @@ function<_Rp(_A0)>::target()
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (_Tp*)0;
|
||||
return (_Tp*)__f_->target(typeid(_Tp));
|
||||
return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
|
||||
}
|
||||
|
||||
template<class _Rp, class _A0>
|
||||
@@ -1256,7 +1256,7 @@ function<_Rp(_A0, _A1)>::target()
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (_Tp*)0;
|
||||
return (_Tp*)__f_->target(typeid(_Tp));
|
||||
return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
|
||||
}
|
||||
|
||||
template<class _Rp, class _A0, class _A1>
|
||||
@@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1, _A2)>::target()
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (_Tp*)0;
|
||||
return (_Tp*)__f_->target(typeid(_Tp));
|
||||
return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
|
||||
}
|
||||
|
||||
template<class _Rp, class _A0, class _A1, class _A2>
|
||||
|
||||
@@ -548,16 +548,13 @@ template <class _Tp> void cref(const _Tp&&) = delete;
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _Tp1, class _Tp2 = void>
|
||||
struct __is_transparent
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::is_transparent* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp1>(0)) == 1;
|
||||
};
|
||||
template <class _Tp, class, class = void>
|
||||
struct __is_transparent : false_type {};
|
||||
|
||||
template <class _Tp, class _Up>
|
||||
struct __is_transparent<_Tp, _Up,
|
||||
typename __void_t<typename _Tp::is_transparent>::type>
|
||||
: true_type {};
|
||||
#endif
|
||||
|
||||
// allocator_arg_t
|
||||
@@ -567,7 +564,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
|
||||
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MEMORY)
|
||||
extern const allocator_arg_t allocator_arg;
|
||||
#else
|
||||
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
#endif
|
||||
|
||||
// uses_allocator
|
||||
@@ -604,7 +601,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp, class _Alloc>
|
||||
constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value;
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
|
||||
@@ -1 +1 @@
|
||||
5000
|
||||
7000
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
# include <support/solaris/xlocale.h>
|
||||
#elif defined(_NEWLIB_VERSION)
|
||||
# include <support/newlib/xlocale.h>
|
||||
#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
#elif (defined(__APPLE__) || defined(__FreeBSD__) \
|
||||
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
|
||||
# include <xlocale.h>
|
||||
#elif defined(__Fuchsia__)
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS) || defined(_LIBCPP_MSVCRT)
|
||||
#if !defined(_LIBCPP_LOCALE__L_EXTENSIONS)
|
||||
struct __libcpp_locale_guard {
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {}
|
||||
@@ -65,6 +65,32 @@ private:
|
||||
__libcpp_locale_guard(__libcpp_locale_guard const&);
|
||||
__libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
|
||||
};
|
||||
#elif defined(_LIBCPP_MSVCRT_LIKE)
|
||||
struct __libcpp_locale_guard {
|
||||
__libcpp_locale_guard(locale_t __l) :
|
||||
__status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
|
||||
__locale_collate(setlocale(LC_COLLATE, __l.__get_locale())),
|
||||
__locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())),
|
||||
__locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())),
|
||||
__locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())),
|
||||
__locale_time(setlocale(LC_TIME, __l.__get_locale()))
|
||||
// LC_MESSAGES is not supported on Windows.
|
||||
{}
|
||||
~__libcpp_locale_guard() {
|
||||
setlocale(LC_COLLATE, __locale_collate);
|
||||
setlocale(LC_CTYPE, __locale_ctype);
|
||||
setlocale(LC_MONETARY, __locale_monetary);
|
||||
setlocale(LC_NUMERIC, __locale_numeric);
|
||||
setlocale(LC_TIME, __locale_time);
|
||||
_configthreadlocale(__status);
|
||||
}
|
||||
int __status;
|
||||
char* __locale_collate;
|
||||
char* __locale_ctype;
|
||||
char* __locale_monetary;
|
||||
char* __locale_numeric;
|
||||
char* __locale_time;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -82,9 +82,9 @@ extern const adopt_lock_t adopt_lock;
|
||||
|
||||
#else
|
||||
|
||||
constexpr defer_lock_t defer_lock = defer_lock_t();
|
||||
constexpr try_to_lock_t try_to_lock = try_to_lock_t();
|
||||
constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr defer_lock_t defer_lock = defer_lock_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr try_to_lock_t try_to_lock = try_to_lock_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ const char*
|
||||
char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_char_memchr(__s, to_int_type(__a), __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
@@ -278,7 +278,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -372,9 +372,9 @@ const wchar_t*
|
||||
char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
|
||||
{
|
||||
if (__n == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#if __has_feature(cxx_constexpr_string_builtins)
|
||||
return __builtin_wmemchr(__s, __a, __n);
|
||||
return __builtin_wmemchr(__s, __a, __n);
|
||||
#elif _LIBCPP_STD_VER <= 14
|
||||
return wmemchr(__s, __a, __n);
|
||||
#else
|
||||
@@ -384,7 +384,7 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
|
||||
return __s;
|
||||
++__s;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -26,23 +26,11 @@
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
# include <pthread.h>
|
||||
# include <sched.h>
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include <fibersapi.h>
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
|
||||
#else
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(no_thread_safety_analysis)
|
||||
#define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS __attribute__((no_thread_safety_analysis))
|
||||
#else
|
||||
@@ -51,7 +39,15 @@ _LIBCPP_PUSH_MACROS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
#if defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
|
||||
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
|
||||
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
|
||||
|
||||
// Mutex
|
||||
typedef pthread_mutex_t __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
@@ -79,32 +75,41 @@ typedef pthread_key_t __libcpp_tls_key;
|
||||
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC
|
||||
#else
|
||||
// Mutex
|
||||
typedef SRWLOCK __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER SRWLOCK_INIT
|
||||
|
||||
typedef CRITICAL_SECTION __libcpp_recursive_mutex_t;
|
||||
#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
|
||||
|
||||
// Mutex
|
||||
typedef void* __libcpp_mutex_t;
|
||||
#define _LIBCPP_MUTEX_INITIALIZER 0
|
||||
|
||||
#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
|
||||
typedef void* __libcpp_recursive_mutex_t[6];
|
||||
#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
|
||||
typedef void* __libcpp_recursive_mutex_t[5];
|
||||
#else
|
||||
# error Unsupported architecture
|
||||
#endif
|
||||
|
||||
// Condition Variable
|
||||
typedef CONDITION_VARIABLE __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER CONDITION_VARIABLE_INIT
|
||||
typedef void* __libcpp_condvar_t;
|
||||
#define _LIBCPP_CONDVAR_INITIALIZER 0
|
||||
|
||||
// Execute Once
|
||||
typedef INIT_ONCE __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT
|
||||
typedef void* __libcpp_exec_once_flag;
|
||||
#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
|
||||
|
||||
// Thread ID
|
||||
typedef DWORD __libcpp_thread_id;
|
||||
typedef long __libcpp_thread_id;
|
||||
|
||||
// Thread
|
||||
#define _LIBCPP_NULL_THREAD 0U
|
||||
|
||||
typedef HANDLE __libcpp_thread_t;
|
||||
typedef void* __libcpp_thread_t;
|
||||
|
||||
// Thread Local Storage
|
||||
typedef DWORD __libcpp_tls_key;
|
||||
typedef long __libcpp_tls_key;
|
||||
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC WINAPI
|
||||
#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
|
||||
#endif
|
||||
|
||||
// Mutex
|
||||
@@ -201,10 +206,9 @@ void *__libcpp_tls_get(__libcpp_tls_key __key);
|
||||
_LIBCPP_THREAD_ABI_VISIBILITY
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
|
||||
|
||||
#if !defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)
|
||||
|
||||
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
#if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \
|
||||
defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) && \
|
||||
defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
@@ -390,244 +394,6 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
return pthread_setspecific(__key, __p);
|
||||
}
|
||||
|
||||
#elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
|
||||
|
||||
// Mutex
|
||||
int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
InitializeCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
EnterCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
return TryEnterCriticalSection(__m) != 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
LeaveCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
|
||||
{
|
||||
DeleteCriticalSection(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
AcquireSRWLockExclusive(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
return TryAcquireSRWLockExclusive(__m) != 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
|
||||
{
|
||||
ReleaseSRWLockExclusive(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
|
||||
{
|
||||
static_cast<void>(__m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Condition Variable
|
||||
int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
WakeConditionVariable(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
WakeAllConditionVariable(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
|
||||
{
|
||||
SleepConditionVariableSRW(__cv, __m, INFINITE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
|
||||
timespec *__ts)
|
||||
{
|
||||
using namespace _VSTD::chrono;
|
||||
|
||||
auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
|
||||
auto abstime =
|
||||
system_clock::time_point(duration_cast<system_clock::duration>(duration));
|
||||
auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
|
||||
|
||||
if (!SleepConditionVariableSRW(__cv, __m,
|
||||
timeout_ms.count() > 0 ? timeout_ms.count()
|
||||
: 0,
|
||||
0))
|
||||
{
|
||||
auto __ec = GetLastError();
|
||||
return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
|
||||
{
|
||||
static_cast<void>(__cv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute Once
|
||||
static inline _LIBCPP_ALWAYS_INLINE BOOL CALLBACK
|
||||
__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
|
||||
PVOID *__context)
|
||||
{
|
||||
static_cast<void>(__init_once);
|
||||
static_cast<void>(__context);
|
||||
|
||||
void (*init_routine)(void) = reinterpret_cast<void (*)(void)>(__parameter);
|
||||
init_routine();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
|
||||
void (*__init_routine)(void))
|
||||
{
|
||||
if (!InitOnceExecuteOnce(__flag, __libcpp_init_once_execute_once_thunk,
|
||||
reinterpret_cast<void *>(__init_routine), NULL))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Thread ID
|
||||
bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
|
||||
__libcpp_thread_id __rhs)
|
||||
{
|
||||
return __lhs == __rhs;
|
||||
}
|
||||
|
||||
bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
|
||||
{
|
||||
return __lhs < __rhs;
|
||||
}
|
||||
|
||||
// Thread
|
||||
struct __libcpp_beginthreadex_thunk_data
|
||||
{
|
||||
void *(*__func)(void *);
|
||||
void *__arg;
|
||||
};
|
||||
|
||||
static inline _LIBCPP_ALWAYS_INLINE unsigned WINAPI
|
||||
__libcpp_beginthreadex_thunk(void *__raw_data)
|
||||
{
|
||||
auto *__data =
|
||||
static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
|
||||
auto *__func = __data->__func;
|
||||
void *__arg = __data->__arg;
|
||||
delete __data;
|
||||
return static_cast<unsigned>(reinterpret_cast<uintptr_t>(__func(__arg)));
|
||||
}
|
||||
|
||||
bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
|
||||
return *__t == 0;
|
||||
}
|
||||
|
||||
int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
|
||||
void *__arg)
|
||||
{
|
||||
auto *__data = new __libcpp_beginthreadex_thunk_data;
|
||||
__data->__func = __func;
|
||||
__data->__arg = __arg;
|
||||
|
||||
*__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0,
|
||||
__libcpp_beginthreadex_thunk,
|
||||
__data, 0, nullptr));
|
||||
|
||||
if (*__t)
|
||||
return 0;
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_current_id()
|
||||
{
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
||||
__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
|
||||
{
|
||||
return GetThreadId(*__t);
|
||||
}
|
||||
|
||||
int __libcpp_thread_join(__libcpp_thread_t *__t)
|
||||
{
|
||||
if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
|
||||
return GetLastError();
|
||||
if (!CloseHandle(*__t))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __libcpp_thread_detach(__libcpp_thread_t *__t)
|
||||
{
|
||||
if (!CloseHandle(*__t))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __libcpp_thread_yield()
|
||||
{
|
||||
SwitchToThread();
|
||||
}
|
||||
|
||||
void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
|
||||
{
|
||||
using namespace chrono;
|
||||
// round-up to the nearest milisecond
|
||||
milliseconds __ms =
|
||||
duration_cast<milliseconds>(__ns + chrono::nanoseconds(999999));
|
||||
// FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
|
||||
Sleep(__ms.count());
|
||||
}
|
||||
|
||||
// Thread Local Storage
|
||||
int __libcpp_tls_create(__libcpp_tls_key* __key,
|
||||
void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
|
||||
{
|
||||
*__key = FlsAlloc(__at_exit);
|
||||
if (*__key == FLS_OUT_OF_INDEXES)
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *__libcpp_tls_get(__libcpp_tls_key __key)
|
||||
{
|
||||
return FlsGetValue(__key);
|
||||
}
|
||||
|
||||
int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
|
||||
{
|
||||
if (!FlsSetValue(__key, __p))
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
|
||||
#endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
@@ -84,7 +84,7 @@ __tree_is_left_child(_NodePtr __x) _NOEXCEPT
|
||||
return __x == __x->__parent_->__left_;
|
||||
}
|
||||
|
||||
// Determintes if the subtree rooted at __x is a proper red black subtree. If
|
||||
// Determines if the subtree rooted at __x is a proper red black subtree. If
|
||||
// __x is a proper subtree, returns the black height (null counts as 1). If
|
||||
// __x is an improper subtree, returns 0.
|
||||
template <class _NodePtr>
|
||||
@@ -119,7 +119,7 @@ __tree_sub_invariant(_NodePtr __x)
|
||||
return __h + __x->__is_black_; // return black height of this node
|
||||
}
|
||||
|
||||
// Determintes if the red black tree rooted at __root is a proper red black tree.
|
||||
// Determines if the red black tree rooted at __root is a proper red black tree.
|
||||
// __root == nullptr is a proper tree. Returns true is __root is a proper
|
||||
// red black tree, else returns false.
|
||||
template <class _NodePtr>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
170
include/array
170
include/array
@@ -108,6 +108,8 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for _LIBCPP_UNREACHABLE
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@@ -117,6 +119,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS array
|
||||
{
|
||||
@@ -134,31 +137,27 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
value_type __elems_[_Size > 0 ? _Size : 1];
|
||||
_Tp __elems_[_Size];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u)
|
||||
{_VSTD::fill_n(__elems_, _Size, __u);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array& __a) _NOEXCEPT_(_Size == 0 || __is_nothrow_swappable<_Tp>::value)
|
||||
{ __swap_dispatch((std::integral_constant<bool, _Size == 0>()), __a); }
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {
|
||||
_VSTD::fill_n(__elems_, _Size, __u);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_dispatch(std::true_type, array&) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_dispatch(std::false_type, array& __a)
|
||||
{ _VSTD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
|
||||
void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
|
||||
std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator begin() _NOEXCEPT {return iterator(__elems_);}
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(__elems_);}
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
iterator end() _NOEXCEPT {return iterator(__elems_ + _Size);}
|
||||
iterator end() _NOEXCEPT {return iterator(data() + _Size);}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(__elems_ + _Size);}
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
@@ -183,8 +182,8 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; }
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
@@ -197,8 +196,8 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size - 1];}
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size - 1];}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
value_type* data() _NOEXCEPT {return __elems_;}
|
||||
@@ -206,6 +205,7 @@ struct _LIBCPP_TEMPLATE_VIS array
|
||||
const value_type* data() const _NOEXCEPT {return __elems_;}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
typename array<_Tp, _Size>::reference
|
||||
@@ -227,12 +227,138 @@ array<_Tp, _Size>::at(size_type __n) const
|
||||
return __elems_[__n];
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
|
||||
{
|
||||
// types:
|
||||
typedef array __self;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
|
||||
typedef typename conditional<is_const<_Tp>::value, const char,
|
||||
char>::type _CharType;
|
||||
_ALIGNAS(alignment_of<_Tp[1]>::value) _CharType __elems_[sizeof(_Tp[1])];
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
_LIBCPP_INLINE_VISIBILITY void fill(const value_type&) {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot fill zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(array&) _NOEXCEPT {
|
||||
static_assert(!is_const<_Tp>::value,
|
||||
"cannot swap zero-sized array of type 'const T'");
|
||||
}
|
||||
|
||||
// iterators:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator begin() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
iterator end() _NOEXCEPT {return iterator(data());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT {return const_iterator(data());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT {return begin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT {return end();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
// capacity:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference operator[](size_type) {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
const_reference operator[](size_type) const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference at(size_type) {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type) const {
|
||||
__throw_out_of_range("array<T, 0>::at");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference front() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
reference back() {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const {
|
||||
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
|
||||
_LIBCPP_UNREACHABLE();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);}
|
||||
};
|
||||
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
|
||||
return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
@@ -248,7 +374,8 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
|
||||
{
|
||||
return _VSTD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
|
||||
return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
|
||||
__y.begin(), __y.end());
|
||||
}
|
||||
|
||||
template <class _Tp, size_t _Size>
|
||||
@@ -296,6 +423,7 @@ class _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
|
||||
{
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
|
||||
public:
|
||||
typedef _Tp type;
|
||||
};
|
||||
|
||||
@@ -235,8 +235,13 @@ void
|
||||
__bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT
|
||||
{
|
||||
__storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
|
||||
for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word)
|
||||
__t[__i] = static_cast<__storage_type>(__v);
|
||||
size_t __sz = _Size;
|
||||
for (size_t __i = 0; __i < sizeof(__t)/sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word )
|
||||
if ( __sz < __bits_per_word)
|
||||
__t[__i] = static_cast<__storage_type>(__v) & ( 1ULL << __sz ) - 1;
|
||||
else
|
||||
__t[__i] = static_cast<__storage_type>(__v);
|
||||
|
||||
_VSTD::copy(__t, __t + sizeof(__t)/sizeof(__t[0]), __first_);
|
||||
_VSTD::fill(__first_ + sizeof(__t)/sizeof(__t[0]), __first_ + sizeof(__first_)/sizeof(__first_[0]),
|
||||
__storage_type(0));
|
||||
@@ -248,6 +253,9 @@ void
|
||||
__bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT
|
||||
{
|
||||
__first_[0] = __v;
|
||||
if (_Size < __bits_per_word)
|
||||
__first_[0] &= ( 1ULL << _Size ) - 1;
|
||||
|
||||
_VSTD::fill(__first_ + 1, __first_ + sizeof(__first_)/sizeof(__first_[0]), __storage_type(0));
|
||||
}
|
||||
|
||||
@@ -261,7 +269,9 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
|
||||
#if __SIZEOF_SIZE_T__ == 8
|
||||
: __first_{__v}
|
||||
#elif __SIZEOF_SIZE_T__ == 4
|
||||
: __first_{static_cast<__storage_type>(__v), static_cast<__storage_type>(__v >> __bits_per_word)}
|
||||
: __first_{static_cast<__storage_type>(__v),
|
||||
_Size >= 2 * __bits_per_word ? static_cast<__storage_type>(__v >> __bits_per_word)
|
||||
: static_cast<__storage_type>((__v >> __bits_per_word) & (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
|
||||
#else
|
||||
#error This constructor has not been ported to this platform
|
||||
#endif
|
||||
@@ -503,7 +513,10 @@ template <size_t _Size>
|
||||
inline
|
||||
_LIBCPP_CONSTEXPR
|
||||
__bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
|
||||
: __first_(static_cast<__storage_type>(__v))
|
||||
: __first_(
|
||||
_Size == __bits_per_word ? static_cast<__storage_type>(__v)
|
||||
: static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ duration_cast(const duration<Rep, Period>& fd);
|
||||
|
||||
template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
|
||||
|
||||
template <class Rep> constexpr bool treat_as_floating_point_v
|
||||
template <class Rep> inline constexpr bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<Rep>::value; // C++17
|
||||
|
||||
template <class Rep>
|
||||
@@ -283,18 +283,18 @@ typedef steady_clock high_resolution_clock;
|
||||
|
||||
} // chrono
|
||||
|
||||
constexpr chrono::hours operator "" h(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , ratio<3600,1>> operator "" h(long double); // C++14
|
||||
constexpr chrono::minutes operator "" min(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , ratio<60,1>> operator "" min(long double); // C++14
|
||||
constexpr chrono::seconds operator "" s(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified > operator "" s(long double); // C++14
|
||||
constexpr chrono::milliseconds operator "" ms(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , milli> operator "" ms(long double); // C++14
|
||||
constexpr chrono::microseconds operator "" us(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , micro> operator "" us(long double); // C++14
|
||||
constexpr chrono::nanoseconds operator "" ns(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , nano> operator "" ns(long double); // C++14
|
||||
constexpr chrono::hours operator ""h(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
|
||||
constexpr chrono::minutes operator ""min(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
|
||||
constexpr chrono::seconds operator ""s(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
|
||||
constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
|
||||
constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
|
||||
constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
|
||||
constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
|
||||
|
||||
} // std
|
||||
*/
|
||||
@@ -419,7 +419,8 @@ template <class _Rep>
|
||||
struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
|
||||
template <class _Rep>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<_Rep>::value;
|
||||
#endif
|
||||
|
||||
@@ -1087,67 +1088,67 @@ inline namespace literals
|
||||
inline namespace chrono_literals
|
||||
{
|
||||
|
||||
constexpr chrono::hours operator"" h(unsigned long long __h)
|
||||
constexpr chrono::hours operator""h(unsigned long long __h)
|
||||
{
|
||||
return chrono::hours(static_cast<chrono::hours::rep>(__h));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double, ratio<3600,1>> operator"" h(long double __h)
|
||||
constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h)
|
||||
{
|
||||
return chrono::duration<long double, ratio<3600,1>>(__h);
|
||||
}
|
||||
|
||||
|
||||
constexpr chrono::minutes operator"" min(unsigned long long __m)
|
||||
constexpr chrono::minutes operator""min(unsigned long long __m)
|
||||
{
|
||||
return chrono::minutes(static_cast<chrono::minutes::rep>(__m));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double, ratio<60,1>> operator"" min(long double __m)
|
||||
constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m)
|
||||
{
|
||||
return chrono::duration<long double, ratio<60,1>> (__m);
|
||||
}
|
||||
|
||||
|
||||
constexpr chrono::seconds operator"" s(unsigned long long __s)
|
||||
constexpr chrono::seconds operator""s(unsigned long long __s)
|
||||
{
|
||||
return chrono::seconds(static_cast<chrono::seconds::rep>(__s));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double> operator"" s(long double __s)
|
||||
constexpr chrono::duration<long double> operator""s(long double __s)
|
||||
{
|
||||
return chrono::duration<long double> (__s);
|
||||
}
|
||||
|
||||
|
||||
constexpr chrono::milliseconds operator"" ms(unsigned long long __ms)
|
||||
constexpr chrono::milliseconds operator""ms(unsigned long long __ms)
|
||||
{
|
||||
return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double, milli> operator"" ms(long double __ms)
|
||||
constexpr chrono::duration<long double, milli> operator""ms(long double __ms)
|
||||
{
|
||||
return chrono::duration<long double, milli>(__ms);
|
||||
}
|
||||
|
||||
|
||||
constexpr chrono::microseconds operator"" us(unsigned long long __us)
|
||||
constexpr chrono::microseconds operator""us(unsigned long long __us)
|
||||
{
|
||||
return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double, micro> operator"" us(long double __us)
|
||||
constexpr chrono::duration<long double, micro> operator""us(long double __us)
|
||||
{
|
||||
return chrono::duration<long double, micro> (__us);
|
||||
}
|
||||
|
||||
|
||||
constexpr chrono::nanoseconds operator"" ns(unsigned long long __ns)
|
||||
constexpr chrono::nanoseconds operator""ns(unsigned long long __ns)
|
||||
{
|
||||
return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns));
|
||||
}
|
||||
|
||||
constexpr chrono::duration<long double, nano> operator"" ns(long double __ns)
|
||||
constexpr chrono::duration<long double, nano> operator""ns(long double __ns)
|
||||
{
|
||||
return chrono::duration<long double, nano> (__ns);
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isnan)
|
||||
return __builtin_isnan(__lcpp_x);
|
||||
@@ -561,7 +561,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isnan(__lcpp_x);
|
||||
}
|
||||
@@ -569,7 +569,7 @@ __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isinf)
|
||||
return __builtin_isinf(__lcpp_x);
|
||||
@@ -581,7 +581,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isinf(__lcpp_x);
|
||||
}
|
||||
@@ -589,7 +589,7 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
#if __has_builtin(__builtin_isfinite)
|
||||
return __builtin_isfinite(__lcpp_x);
|
||||
@@ -601,7 +601,7 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
|
||||
template <class _A1>
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
|
||||
__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
|
||||
__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
|
||||
{
|
||||
return isfinite(__lcpp_x);
|
||||
}
|
||||
|
||||
162
include/complex
162
include/complex
@@ -203,7 +203,7 @@ template<class T> complex<T> proj(const complex<T>&);
|
||||
template<Integral T> complex<double> proj(T);
|
||||
complex<float> proj(float);
|
||||
|
||||
template<class T> complex<T> polar(const T&, const T& = 0);
|
||||
template<class T> complex<T> polar(const T&, const T& = T());
|
||||
|
||||
// 26.3.8 transcendentals:
|
||||
template<class T> complex<T> acos(const complex<T>&);
|
||||
@@ -599,39 +599,39 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
|
||||
_Tp __bc = __b * __c;
|
||||
_Tp __x = __ac - __bd;
|
||||
_Tp __y = __ad + __bc;
|
||||
if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
|
||||
if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
|
||||
{
|
||||
bool __recalc = false;
|
||||
if (__libcpp_isinf(__a) || __libcpp_isinf(__b))
|
||||
if (__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b))
|
||||
{
|
||||
__a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
|
||||
__b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
|
||||
if (__libcpp_isnan(__c))
|
||||
__a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
|
||||
__b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
|
||||
if (__libcpp_isnan_or_builtin(__c))
|
||||
__c = copysign(_Tp(0), __c);
|
||||
if (__libcpp_isnan(__d))
|
||||
if (__libcpp_isnan_or_builtin(__d))
|
||||
__d = copysign(_Tp(0), __d);
|
||||
__recalc = true;
|
||||
}
|
||||
if (__libcpp_isinf(__c) || __libcpp_isinf(__d))
|
||||
if (__libcpp_isinf_or_builtin(__c) || __libcpp_isinf_or_builtin(__d))
|
||||
{
|
||||
__c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
|
||||
__d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
|
||||
if (__libcpp_isnan(__a))
|
||||
__c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
|
||||
__d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
|
||||
if (__libcpp_isnan_or_builtin(__a))
|
||||
__a = copysign(_Tp(0), __a);
|
||||
if (__libcpp_isnan(__b))
|
||||
if (__libcpp_isnan_or_builtin(__b))
|
||||
__b = copysign(_Tp(0), __b);
|
||||
__recalc = true;
|
||||
}
|
||||
if (!__recalc && (__libcpp_isinf(__ac) || __libcpp_isinf(__bd) ||
|
||||
__libcpp_isinf(__ad) || __libcpp_isinf(__bc)))
|
||||
if (!__recalc && (__libcpp_isinf_or_builtin(__ac) || __libcpp_isinf_or_builtin(__bd) ||
|
||||
__libcpp_isinf_or_builtin(__ad) || __libcpp_isinf_or_builtin(__bc)))
|
||||
{
|
||||
if (__libcpp_isnan(__a))
|
||||
if (__libcpp_isnan_or_builtin(__a))
|
||||
__a = copysign(_Tp(0), __a);
|
||||
if (__libcpp_isnan(__b))
|
||||
if (__libcpp_isnan_or_builtin(__b))
|
||||
__b = copysign(_Tp(0), __b);
|
||||
if (__libcpp_isnan(__c))
|
||||
if (__libcpp_isnan_or_builtin(__c))
|
||||
__c = copysign(_Tp(0), __c);
|
||||
if (__libcpp_isnan(__d))
|
||||
if (__libcpp_isnan_or_builtin(__d))
|
||||
__d = copysign(_Tp(0), __d);
|
||||
__recalc = true;
|
||||
}
|
||||
@@ -674,7 +674,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
|
||||
_Tp __c = __w.real();
|
||||
_Tp __d = __w.imag();
|
||||
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
|
||||
if (__libcpp_isfinite(__logbw))
|
||||
if (__libcpp_isfinite_or_builtin(__logbw))
|
||||
{
|
||||
__ilogbw = static_cast<int>(__logbw);
|
||||
__c = scalbn(__c, -__ilogbw);
|
||||
@@ -683,24 +683,24 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
|
||||
_Tp __denom = __c * __c + __d * __d;
|
||||
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
|
||||
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
|
||||
if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
|
||||
if (__libcpp_isnan_or_builtin(__x) && __libcpp_isnan_or_builtin(__y))
|
||||
{
|
||||
if ((__denom == _Tp(0)) && (!__libcpp_isnan(__a) || !__libcpp_isnan(__b)))
|
||||
if ((__denom == _Tp(0)) && (!__libcpp_isnan_or_builtin(__a) || !__libcpp_isnan_or_builtin(__b)))
|
||||
{
|
||||
__x = copysign(_Tp(INFINITY), __c) * __a;
|
||||
__y = copysign(_Tp(INFINITY), __c) * __b;
|
||||
}
|
||||
else if ((__libcpp_isinf(__a) || __libcpp_isinf(__b)) && __libcpp_isfinite(__c) && __libcpp_isfinite(__d))
|
||||
else if ((__libcpp_isinf_or_builtin(__a) || __libcpp_isinf_or_builtin(__b)) && __libcpp_isfinite_or_builtin(__c) && __libcpp_isfinite_or_builtin(__d))
|
||||
{
|
||||
__a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
|
||||
__b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
|
||||
__a = copysign(__libcpp_isinf_or_builtin(__a) ? _Tp(1) : _Tp(0), __a);
|
||||
__b = copysign(__libcpp_isinf_or_builtin(__b) ? _Tp(1) : _Tp(0), __b);
|
||||
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
|
||||
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
|
||||
}
|
||||
else if (__libcpp_isinf(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite(__a) && __libcpp_isfinite(__b))
|
||||
else if (__libcpp_isinf_or_builtin(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite_or_builtin(__a) && __libcpp_isfinite_or_builtin(__b))
|
||||
{
|
||||
__c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
|
||||
__d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
|
||||
__c = copysign(__libcpp_isinf_or_builtin(__c) ? _Tp(1) : _Tp(0), __c);
|
||||
__d = copysign(__libcpp_isinf_or_builtin(__d) ? _Tp(1) : _Tp(0), __d);
|
||||
__x = _Tp(0) * (__a * __c + __b * __d);
|
||||
__y = _Tp(0) * (__b * __c - __a * __d);
|
||||
}
|
||||
@@ -910,9 +910,9 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
norm(const complex<_Tp>& __c)
|
||||
{
|
||||
if (__libcpp_isinf(__c.real()))
|
||||
if (__libcpp_isinf_or_builtin(__c.real()))
|
||||
return abs(__c.real());
|
||||
if (__libcpp_isinf(__c.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__c.imag()))
|
||||
return abs(__c.imag());
|
||||
return __c.real() * __c.real() + __c.imag() * __c.imag();
|
||||
}
|
||||
@@ -955,7 +955,7 @@ complex<_Tp>
|
||||
proj(const complex<_Tp>& __c)
|
||||
{
|
||||
std::complex<_Tp> __r = __c;
|
||||
if (__libcpp_isinf(__c.real()) || __libcpp_isinf(__c.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__c.real()) || __libcpp_isinf_or_builtin(__c.imag()))
|
||||
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
|
||||
return __r;
|
||||
}
|
||||
@@ -969,7 +969,7 @@ typename enable_if
|
||||
>::type
|
||||
proj(_Tp __re)
|
||||
{
|
||||
if (__libcpp_isinf(__re))
|
||||
if (__libcpp_isinf_or_builtin(__re))
|
||||
__re = abs(__re);
|
||||
return complex<_Tp>(__re);
|
||||
}
|
||||
@@ -991,27 +991,27 @@ proj(_Tp __re)
|
||||
|
||||
template<class _Tp>
|
||||
complex<_Tp>
|
||||
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
|
||||
polar(const _Tp& __rho, const _Tp& __theta = _Tp())
|
||||
{
|
||||
if (__libcpp_isnan(__rho) || signbit(__rho))
|
||||
if (__libcpp_isnan_or_builtin(__rho) || signbit(__rho))
|
||||
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
|
||||
if (__libcpp_isnan(__theta))
|
||||
if (__libcpp_isnan_or_builtin(__theta))
|
||||
{
|
||||
if (__libcpp_isinf(__rho))
|
||||
if (__libcpp_isinf_or_builtin(__rho))
|
||||
return complex<_Tp>(__rho, __theta);
|
||||
return complex<_Tp>(__theta, __theta);
|
||||
}
|
||||
if (__libcpp_isinf(__theta))
|
||||
if (__libcpp_isinf_or_builtin(__theta))
|
||||
{
|
||||
if (__libcpp_isinf(__rho))
|
||||
if (__libcpp_isinf_or_builtin(__rho))
|
||||
return complex<_Tp>(__rho, _Tp(NAN));
|
||||
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
|
||||
}
|
||||
_Tp __x = __rho * cos(__theta);
|
||||
if (__libcpp_isnan(__x))
|
||||
if (__libcpp_isnan_or_builtin(__x))
|
||||
__x = 0;
|
||||
_Tp __y = __rho * sin(__theta);
|
||||
if (__libcpp_isnan(__y))
|
||||
if (__libcpp_isnan_or_builtin(__y))
|
||||
__y = 0;
|
||||
return complex<_Tp>(__x, __y);
|
||||
}
|
||||
@@ -1042,13 +1042,13 @@ template<class _Tp>
|
||||
complex<_Tp>
|
||||
sqrt(const complex<_Tp>& __x)
|
||||
{
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(_Tp(INFINITY), __x.imag());
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (__x.real() > _Tp(0))
|
||||
return complex<_Tp>(__x.real(), __libcpp_isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
|
||||
return complex<_Tp>(__libcpp_isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
|
||||
return complex<_Tp>(__x.real(), __libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
|
||||
return complex<_Tp>(__libcpp_isnan_or_builtin(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
|
||||
}
|
||||
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
|
||||
}
|
||||
@@ -1060,21 +1060,21 @@ complex<_Tp>
|
||||
exp(const complex<_Tp>& __x)
|
||||
{
|
||||
_Tp __i = __x.imag();
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (__x.real() < _Tp(0))
|
||||
{
|
||||
if (!__libcpp_isfinite(__i))
|
||||
if (!__libcpp_isfinite_or_builtin(__i))
|
||||
__i = _Tp(1);
|
||||
}
|
||||
else if (__i == 0 || !__libcpp_isfinite(__i))
|
||||
else if (__i == 0 || !__libcpp_isfinite_or_builtin(__i))
|
||||
{
|
||||
if (__libcpp_isinf(__i))
|
||||
if (__libcpp_isinf_or_builtin(__i))
|
||||
__i = _Tp(NAN);
|
||||
return complex<_Tp>(__x.real(), __i);
|
||||
}
|
||||
}
|
||||
else if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
|
||||
else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
|
||||
return __x;
|
||||
_Tp __e = exp(__x.real());
|
||||
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
|
||||
@@ -1132,23 +1132,23 @@ complex<_Tp>
|
||||
asinh(const complex<_Tp>& __x)
|
||||
{
|
||||
const _Tp __pi(atan2(+0., -0.));
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isnan(__x.imag()))
|
||||
if (__libcpp_isnan_or_builtin(__x.imag()))
|
||||
return __x;
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
|
||||
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
|
||||
}
|
||||
if (__libcpp_isnan(__x.real()))
|
||||
if (__libcpp_isnan_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.imag(), __x.real());
|
||||
if (__x.imag() == 0)
|
||||
return __x;
|
||||
return complex<_Tp>(__x.real(), __x.real());
|
||||
}
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
|
||||
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
|
||||
@@ -1161,11 +1161,11 @@ complex<_Tp>
|
||||
acosh(const complex<_Tp>& __x)
|
||||
{
|
||||
const _Tp __pi(atan2(+0., -0.));
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isnan(__x.imag()))
|
||||
if (__libcpp_isnan_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(abs(__x.real()), __x.imag());
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
{
|
||||
if (__x.real() > 0)
|
||||
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
|
||||
@@ -1176,13 +1176,13 @@ acosh(const complex<_Tp>& __x)
|
||||
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
|
||||
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
|
||||
}
|
||||
if (__libcpp_isnan(__x.real()))
|
||||
if (__libcpp_isnan_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(abs(__x.imag()), __x.real());
|
||||
return complex<_Tp>(__x.real(), __x.real());
|
||||
}
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
|
||||
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
|
||||
@@ -1195,21 +1195,21 @@ complex<_Tp>
|
||||
atanh(const complex<_Tp>& __x)
|
||||
{
|
||||
const _Tp __pi(atan2(+0., -0.));
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
{
|
||||
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
}
|
||||
if (__libcpp_isnan(__x.imag()))
|
||||
if (__libcpp_isnan_or_builtin(__x.imag()))
|
||||
{
|
||||
if (__libcpp_isinf(__x.real()) || __x.real() == 0)
|
||||
if (__libcpp_isinf_or_builtin(__x.real()) || __x.real() == 0)
|
||||
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
|
||||
return complex<_Tp>(__x.imag(), __x.imag());
|
||||
}
|
||||
if (__libcpp_isnan(__x.real()))
|
||||
if (__libcpp_isnan_or_builtin(__x.real()))
|
||||
{
|
||||
return complex<_Tp>(__x.real(), __x.real());
|
||||
}
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
|
||||
}
|
||||
@@ -1227,11 +1227,11 @@ template<class _Tp>
|
||||
complex<_Tp>
|
||||
sinh(const complex<_Tp>& __x)
|
||||
{
|
||||
if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.real(), _Tp(NAN));
|
||||
if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
|
||||
if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.real(), _Tp(NAN));
|
||||
if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
|
||||
if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
|
||||
return __x;
|
||||
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
|
||||
}
|
||||
@@ -1242,13 +1242,13 @@ template<class _Tp>
|
||||
complex<_Tp>
|
||||
cosh(const complex<_Tp>& __x)
|
||||
{
|
||||
if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()) && !__libcpp_isfinite_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(abs(__x.real()), _Tp(NAN));
|
||||
if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
|
||||
if (__x.real() == 0 && !__libcpp_isfinite_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(_Tp(NAN), __x.real());
|
||||
if (__x.real() == 0 && __x.imag() == 0)
|
||||
return complex<_Tp>(_Tp(1), __x.imag());
|
||||
if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
|
||||
if (__x.imag() == 0 && !__libcpp_isfinite_or_builtin(__x.real()))
|
||||
return complex<_Tp>(abs(__x.real()), __x.imag());
|
||||
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
|
||||
}
|
||||
@@ -1259,19 +1259,19 @@ template<class _Tp>
|
||||
complex<_Tp>
|
||||
tanh(const complex<_Tp>& __x)
|
||||
{
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (!__libcpp_isfinite(__x.imag()))
|
||||
if (!__libcpp_isfinite_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(_Tp(1), _Tp(0));
|
||||
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
|
||||
}
|
||||
if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
|
||||
if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
|
||||
return __x;
|
||||
_Tp __2r(_Tp(2) * __x.real());
|
||||
_Tp __2i(_Tp(2) * __x.imag());
|
||||
_Tp __d(cosh(__2r) + cos(__2i));
|
||||
_Tp __2rsh(sinh(__2r));
|
||||
if (__libcpp_isinf(__2rsh) && __libcpp_isinf(__d))
|
||||
if (__libcpp_isinf_or_builtin(__2rsh) && __libcpp_isinf_or_builtin(__d))
|
||||
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
|
||||
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
|
||||
return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
|
||||
@@ -1294,11 +1294,11 @@ complex<_Tp>
|
||||
acos(const complex<_Tp>& __x)
|
||||
{
|
||||
const _Tp __pi(atan2(+0., -0.));
|
||||
if (__libcpp_isinf(__x.real()))
|
||||
if (__libcpp_isinf_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isnan(__x.imag()))
|
||||
if (__libcpp_isnan_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.imag(), __x.real());
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
{
|
||||
if (__x.real() < _Tp(0))
|
||||
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
|
||||
@@ -1308,13 +1308,13 @@ acos(const complex<_Tp>& __x)
|
||||
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
|
||||
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
|
||||
}
|
||||
if (__libcpp_isnan(__x.real()))
|
||||
if (__libcpp_isnan_or_builtin(__x.real()))
|
||||
{
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__x.real(), -__x.imag());
|
||||
return complex<_Tp>(__x.real(), __x.real());
|
||||
}
|
||||
if (__libcpp_isinf(__x.imag()))
|
||||
if (__libcpp_isinf_or_builtin(__x.imag()))
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
|
||||
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
|
||||
|
||||
@@ -64,23 +64,46 @@ namespace std // purposefully not versioned
|
||||
{
|
||||
enum class byte : unsigned char {};
|
||||
|
||||
constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator| (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = __lhs | __rhs; }
|
||||
|
||||
constexpr byte operator& (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator& (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
|
||||
{ return __lhs = __lhs & __rhs; }
|
||||
|
||||
constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
|
||||
{ return __lhs = __lhs ^ __rhs; }
|
||||
|
||||
constexpr byte operator~ (byte __b) noexcept
|
||||
{ return byte(~static_cast<unsigned char>(__b)); }
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
~static_cast<unsigned int>(__b)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1314,7 +1314,7 @@ public:
|
||||
void resize(size_type __n);
|
||||
void resize(size_type __n, const value_type& __v);
|
||||
void shrink_to_fit() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __base::size() == 0;}
|
||||
|
||||
// element access:
|
||||
@@ -1356,7 +1356,6 @@ public:
|
||||
iterator insert(const_iterator __p, initializer_list<value_type> __il)
|
||||
{return insert(__p, __il.begin(), __il.end());}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
iterator insert(const_iterator __p, const value_type& __v);
|
||||
iterator insert(const_iterator __p, size_type __n, const value_type& __v);
|
||||
template <class _InputIter>
|
||||
@@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l,
|
||||
!__is_forward_iterator<_InpIter>::value>::type*)
|
||||
{
|
||||
for (; __f != __l; ++__f)
|
||||
#ifdef _LIBCPP_CXX03_LANG
|
||||
push_back(*__f);
|
||||
#else
|
||||
emplace_back(*__f);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class _Tp, class _Allocator>
|
||||
|
||||
@@ -82,7 +82,7 @@ template <class E> void rethrow_if_nested(const E& e);
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include <vcruntime_exception.h>
|
||||
#endif
|
||||
|
||||
@@ -93,7 +93,7 @@ template <class E> void rethrow_if_nested(const E& e);
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
|
||||
class _LIBCPP_EXCEPTION_ABI exception
|
||||
{
|
||||
public:
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
virtual ~bad_exception() _NOEXCEPT;
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 \
|
||||
|| defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \
|
||||
|
||||
@@ -23,11 +23,8 @@ 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);
|
||||
|
||||
// sample removed because it's now part of C++17
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
@@ -56,16 +53,6 @@ _LIBCPP_INLINE_VISIBILITY
|
||||
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
|
||||
{ return __s(__f, __l).first; }
|
||||
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
|
||||
_SampleIterator __output, _Distance __n,
|
||||
_UniformRandomNumberGenerator &&__g) {
|
||||
return _VSTD::__sample(__first, __last, __output, __n, __g);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
@@ -8,584 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 11 // C++ > 11
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
void __throw_bad_any_cast()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_any_cast();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Forward declarations
|
||||
class any;
|
||||
|
||||
template <class _ValueType>
|
||||
typename add_pointer<typename add_const<_ValueType>::type>::type
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any_cast(any const *) _NOEXCEPT;
|
||||
|
||||
template <class _ValueType>
|
||||
typename add_pointer<_ValueType>::type
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
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>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any(_ValueType && __value);
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~any()
|
||||
{
|
||||
this->clear();
|
||||
}
|
||||
|
||||
// 6.3.2 any assignments
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any const & __rhs)
|
||||
{
|
||||
any(__rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(any && __rhs) _NOEXCEPT
|
||||
{
|
||||
any(_VSTD::move(__rhs)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <
|
||||
class _ValueType
|
||||
, class = __any_imp::_EnableIfNotAny<_ValueType>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
any & operator=(_ValueType && __rhs);
|
||||
|
||||
// 6.3.3 any modifiers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
if (__h) this->__call(_Action::_Destroy);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __rhs) _NOEXCEPT;
|
||||
|
||||
// 6.3.4 any observers
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT
|
||||
{
|
||||
return __h == nullptr;
|
||||
}
|
||||
|
||||
#if !defined(_LIBCPP_NO_RTTI)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const type_info & type() const _NOEXCEPT
|
||||
{
|
||||
if (__h) {
|
||||
return *static_cast<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_TEMPLATE_VIS _SmallHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<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_TEMPLATE_VIS _LargeHandler
|
||||
{
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static void* __handle(_Action __act, any const * __this, any * __other,
|
||||
type_info const * __info)
|
||||
{
|
||||
switch (__act)
|
||||
{
|
||||
case _Action::_Destroy:
|
||||
__destroy(const_cast<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>
|
||||
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>
|
||||
any & any::operator=(_ValueType && __v)
|
||||
{
|
||||
typedef typename decay<_ValueType>::type _Tp;
|
||||
static_assert(is_copy_constructible<_Tp>::value,
|
||||
"_ValueType must be CopyConstructible.");
|
||||
any(_VSTD::forward<_ValueType>(__v)).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
void any::swap(any & __rhs) _NOEXCEPT
|
||||
{
|
||||
if (__h && __rhs.__h) {
|
||||
any __tmp;
|
||||
__rhs.__call(_Action::_Move, &__tmp);
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
__tmp.__call(_Action::_Move, this);
|
||||
}
|
||||
else if (__h) {
|
||||
this->__call(_Action::_Move, &__rhs);
|
||||
}
|
||||
else if (__rhs.__h) {
|
||||
__rhs.__call(_Action::_Move, this);
|
||||
}
|
||||
}
|
||||
|
||||
// 6.4 Non-member functions
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(any & __lhs, any & __rhs) _NOEXCEPT
|
||||
{
|
||||
__lhs.swap(__rhs);
|
||||
}
|
||||
|
||||
template <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
|
||||
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>
|
||||
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
|
||||
#error "<experimental/any> has been removed. Use <any> instead."
|
||||
|
||||
@@ -8,52 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
|
||||
#define _LIBCPP_EXPERIMENTAL_CHRONO
|
||||
|
||||
/**
|
||||
experimental/chrono synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace std {
|
||||
namespace chrono {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.12.4, customization traits
|
||||
template <class Rep> constexpr bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<Rep>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace chrono
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <chrono>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_CHRONO_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
template <class _Rep> _LIBCPP_CONSTEXPR bool treat_as_floating_point_v
|
||||
= treat_as_floating_point<_Rep>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_CHRONO_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_CHRONO */
|
||||
#error "<experimental/chrono> has been removed. Use <chrono> instead."
|
||||
|
||||
@@ -250,9 +250,11 @@ public:
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
|
||||
typedef typename remove_cv<_Promise>::type _RawPromise;
|
||||
coroutine_handle __tmp;
|
||||
__tmp.__handle_ = __builtin_coro_promise(_VSTD::addressof(__promise),
|
||||
__alignof(_Promise), true);
|
||||
__tmp.__handle_ = __builtin_coro_promise(
|
||||
_VSTD::addressof(const_cast<_RawPromise&>(__promise)),
|
||||
__alignof(_Promise), true);
|
||||
return __tmp;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,12 +28,13 @@
|
||||
|
||||
path operator/ (const path& lhs, const path& rhs);
|
||||
|
||||
// fs.path.io operators are friends of path.
|
||||
template <class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
friend basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os, const path& p);
|
||||
|
||||
template <class charT, class traits>
|
||||
basic_istream<charT, traits>&
|
||||
friend basic_istream<charT, traits>&
|
||||
operator>>(basic_istream<charT, traits>& is, path& p);
|
||||
|
||||
template <class Source>
|
||||
@@ -81,23 +82,23 @@
|
||||
path canonical(const path& p, const path& base, error_code& ec);
|
||||
|
||||
void copy(const path& from, const path& to);
|
||||
void copy(const path& from, const path& to, error_code& ec) _NOEXCEPT;
|
||||
void copy(const path& from, const path& to, error_code& ec);
|
||||
void copy(const path& from, const path& to, copy_options options);
|
||||
void copy(const path& from, const path& to, copy_options options,
|
||||
error_code& ec) _NOEXCEPT;
|
||||
error_code& ec);
|
||||
|
||||
bool copy_file(const path& from, const path& to);
|
||||
bool copy_file(const path& from, const path& to, error_code& ec) _NOEXCEPT;
|
||||
bool copy_file(const path& from, const path& to, error_code& ec);
|
||||
bool copy_file(const path& from, const path& to, copy_options option);
|
||||
bool copy_file(const path& from, const path& to, copy_options option,
|
||||
error_code& ec) _NOEXCEPT;
|
||||
error_code& ec);
|
||||
|
||||
void copy_symlink(const path& existing_symlink, const path& new_symlink);
|
||||
void copy_symlink(const path& existing_symlink, const path& new_symlink,
|
||||
error_code& ec) _NOEXCEPT;
|
||||
|
||||
bool create_directories(const path& p);
|
||||
bool create_directories(const path& p, error_code& ec) _NOEXCEPT;
|
||||
bool create_directories(const path& p, error_code& ec);
|
||||
|
||||
bool create_directory(const path& p);
|
||||
bool create_directory(const path& p, error_code& ec) _NOEXCEPT;
|
||||
@@ -187,7 +188,7 @@
|
||||
bool remove(const path& p, error_code& ec) _NOEXCEPT;
|
||||
|
||||
uintmax_t remove_all(const path& p);
|
||||
uintmax_t remove_all(const path& p, error_code& ec) _NOEXCEPT;
|
||||
uintmax_t remove_all(const path& p, error_code& ec);
|
||||
|
||||
void rename(const path& from, const path& to);
|
||||
void rename(const path& from, const path& to, error_code& ec) _NOEXCEPT;
|
||||
@@ -972,7 +973,8 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY path extension() const { return string_type(__extension()); }
|
||||
|
||||
// query
|
||||
_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT { return __pn_.empty(); }
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT { return __pn_.empty(); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY bool has_root_name() const { return !__root_name().empty(); }
|
||||
_LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { return !__root_directory().empty(); }
|
||||
@@ -993,6 +995,40 @@ public:
|
||||
iterator begin() const;
|
||||
iterator end() const;
|
||||
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend typename enable_if<is_same<_CharT, char>::value &&
|
||||
is_same<_Traits, char_traits<char>>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
|
||||
__os << std::__quoted(__p.native());
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend typename enable_if<!is_same<_CharT, char>::value ||
|
||||
!is_same<_Traits, char_traits<char>>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
|
||||
__os << std::__quoted(__p.string<_CharT, _Traits>());
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
friend basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, path& __p)
|
||||
{
|
||||
basic_string<_CharT, _Traits> __tmp;
|
||||
__is >> __quoted(__tmp);
|
||||
__p = __tmp;
|
||||
return __is;
|
||||
}
|
||||
|
||||
private:
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
path& __assign_view(__string_view const& __s) noexcept { __pn_ = string_type(__s); return *this; }
|
||||
@@ -1036,39 +1072,6 @@ path operator/(const path& __lhs, const path& __rhs) {
|
||||
return path(__lhs) /= __rhs;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<is_same<_CharT, char>::value &&
|
||||
is_same<_Traits, char_traits<char>>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
|
||||
__os << std::__quoted(__p.native());
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<!is_same<_CharT, char>::value ||
|
||||
!is_same<_Traits, char_traits<char>>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
|
||||
__os << std::__quoted(__p.string<_CharT, _Traits>());
|
||||
return __os;
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_istream<_CharT, _Traits>&
|
||||
operator>>(basic_istream<_CharT, _Traits>& __is, path& __p)
|
||||
{
|
||||
basic_string<_CharT, _Traits> __tmp;
|
||||
__is >> __quoted(__tmp);
|
||||
__p = __tmp;
|
||||
return __is;
|
||||
}
|
||||
|
||||
template <class _Source>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<__is_pathable<_Source>::value, path>::type
|
||||
@@ -1351,7 +1354,7 @@ void copy(const path& __from, const path& __to) {
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void copy(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT {
|
||||
void copy(const path& __from, const path& __to, error_code& __ec) {
|
||||
__copy(__from, __to, copy_options::none, &__ec);
|
||||
}
|
||||
|
||||
@@ -1362,7 +1365,7 @@ void copy(const path& __from, const path& __to, copy_options __opt) {
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void copy(const path& __from, const path& __to,
|
||||
copy_options __opt, error_code& __ec) _NOEXCEPT {
|
||||
copy_options __opt, error_code& __ec) {
|
||||
__copy(__from, __to, __opt, &__ec);
|
||||
}
|
||||
|
||||
@@ -1372,7 +1375,7 @@ bool copy_file(const path& __from, const path& __to) {
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool copy_file(const path& __from, const path& __to, error_code& __ec) _NOEXCEPT {
|
||||
bool copy_file(const path& __from, const path& __to, error_code& __ec) {
|
||||
return __copy_file(__from, __to, copy_options::none, &__ec);
|
||||
}
|
||||
|
||||
@@ -1383,7 +1386,7 @@ bool copy_file(const path& __from, const path& __to, copy_options __opt) {
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool copy_file(const path& __from, const path& __to,
|
||||
copy_options __opt, error_code& __ec) _NOEXCEPT {
|
||||
copy_options __opt, error_code& __ec){
|
||||
return __copy_file(__from, __to, __opt, &__ec);
|
||||
}
|
||||
|
||||
@@ -1403,7 +1406,7 @@ bool create_directories(const path& __p) {
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool create_directories(const path& __p, error_code& __ec) _NOEXCEPT {
|
||||
bool create_directories(const path& __p, error_code& __ec) {
|
||||
return __create_directories(__p, &__ec);
|
||||
}
|
||||
|
||||
@@ -1561,7 +1564,7 @@ bool is_empty(const path& __p) {
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool is_empty(const path& __p, error_code& __ec) _NOEXCEPT {
|
||||
bool is_empty(const path& __p, error_code& __ec) {
|
||||
return __fs_is_empty(__p, &__ec);
|
||||
}
|
||||
|
||||
@@ -1696,7 +1699,7 @@ uintmax_t remove_all(const path& __p) {
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
uintmax_t remove_all(const path& __p, error_code& __ec) _NOEXCEPT {
|
||||
uintmax_t remove_all(const path& __p, error_code& __ec) {
|
||||
return __remove_all(__p, &__ec);
|
||||
}
|
||||
|
||||
@@ -1903,12 +1906,12 @@ public:
|
||||
: directory_iterator(__p, nullptr, __opts)
|
||||
{ }
|
||||
|
||||
directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT
|
||||
directory_iterator(const path& __p, error_code& __ec)
|
||||
: directory_iterator(__p, &__ec)
|
||||
{ }
|
||||
|
||||
directory_iterator(const path& __p, directory_options __opts,
|
||||
error_code& __ec) _NOEXCEPT
|
||||
error_code& __ec)
|
||||
: directory_iterator(__p, &__ec, __opts)
|
||||
{ }
|
||||
|
||||
@@ -1943,7 +1946,7 @@ public:
|
||||
return __p;
|
||||
}
|
||||
|
||||
directory_iterator& increment(error_code& __ec) _NOEXCEPT
|
||||
directory_iterator& increment(error_code& __ec)
|
||||
{ return __increment(&__ec); }
|
||||
|
||||
private:
|
||||
@@ -2013,12 +2016,12 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
recursive_directory_iterator(const path& __p,
|
||||
directory_options __xoptions, error_code& __ec) _NOEXCEPT
|
||||
directory_options __xoptions, error_code& __ec)
|
||||
: recursive_directory_iterator(__p, __xoptions, &__ec)
|
||||
{ }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
recursive_directory_iterator(const path& __p, error_code& __ec) _NOEXCEPT
|
||||
recursive_directory_iterator(const path& __p, error_code& __ec)
|
||||
: recursive_directory_iterator(__p, directory_options::none, &__ec)
|
||||
{ }
|
||||
|
||||
@@ -2060,7 +2063,7 @@ public:
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
recursive_directory_iterator& increment(error_code& __ec) _NOEXCEPT
|
||||
recursive_directory_iterator& increment(error_code& __ec)
|
||||
{ return __increment(&__ec); }
|
||||
|
||||
_LIBCPP_FUNC_VIS directory_options options() const;
|
||||
|
||||
@@ -75,19 +75,19 @@ public:
|
||||
typedef void reference;
|
||||
|
||||
ostream_joiner(ostream_type& __os, _Delim&& __d)
|
||||
: __output(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
|
||||
: __output_iter(_VSTD::addressof(__os)), __delim(_VSTD::move(__d)), __first(true) {}
|
||||
|
||||
ostream_joiner(ostream_type& __os, const _Delim& __d)
|
||||
: __output(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
|
||||
: __output_iter(_VSTD::addressof(__os)), __delim(__d), __first(true) {}
|
||||
|
||||
|
||||
template<typename _Tp>
|
||||
ostream_joiner& operator=(const _Tp& __v)
|
||||
{
|
||||
if (!__first)
|
||||
*__output << __delim;
|
||||
*__output_iter << __delim;
|
||||
__first = false;
|
||||
*__output << __v;
|
||||
*__output_iter << __v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
ostream_joiner& operator++(int) _NOEXCEPT { return *this; }
|
||||
|
||||
private:
|
||||
ostream_type* __output;
|
||||
ostream_type* __output_iter;
|
||||
_Delim __delim;
|
||||
bool __first;
|
||||
};
|
||||
|
||||
@@ -8,112 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
|
||||
#define _LIBCPP_EXPERIMENTAL_NUMERIC
|
||||
/*
|
||||
experimental/numeric synopsis
|
||||
|
||||
// C++1z
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v2 {
|
||||
|
||||
// 13.1.2, Greatest common divisor
|
||||
template<class M, class N>
|
||||
constexpr common_type_t<M,N> gcd(M m, N n);
|
||||
|
||||
// 13.1.3, Least common multiple
|
||||
template<class M, class N>
|
||||
constexpr common_type_t<M,N> lcm(M m, N n);
|
||||
|
||||
} // namespace fundamentals_v2
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <numeric>
|
||||
#include <type_traits> // is_integral
|
||||
#include <limits> // numeric_limits
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
|
||||
|
||||
template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;
|
||||
|
||||
template <typename _Result, typename _Source>
|
||||
struct __abs<_Result, _Source, true> {
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
_Result operator()(_Source __t) const noexcept
|
||||
{
|
||||
if (__t >= 0) return __t;
|
||||
if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
|
||||
return -__t;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename _Result, typename _Source>
|
||||
struct __abs<_Result, _Source, false> {
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
_Result operator()(_Source __t) const noexcept { return __t; }
|
||||
};
|
||||
|
||||
|
||||
template<class _Tp>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
|
||||
inline _Tp __gcd(_Tp __m, _Tp __n)
|
||||
{
|
||||
static_assert((!is_signed<_Tp>::value), "" );
|
||||
return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
|
||||
}
|
||||
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
common_type_t<_Tp,_Up>
|
||||
gcd(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
|
||||
using _Rp = common_type_t<_Tp,_Up>;
|
||||
using _Wp = make_unsigned_t<_Rp>;
|
||||
return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
|
||||
static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
|
||||
static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
common_type_t<_Tp,_Up>
|
||||
lcm(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
|
||||
if (__m == 0 || __n == 0)
|
||||
return 0;
|
||||
|
||||
using _Rp = common_type_t<_Tp,_Up>;
|
||||
_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
|
||||
_Rp __val2 = __abs<_Rp, _Up>()(__n);
|
||||
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
|
||||
return __val1 * __val2;
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS_V2
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */
|
||||
#error "<experimental/numeric> has been removed. Use <numeric> instead."
|
||||
|
||||
@@ -8,915 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
#define _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
|
||||
/*
|
||||
optional synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
namespace std { namespace experimental { inline namespace fundamentals_v1 {
|
||||
|
||||
// 5.3, optional for object types
|
||||
template <class T> class optional;
|
||||
|
||||
// 5.4, In-place construction
|
||||
struct in_place_t{};
|
||||
constexpr in_place_t in_place{};
|
||||
|
||||
// 5.5, No-value state indicator
|
||||
struct nullopt_t{see below};
|
||||
constexpr nullopt_t nullopt(unspecified);
|
||||
|
||||
// 5.6, Class bad_optional_access
|
||||
class bad_optional_access;
|
||||
|
||||
// 5.7, Relational operators
|
||||
template <class T>
|
||||
constexpr bool operator==(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator!=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator<=(const optional<T>&, const optional<T>&);
|
||||
template <class T>
|
||||
constexpr bool operator>=(const optional<T>&, const optional<T>&);
|
||||
|
||||
// 5.8, Comparison with nullopt
|
||||
template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator!=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>(nullopt_t, const optional<T>&) noexcept;
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept;
|
||||
template <class T> constexpr bool operator>=(nullopt_t, const optional<T>&) noexcept;
|
||||
|
||||
// 5.9, Comparison with T
|
||||
template <class T> constexpr bool operator==(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator==(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator!=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator!=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator<=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator<=(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>(const T&, const optional<T>&);
|
||||
template <class T> constexpr bool operator>=(const optional<T>&, const T&);
|
||||
template <class T> constexpr bool operator>=(const T&, const optional<T>&);
|
||||
|
||||
// 5.10, Specialized algorithms
|
||||
template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below);
|
||||
template <class T> constexpr optional<see below> make_optional(T&&);
|
||||
|
||||
template <class T>
|
||||
class optional
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
// 5.3.1, Constructors
|
||||
constexpr optional() noexcept;
|
||||
constexpr optional(nullopt_t) noexcept;
|
||||
optional(const optional&);
|
||||
optional(optional&&) noexcept(see below);
|
||||
constexpr optional(const T&);
|
||||
constexpr optional(T&&);
|
||||
template <class... Args> constexpr explicit optional(in_place_t, Args&&...);
|
||||
template <class U, class... Args>
|
||||
constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...);
|
||||
|
||||
// 5.3.2, Destructor
|
||||
~optional();
|
||||
|
||||
// 5.3.3, Assignment
|
||||
optional& operator=(nullopt_t) noexcept;
|
||||
optional& operator=(const optional&);
|
||||
optional& operator=(optional&&) noexcept(see below);
|
||||
template <class U> optional& operator=(U&&);
|
||||
template <class... Args> void emplace(Args&&...);
|
||||
template <class U, class... Args>
|
||||
void emplace(initializer_list<U>, Args&&...);
|
||||
|
||||
// 5.3.4, Swap
|
||||
void swap(optional&) noexcept(see below);
|
||||
|
||||
// 5.3.5, Observers
|
||||
constexpr T const* operator ->() const;
|
||||
constexpr T* operator ->();
|
||||
constexpr T const& operator *() const &;
|
||||
constexpr T& operator *() &;
|
||||
constexpr T&& operator *() &&;
|
||||
constexpr const T&& operator *() const &&;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
constexpr T const& value() const &;
|
||||
constexpr T& value() &;
|
||||
constexpr T&& value() &&;
|
||||
constexpr const T&& value() const &&;
|
||||
template <class U> constexpr T value_or(U&&) const &;
|
||||
template <class U> constexpr T value_or(U&&) &&;
|
||||
|
||||
private:
|
||||
T* val; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 5.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <class T> struct hash<experimental::optional<T>>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
#include <new>
|
||||
#include <__functional_base>
|
||||
#include <__debug>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
|
||||
class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
|
||||
: public std::logic_error
|
||||
{
|
||||
public:
|
||||
bad_optional_access() : std::logic_error("Bad optional Access") {}
|
||||
|
||||
// Get the key function ~bad_optional_access() into the dylib
|
||||
virtual ~bad_optional_access() _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_EXPERIMENTAL
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
struct in_place_t {};
|
||||
constexpr in_place_t in_place{};
|
||||
|
||||
struct nullopt_t
|
||||
{
|
||||
explicit constexpr nullopt_t(int) noexcept {}
|
||||
};
|
||||
|
||||
constexpr nullopt_t nullopt{0};
|
||||
|
||||
template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
|
||||
class __optional_storage
|
||||
{
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
union
|
||||
{
|
||||
char __null_state_;
|
||||
value_type __val_;
|
||||
};
|
||||
bool __engaged_ = false;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
~__optional_storage()
|
||||
{
|
||||
if (__engaged_)
|
||||
__val_.~value_type();
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage() noexcept
|
||||
: __null_state_('\0') {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(const __optional_storage& __x)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(__optional_storage&& __x)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(const value_type& __v)
|
||||
: __val_(__v),
|
||||
__engaged_(true) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(value_type&& __v)
|
||||
: __val_(_VSTD::move(__v)),
|
||||
__engaged_(true) {}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit __optional_storage(in_place_t, _Args&&... __args)
|
||||
: __val_(_VSTD::forward<_Args>(__args)...),
|
||||
__engaged_(true) {}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class __optional_storage<_Tp, true>
|
||||
{
|
||||
protected:
|
||||
typedef _Tp value_type;
|
||||
union
|
||||
{
|
||||
char __null_state_;
|
||||
value_type __val_;
|
||||
};
|
||||
bool __engaged_ = false;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage() noexcept
|
||||
: __null_state_('\0') {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(const __optional_storage& __x)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(__optional_storage&& __x)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value)
|
||||
: __engaged_(__x.__engaged_)
|
||||
{
|
||||
if (__engaged_)
|
||||
::new((void*)_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(const value_type& __v)
|
||||
: __val_(__v),
|
||||
__engaged_(true) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr __optional_storage(value_type&& __v)
|
||||
: __val_(_VSTD::move(__v)),
|
||||
__engaged_(true) {}
|
||||
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit __optional_storage(in_place_t, _Args&&... __args)
|
||||
: __val_(_VSTD::forward<_Args>(__args)...),
|
||||
__engaged_(true) {}
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
class optional
|
||||
: private __optional_storage<_Tp>
|
||||
{
|
||||
typedef __optional_storage<_Tp> __base;
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
|
||||
static_assert(!is_reference<value_type>::value,
|
||||
"Instantiation of optional with a reference type is ill-formed.");
|
||||
static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value,
|
||||
"Instantiation of optional with a in_place_t type is ill-formed.");
|
||||
static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value,
|
||||
"Instantiation of optional with a nullopt_t type is ill-formed.");
|
||||
static_assert(is_object<value_type>::value,
|
||||
"Instantiation of optional with a non-object type is undefined behavior.");
|
||||
static_assert(is_nothrow_destructible<value_type>::value,
|
||||
"Instantiation of optional with an object type that is not noexcept destructible is undefined behavior.");
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {}
|
||||
_LIBCPP_INLINE_VISIBILITY optional(const optional&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY optional(optional&&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY ~optional() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v)
|
||||
: __base(__v) {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v)
|
||||
: __base(_VSTD::move(__v)) {}
|
||||
|
||||
template <class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit optional(in_place_t, _Args&&... __args)
|
||||
: __base(in_place, _VSTD::forward<_Args>(__args)...) {}
|
||||
|
||||
template <class _Up, class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
|
||||
: __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional& operator=(nullopt_t) noexcept
|
||||
{
|
||||
if (this->__engaged_)
|
||||
{
|
||||
this->__val_.~value_type();
|
||||
this->__engaged_ = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(const optional& __opt)
|
||||
{
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = __opt.__val_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_.~value_type();
|
||||
else
|
||||
::new((void*)_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
|
||||
this->__engaged_ = __opt.__engaged_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(optional&& __opt)
|
||||
noexcept(is_nothrow_move_assignable<value_type>::value &&
|
||||
is_nothrow_move_constructible<value_type>::value)
|
||||
{
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = _VSTD::move(__opt.__val_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_.~value_type();
|
||||
else
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::move(__opt.__val_));
|
||||
this->__engaged_ = __opt.__engaged_;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Up,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_same<typename remove_reference<_Up>::type, value_type>::value &&
|
||||
is_constructible<value_type, _Up>::value &&
|
||||
is_assignable<value_type&, _Up>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
operator=(_Up&& __v)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
this->__val_ = _VSTD::forward<_Up>(__v);
|
||||
else
|
||||
{
|
||||
::new((void*)_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v));
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
emplace(_Args&&... __args)
|
||||
{
|
||||
*this = nullopt;
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::forward<_Args>(__args)...);
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
|
||||
template <class _Up, class... _Args,
|
||||
class = typename enable_if
|
||||
<
|
||||
is_constructible<value_type, initializer_list<_Up>&, _Args...>::value
|
||||
>::type
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
emplace(initializer_list<_Up> __il, _Args&&... __args)
|
||||
{
|
||||
*this = nullopt;
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(__il, _VSTD::forward<_Args>(__args)...);
|
||||
this->__engaged_ = true;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(optional& __opt)
|
||||
noexcept(is_nothrow_move_constructible<value_type>::value &&
|
||||
__is_nothrow_swappable<value_type>::value)
|
||||
{
|
||||
using _VSTD::swap;
|
||||
if (this->__engaged_ == __opt.__engaged_)
|
||||
{
|
||||
if (this->__engaged_)
|
||||
swap(this->__val_, __opt.__val_);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->__engaged_)
|
||||
{
|
||||
::new((void*)_VSTD::addressof(__opt.__val_))
|
||||
value_type(_VSTD::move(this->__val_));
|
||||
this->__val_.~value_type();
|
||||
}
|
||||
else
|
||||
{
|
||||
::new((void*)_VSTD::addressof(this->__val_))
|
||||
value_type(_VSTD::move(__opt.__val_));
|
||||
__opt.__val_.~value_type();
|
||||
}
|
||||
swap(this->__engaged_, __opt.__engaged_);
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
value_type const*
|
||||
operator->() const
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
|
||||
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
|
||||
return __builtin_addressof(this->__val_);
|
||||
#else
|
||||
return __operator_arrow(__has_operator_addressof<value_type>{});
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type*
|
||||
operator->()
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
|
||||
return _VSTD::addressof(this->__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
const value_type&
|
||||
operator*() const
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type&
|
||||
operator*()
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value");
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit operator bool() const noexcept {return this->__engaged_;}
|
||||
|
||||
_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
#endif
|
||||
constexpr void __throw_bad_optional_access() const
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_optional_access();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
constexpr value_type const& value() const
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
__throw_bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
|
||||
value_type& value()
|
||||
{
|
||||
if (!this->__engaged_)
|
||||
__throw_bad_optional_access();
|
||||
return this->__val_;
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr value_type value_or(_Up&& __v) const&
|
||||
{
|
||||
static_assert(is_copy_constructible<value_type>::value,
|
||||
"optional<T>::value_or: T must be copy constructible");
|
||||
static_assert(is_convertible<_Up, value_type>::value,
|
||||
"optional<T>::value_or: U must be convertible to T");
|
||||
return this->__engaged_ ? this->__val_ :
|
||||
static_cast<value_type>(_VSTD::forward<_Up>(__v));
|
||||
}
|
||||
|
||||
template <class _Up>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type value_or(_Up&& __v) &&
|
||||
{
|
||||
static_assert(is_move_constructible<value_type>::value,
|
||||
"optional<T>::value_or: T must be move constructible");
|
||||
static_assert(is_convertible<_Up, value_type>::value,
|
||||
"optional<T>::value_or: U must be convertible to T");
|
||||
return this->__engaged_ ? _VSTD::move(this->__val_) :
|
||||
static_cast<value_type>(_VSTD::forward<_Up>(__v));
|
||||
}
|
||||
|
||||
private:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type const*
|
||||
__operator_arrow(true_type) const
|
||||
{
|
||||
return _VSTD::addressof(this->__val_);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
value_type const*
|
||||
__operator_arrow(false_type) const
|
||||
{
|
||||
return &this->__val_;
|
||||
}
|
||||
};
|
||||
|
||||
// Comparisons between optionals
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
if (static_cast<bool>(__x) != static_cast<bool>(__y))
|
||||
return false;
|
||||
if (!static_cast<bool>(__x))
|
||||
return true;
|
||||
return *__x == *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
if (!static_cast<bool>(__y))
|
||||
return false;
|
||||
if (!static_cast<bool>(__x))
|
||||
return true;
|
||||
return *__x < *__y;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return __y < __x;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__y < __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
|
||||
{
|
||||
return !(__x < __y);
|
||||
}
|
||||
|
||||
|
||||
// Comparisons with nullopt
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>&, nullopt_t) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(nullopt_t, const optional<_Tp>&) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, nullopt_t) noexcept
|
||||
{
|
||||
return static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(nullopt_t, const optional<_Tp>&) noexcept
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>&, nullopt_t) noexcept
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
|
||||
{
|
||||
return !static_cast<bool>(__x);
|
||||
}
|
||||
|
||||
// Comparisons with T
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? *__x == __v : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator==(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? *__x == __v : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator!=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? !(*__x == __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x > __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator<=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v > __x);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __v < __x : false;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return static_cast<bool>(__x) ? __x < __v : true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const optional<_Tp>& __x, const _Tp& __v)
|
||||
{
|
||||
return !(__x < __v);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
bool
|
||||
operator>=(const _Tp& __v, const optional<_Tp>& __x)
|
||||
{
|
||||
return !(__v < __x);
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y)))
|
||||
{
|
||||
__x.swap(__y);
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr
|
||||
optional<typename decay<_Tp>::type>
|
||||
make_optional(_Tp&& __v)
|
||||
{
|
||||
return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v));
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::optional<_Tp> >
|
||||
{
|
||||
typedef std::experimental::optional<_Tp> argument_type;
|
||||
typedef size_t result_type;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
result_type operator()(const argument_type& __opt) const _NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0;
|
||||
}
|
||||
};
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 11
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL
|
||||
#error "<experimental/optional> has been removed. Use <optional> instead."
|
||||
|
||||
@@ -8,70 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_RATIO
|
||||
#define _LIBCPP_EXPERIMENTAL_RATIO
|
||||
|
||||
/**
|
||||
experimental/ratio synopsis
|
||||
C++1y
|
||||
#include <ratio>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.11.5, ratio comparison
|
||||
template <class R1, class R2> constexpr bool ratio_equal_v
|
||||
= ratio_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_not_equal_v
|
||||
= ratio_not_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_less_v
|
||||
= ratio_less<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_less_equal_v
|
||||
= ratio_less_equal<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_greater_v
|
||||
= ratio_greater<R1, R2>::value;
|
||||
template <class R1, class R2> constexpr bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<R1, R2>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <ratio>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
|
||||
= ratio_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
|
||||
= ratio_not_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
|
||||
= ratio_less<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
|
||||
= ratio_less_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
|
||||
= ratio_greater<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<_R1, _R2>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif // _LIBCPP_EXPERIMENTAL_RATIO
|
||||
#error "<experimental/ratio> has been removed. Use <ratio> instead."
|
||||
|
||||
@@ -8,811 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_LFTS_STRING_VIEW
|
||||
#define _LIBCPP_LFTS_STRING_VIEW
|
||||
|
||||
/*
|
||||
string_view synopsis
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace library_fundamentals_v1 {
|
||||
|
||||
// 7.2, Class template basic_string_view
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view;
|
||||
|
||||
// 7.9, basic_string_view non-member comparison functions
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator==(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator!=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator< (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator> (basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator<=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
template<class charT, class traits>
|
||||
constexpr bool operator>=(basic_string_view<charT, traits> x,
|
||||
basic_string_view<charT, traits> y) noexcept;
|
||||
// see below, sufficient additional overloads of comparison functions
|
||||
|
||||
// 7.10, Inserters and extractors
|
||||
template<class charT, class traits>
|
||||
basic_ostream<charT, traits>&
|
||||
operator<<(basic_ostream<charT, traits>& os,
|
||||
basic_string_view<charT, traits> str);
|
||||
|
||||
// basic_string_view typedef names
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
template<class charT, class traits = char_traits<charT>>
|
||||
class basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef traits traits_type;
|
||||
typedef charT value_type;
|
||||
typedef charT* pointer;
|
||||
typedef const charT* const_pointer;
|
||||
typedef charT& reference;
|
||||
typedef const charT& const_reference;
|
||||
typedef implementation-defined const_iterator;
|
||||
typedef const_iterator iterator;
|
||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static constexpr size_type npos = size_type(-1);
|
||||
|
||||
// 7.3, basic_string_view constructors and assignment operators
|
||||
constexpr basic_string_view() noexcept;
|
||||
constexpr basic_string_view(const basic_string_view&) noexcept = default;
|
||||
basic_string_view& operator=(const basic_string_view&) noexcept = default;
|
||||
template<class Allocator>
|
||||
basic_string_view(const basic_string<charT, traits, Allocator>& str) noexcept;
|
||||
constexpr basic_string_view(const charT* str);
|
||||
constexpr basic_string_view(const charT* str, size_type len);
|
||||
|
||||
// 7.4, basic_string_view iterator support
|
||||
constexpr const_iterator begin() const noexcept;
|
||||
constexpr const_iterator end() const noexcept;
|
||||
constexpr const_iterator cbegin() const noexcept;
|
||||
constexpr const_iterator cend() const noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
// 7.5, basic_string_view capacity
|
||||
constexpr size_type size() const noexcept;
|
||||
constexpr size_type length() const noexcept;
|
||||
constexpr size_type max_size() const noexcept;
|
||||
constexpr bool empty() const noexcept;
|
||||
|
||||
// 7.6, basic_string_view element access
|
||||
constexpr const_reference operator[](size_type pos) const;
|
||||
constexpr const_reference at(size_type pos) const;
|
||||
constexpr const_reference front() const;
|
||||
constexpr const_reference back() const;
|
||||
constexpr const_pointer data() const noexcept;
|
||||
|
||||
// 7.7, basic_string_view modifiers
|
||||
constexpr void clear() noexcept;
|
||||
constexpr void remove_prefix(size_type n);
|
||||
constexpr void remove_suffix(size_type n);
|
||||
constexpr void swap(basic_string_view& s) noexcept;
|
||||
|
||||
// 7.8, basic_string_view string operations
|
||||
template<class Allocator>
|
||||
explicit operator basic_string<charT, traits, Allocator>() const;
|
||||
template<class Allocator = allocator<charT>>
|
||||
basic_string<charT, traits, Allocator> to_string(
|
||||
const Allocator& a = Allocator()) const;
|
||||
|
||||
size_type copy(charT* s, size_type n, size_type pos = 0) const;
|
||||
|
||||
constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const;
|
||||
constexpr int compare(basic_string_view s) const noexcept;
|
||||
constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
basic_string_view s, size_type pos2, size_type n2) const;
|
||||
constexpr int compare(const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1, const charT* s) const;
|
||||
constexpr int compare(size_type pos1, size_type n1,
|
||||
const charT* s, size_type n2) const;
|
||||
constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type rfind(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type rfind(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_of(const charT* s, size_type pos = npos) const;
|
||||
constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const;
|
||||
constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
||||
|
||||
private:
|
||||
const_pointer data_; // exposition only
|
||||
size_type size_; // exposition only
|
||||
};
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
|
||||
// 7.11, Hash support
|
||||
template <class T> struct hash;
|
||||
template <> struct hash<experimental::string_view>;
|
||||
template <> struct hash<experimental::u16string_view>;
|
||||
template <> struct hash<experimental::u32string_view>;
|
||||
template <> struct hash<experimental::wstring_view>;
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <iomanip>
|
||||
|
||||
#include <__debug>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
template<class _CharT, class _Traits = _VSTD::char_traits<_CharT> >
|
||||
class _LIBCPP_TEMPLATE_VIS basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef _Traits traits_type;
|
||||
typedef _CharT value_type;
|
||||
typedef const _CharT* pointer;
|
||||
typedef const _CharT* const_pointer;
|
||||
typedef const _CharT& reference;
|
||||
typedef const _CharT& const_reference;
|
||||
typedef const_pointer const_iterator; // See [string.view.iterators]
|
||||
typedef const_iterator iterator;
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
|
||||
// [string.view.cons], construct/copy
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string<_CharT, _Traits, _Allocator>& __str) _NOEXCEPT
|
||||
: __data (__str.data()), __size(__str.size()) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s, size_type __len)
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s)
|
||||
: __data(__s), __size(_Traits::length(__s)) {}
|
||||
|
||||
// [string.view.iterators], iterators
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT { return cbegin(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT { return cend(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT { return __data; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT { return __data + __size; }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
// [string.view.capacity], capacity
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type length() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT { return _VSTD::numeric_limits<size_type>::max(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
|
||||
empty() const _NOEXCEPT { return __size == 0; }
|
||||
|
||||
// [string.view.access], element access
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference operator[](size_type __pos) const { return __data[__pos]; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? (__throw_out_of_range("string_view::at"), __data[0])
|
||||
: __data[__pos];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer data() const _NOEXCEPT { return __data; }
|
||||
|
||||
// [string.view.modifiers], modifiers:
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT
|
||||
{
|
||||
__data = nullptr;
|
||||
__size = 0;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_prefix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
|
||||
__data += __n;
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_suffix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_string_view& __other) _NOEXCEPT
|
||||
{
|
||||
const value_type *__p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
|
||||
size_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
// _VSTD::swap( __data, __other.__data );
|
||||
// _VSTD::swap( __size, __other.__size );
|
||||
}
|
||||
|
||||
// [string.view.ops], string operations:
|
||||
template<class _Allocator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_EXPLICIT operator basic_string<_CharT, _Traits, _Allocator>() const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator>( begin(), end()); }
|
||||
|
||||
template<class _Allocator = allocator<_CharT> >
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
to_string( const _Allocator& __a = _Allocator()) const
|
||||
{ return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }
|
||||
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if ( __pos > size())
|
||||
__throw_out_of_range("string_view::copy");
|
||||
size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
_VSTD::copy_n(begin() + __pos, __rlen, __s );
|
||||
return __rlen;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR
|
||||
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{
|
||||
// if (__pos > size())
|
||||
// __throw_out_of_range("string_view::substr");
|
||||
// size_type __rlen = _VSTD::min( __n, size() - __pos );
|
||||
// return basic_string_view(data() + __pos, __rlen);
|
||||
return __pos > size()
|
||||
? (__throw_out_of_range("string_view::substr"), basic_string_view())
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare( size_type __pos1, size_type __n1,
|
||||
basic_string_view _sv, size_type __pos2, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(_sv.substr(__pos2, __n2));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const _CharT* __s) const
|
||||
{
|
||||
return compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
|
||||
}
|
||||
|
||||
// find
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// rfind
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return _VSTD::__str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{ return find(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{ return rfind(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
private:
|
||||
const value_type* __data;
|
||||
size_type __size;
|
||||
};
|
||||
|
||||
|
||||
// [string.view.comparison]
|
||||
// operator ==
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
|
||||
// operator !=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
|
||||
// operator <=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
|
||||
// operator >=
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(typename _VSTD::common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
// [string.view.io]
|
||||
template<class _CharT, class _Traits>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv)
|
||||
{
|
||||
return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
|
||||
}
|
||||
|
||||
typedef basic_string_view<char> string_view;
|
||||
typedef basic_string_view<char16_t> u16string_view;
|
||||
typedef basic_string_view<char32_t> u32string_view;
|
||||
typedef basic_string_view<wchar_t> wstring_view;
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
// [string.view.hash]
|
||||
// Shamelessly stolen from <string>
|
||||
template<class _CharT, class _Traits>
|
||||
struct _LIBCPP_TEMPLATE_VIS hash<std::experimental::basic_string_view<_CharT, _Traits> >
|
||||
: public unary_function<std::experimental::basic_string_view<_CharT, _Traits>, size_t>
|
||||
{
|
||||
size_t operator()(const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT;
|
||||
};
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
size_t
|
||||
hash<std::experimental::basic_string_view<_CharT, _Traits> >::operator()(
|
||||
const std::experimental::basic_string_view<_CharT, _Traits>& __val) const _NOEXCEPT
|
||||
{
|
||||
return __do_string_hash(__val.data(), __val.data() + __val.size());
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template <class _CharT, class _Traits>
|
||||
__quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
quoted ( std::experimental::basic_string_view <_CharT, _Traits> __sv,
|
||||
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
|
||||
{
|
||||
return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
|
||||
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_LFTS_STRING_VIEW
|
||||
#error "<experimental/string_view> has been removed. Use <string_view> instead."
|
||||
|
||||
@@ -8,56 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
||||
#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
|
||||
|
||||
/**
|
||||
experimental/system_error synopsis
|
||||
|
||||
// C++1y
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 19.5, System error support
|
||||
template <class T> constexpr bool is_error_code_enum_v
|
||||
= is_error_code_enum<T>::value;
|
||||
template <class T> constexpr bool is_error_condition_enum_v
|
||||
= is_error_condition_enum<T>::value;
|
||||
|
||||
} // namespace fundamentals_v1
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
*/
|
||||
|
||||
#include <experimental/__config>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
|
||||
#include <system_error>
|
||||
|
||||
#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 bool is_error_code_enum_v
|
||||
= is_error_code_enum<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_error_condition_enum_v
|
||||
= is_error_condition_enum<_Tp>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
||||
#endif /* _LIBCPP_STD_VER > 11 */
|
||||
|
||||
#endif /* _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR */
|
||||
#error "<experimental/system_error> has been removed. Use <system_error> instead."
|
||||
|
||||
@@ -8,75 +8,4 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#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
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t,
|
||||
integer_sequence<size_t, _Id...>) {
|
||||
return _VSTD::__invoke_constexpr(
|
||||
_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 */
|
||||
#error "<experimental/tuple> has been removed. Use <tuple> instead."
|
||||
|
||||
@@ -21,146 +21,6 @@ namespace std {
|
||||
namespace experimental {
|
||||
inline namespace fundamentals_v1 {
|
||||
|
||||
// See C++14 20.10.4.1, primary type categories
|
||||
template <class T> constexpr bool is_void_v
|
||||
= is_void<T>::value;
|
||||
template <class T> constexpr bool is_null_pointer_v
|
||||
= is_null_pointer<T>::value;
|
||||
template <class T> constexpr bool is_integral_v
|
||||
= is_integral<T>::value;
|
||||
template <class T> constexpr bool is_floating_point_v
|
||||
= is_floating_point<T>::value;
|
||||
template <class T> constexpr bool is_array_v
|
||||
= is_array<T>::value;
|
||||
template <class T> constexpr bool is_pointer_v
|
||||
= is_pointer<T>::value;
|
||||
template <class T> constexpr bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<T>::value;
|
||||
template <class T> constexpr bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<T>::value;
|
||||
template <class T> constexpr bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<T>::value;
|
||||
template <class T> constexpr bool is_enum_v
|
||||
= is_enum<T>::value;
|
||||
template <class T> constexpr bool is_union_v
|
||||
= is_union<T>::value;
|
||||
template <class T> constexpr bool is_class_v
|
||||
= is_class<T>::value;
|
||||
template <class T> constexpr bool is_function_v
|
||||
= is_function<T>::value;
|
||||
|
||||
// See C++14 20.10.4.2, composite type categories
|
||||
template <class T> constexpr bool is_reference_v
|
||||
= is_reference<T>::value;
|
||||
template <class T> constexpr bool is_arithmetic_v
|
||||
= is_arithmetic<T>::value;
|
||||
template <class T> constexpr bool is_fundamental_v
|
||||
= is_fundamental<T>::value;
|
||||
template <class T> constexpr bool is_object_v
|
||||
= is_object<T>::value;
|
||||
template <class T> constexpr bool is_scalar_v
|
||||
= is_scalar<T>::value;
|
||||
template <class T> constexpr bool is_compound_v
|
||||
= is_compound<T>::value;
|
||||
template <class T> constexpr bool is_member_pointer_v
|
||||
= is_member_pointer<T>::value;
|
||||
|
||||
// See C++14 20.10.4.3, type properties
|
||||
template <class T> constexpr bool is_const_v
|
||||
= is_const<T>::value;
|
||||
template <class T> constexpr bool is_volatile_v
|
||||
= is_volatile<T>::value;
|
||||
template <class T> constexpr bool is_trivial_v
|
||||
= is_trivial<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<T>::value;
|
||||
template <class T> constexpr bool is_standard_layout_v
|
||||
= is_standard_layout<T>::value;
|
||||
template <class T> constexpr bool is_pod_v
|
||||
= is_pod<T>::value;
|
||||
template <class T> constexpr bool is_literal_type_v
|
||||
= is_literal_type<T>::value;
|
||||
template <class T> constexpr bool is_empty_v
|
||||
= is_empty<T>::value;
|
||||
template <class T> constexpr bool is_polymorphic_v
|
||||
= is_polymorphic<T>::value;
|
||||
template <class T> constexpr bool is_abstract_v
|
||||
= is_abstract<T>::value;
|
||||
template <class T> constexpr bool is_final_v
|
||||
= is_final<T>::value;
|
||||
template <class T> constexpr bool is_signed_v
|
||||
= is_signed<T>::value;
|
||||
template <class T> constexpr bool is_unsigned_v
|
||||
= is_unsigned<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_constructible_v
|
||||
= is_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_default_constructible_v
|
||||
= is_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_copy_constructible_v
|
||||
= is_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_move_constructible_v
|
||||
= is_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_assignable_v
|
||||
= is_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_copy_assignable_v
|
||||
= is_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_move_assignable_v
|
||||
= is_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_destructible_v
|
||||
= is_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<T>::value;
|
||||
template <class T, class... Args> constexpr bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<T, Args...>::value;
|
||||
template <class T> constexpr bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<T>::value;
|
||||
template <class T, class U> constexpr bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<T, U>::value;
|
||||
template <class T> constexpr bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<T>::value;
|
||||
template <class T> constexpr bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<T>::value;
|
||||
template <class T> constexpr bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<T>::value;
|
||||
|
||||
// See C++14 20.10.5, type property queries
|
||||
template <class T> constexpr size_t alignment_of_v
|
||||
= alignment_of<T>::value;
|
||||
template <class T> constexpr size_t rank_v
|
||||
= rank<T>::value;
|
||||
template <class T, unsigned I = 0> constexpr size_t extent_v
|
||||
= extent<T, I>::value;
|
||||
|
||||
// See C++14 20.10.6, type relations
|
||||
template <class T, class U> constexpr bool is_same_v
|
||||
= is_same<T, U>::value;
|
||||
template <class Base, class Derived> constexpr bool is_base_of_v
|
||||
= is_base_of<Base, Derived>::value;
|
||||
template <class From, class To> constexpr bool is_convertible_v
|
||||
= is_convertible<From, To>::value;
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
template <class> class invocation_type; // not defined
|
||||
template <class F, class... ArgTypes> class invocation_type<F(ArgTypes...)>;
|
||||
@@ -172,14 +32,6 @@ inline namespace fundamentals_v1 {
|
||||
template <class T>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<T>::type;
|
||||
|
||||
// 3.3.3, Logical operator traits
|
||||
template<class... B> struct conjunction;
|
||||
template<class... B> constexpr bool conjunction_v = conjunction<B...>::value;
|
||||
template<class... B> struct disjunction;
|
||||
template<class... B> constexpr bool disjunction_v = disjunction<B...>::value;
|
||||
template<class B> struct negation;
|
||||
template<class B> constexpr bool negation_v = negation<B>::value;
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
@@ -229,215 +81,6 @@ inline namespace fundamentals_v1 {
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
|
||||
|
||||
// C++14 20.10.4.1, primary type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v
|
||||
= is_void<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v
|
||||
= is_null_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v
|
||||
= is_integral<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v
|
||||
= is_floating_point<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v
|
||||
= is_array<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v
|
||||
= is_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v
|
||||
= is_lvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v
|
||||
= is_rvalue_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v
|
||||
= is_member_object_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v
|
||||
= is_member_function_pointer<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v
|
||||
= is_enum<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v
|
||||
= is_union<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v
|
||||
= is_class<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v
|
||||
= is_function<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.2, composite type categories
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v
|
||||
= is_reference<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v
|
||||
= is_arithmetic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v
|
||||
= is_fundamental<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v
|
||||
= is_object<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v
|
||||
= is_scalar<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v
|
||||
= is_compound<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v
|
||||
= is_member_pointer<_Tp>::value;
|
||||
|
||||
// C++14 20.10.4.3, type properties
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v
|
||||
= is_const<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v
|
||||
= is_volatile<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v
|
||||
= is_trivial<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v
|
||||
= is_trivially_copyable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v
|
||||
= is_standard_layout<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v
|
||||
= is_pod<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v
|
||||
= is_literal_type<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v
|
||||
= is_empty<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v
|
||||
= is_polymorphic<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v
|
||||
= is_abstract<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v
|
||||
= is_final<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v
|
||||
= is_signed<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v
|
||||
= is_unsigned<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_constructible_v
|
||||
= is_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v
|
||||
= is_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v
|
||||
= is_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v
|
||||
= is_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_assignable_v
|
||||
= is_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v
|
||||
= is_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v
|
||||
= is_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v
|
||||
= is_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v
|
||||
= is_trivially_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v
|
||||
= is_trivially_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v
|
||||
= is_trivially_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v
|
||||
= is_trivially_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v
|
||||
= is_trivially_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v
|
||||
= is_trivially_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v
|
||||
= is_trivially_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v
|
||||
= is_trivially_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class ..._Ts> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v
|
||||
= is_nothrow_constructible<_Tp, _Ts...>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v
|
||||
= is_nothrow_default_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v
|
||||
= is_nothrow_copy_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v
|
||||
= is_nothrow_move_constructible<_Tp>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v
|
||||
= is_nothrow_assignable<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v
|
||||
= is_nothrow_copy_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v
|
||||
= is_nothrow_move_assignable<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v
|
||||
= is_nothrow_destructible<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v
|
||||
= has_virtual_destructor<_Tp>::value;
|
||||
|
||||
// C++14 20.10.5, type properties queries
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v
|
||||
= alignment_of<_Tp>::value;
|
||||
|
||||
template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v
|
||||
= rank<_Tp>::value;
|
||||
|
||||
template <class _Tp, unsigned _Id = 0> _LIBCPP_CONSTEXPR size_t extent_v
|
||||
= extent<_Tp, _Id>::value;
|
||||
|
||||
// C++14 20.10.6, type relations
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v
|
||||
= is_same<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_base_of_v
|
||||
= is_base_of<_Tp, _Up>::value;
|
||||
|
||||
template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_convertible_v
|
||||
= is_convertible<_Tp, _Up>::value;
|
||||
|
||||
#endif /* _LIBCPP_HAS_NO_VARIABLE_TEMPLATES */
|
||||
|
||||
// 3.3.2, Other type transformations
|
||||
/*
|
||||
template <class>
|
||||
@@ -459,24 +102,6 @@ template <class _Tp>
|
||||
using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
|
||||
*/
|
||||
|
||||
// 3.3.3, Logical operator traits
|
||||
template <class...> using void_t = void;
|
||||
|
||||
template <class... _Args>
|
||||
struct conjunction : _VSTD::__and_<_Args...> {};
|
||||
template <class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool conjunction_v = conjunction<_Args...>::value;
|
||||
|
||||
template <class... _Args>
|
||||
struct disjunction : _VSTD::__or_<_Args...> {};
|
||||
template <class... _Args>
|
||||
_LIBCPP_CONSTEXPR bool disjunction_v = disjunction<_Args...>::value;
|
||||
|
||||
template <class _Tp>
|
||||
struct negation : _VSTD::__not_<_Tp> {};
|
||||
template<class _Tp>
|
||||
_LIBCPP_CONSTEXPR bool negation_v = negation<_Tp>::value;
|
||||
|
||||
// 3.3.4, Detection idiom
|
||||
template <class...> using void_t = void;
|
||||
|
||||
|
||||
@@ -728,7 +728,7 @@ public:
|
||||
const_iterator cbefore_begin() const _NOEXCEPT
|
||||
{return const_iterator(base::__before_begin());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT
|
||||
{return base::__before_begin()->__next_ == nullptr;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
||||
192
include/fstream
192
include/fstream
@@ -212,6 +212,9 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
basic_filebuf* open(const char* __s, ios_base::openmode __mode);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
|
||||
#endif
|
||||
@@ -315,7 +318,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf(basic_filebuf&& __rhs)
|
||||
else
|
||||
this->setp((char_type*)__extbuf_,
|
||||
(char_type*)__extbuf_ + (__rhs. epptr() - __rhs.pbase()));
|
||||
this->pbump(__rhs. pptr() - __rhs.pbase());
|
||||
this->__pbump(__rhs. pptr() - __rhs.pbase());
|
||||
}
|
||||
else if (__rhs.eback())
|
||||
{
|
||||
@@ -434,7 +437,7 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
|
||||
ptrdiff_t __e = this->epptr() - this->pbase();
|
||||
this->setp((char_type*)__extbuf_min_,
|
||||
(char_type*)__extbuf_min_ + __e);
|
||||
this->pbump(__n);
|
||||
this->__pbump(__n);
|
||||
}
|
||||
if (__rhs.eback() == (char_type*)__extbuf_min_)
|
||||
{
|
||||
@@ -450,7 +453,7 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs)
|
||||
ptrdiff_t __e = __rhs.epptr() - __rhs.pbase();
|
||||
__rhs.setp((char_type*)__rhs.__extbuf_min_,
|
||||
(char_type*)__rhs.__extbuf_min_ + __e);
|
||||
__rhs.pbump(__n);
|
||||
__rhs.__pbump(__n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,6 +554,90 @@ basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
return __rt;
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
// This is basically the same as the char* overload except that it uses _wfopen
|
||||
// and long mode strings.
|
||||
template <class _CharT, class _Traits>
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
basic_filebuf<_CharT, _Traits>* __rt = 0;
|
||||
if (__file_ == 0)
|
||||
{
|
||||
__rt = this;
|
||||
const wchar_t* __mdstr;
|
||||
switch (__mode & ~ios_base::ate)
|
||||
{
|
||||
case ios_base::out:
|
||||
case ios_base::out | ios_base::trunc:
|
||||
__mdstr = L"w";
|
||||
break;
|
||||
case ios_base::out | ios_base::app:
|
||||
case ios_base::app:
|
||||
__mdstr = L"a";
|
||||
break;
|
||||
case ios_base::in:
|
||||
__mdstr = L"r";
|
||||
break;
|
||||
case ios_base::in | ios_base::out:
|
||||
__mdstr = L"r+";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::trunc:
|
||||
__mdstr = L"w+";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::app:
|
||||
case ios_base::in | ios_base::app:
|
||||
__mdstr = L"a+";
|
||||
break;
|
||||
case ios_base::out | ios_base::binary:
|
||||
case ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
__mdstr = L"wb";
|
||||
break;
|
||||
case ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::app | ios_base::binary:
|
||||
__mdstr = L"ab";
|
||||
break;
|
||||
case ios_base::in | ios_base::binary:
|
||||
__mdstr = L"rb";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::binary:
|
||||
__mdstr = L"r+b";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
|
||||
__mdstr = L"w+b";
|
||||
break;
|
||||
case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
|
||||
case ios_base::in | ios_base::app | ios_base::binary:
|
||||
__mdstr = L"a+b";
|
||||
break;
|
||||
default:
|
||||
__rt = 0;
|
||||
break;
|
||||
}
|
||||
if (__rt)
|
||||
{
|
||||
__file_ = _wfopen(__s, __mdstr);
|
||||
if (__file_)
|
||||
{
|
||||
__om_ = __mode;
|
||||
if (__mode & ios_base::ate)
|
||||
{
|
||||
if (fseek(__file_, 0, SEEK_END))
|
||||
{
|
||||
fclose(__file_);
|
||||
__file_ = 0;
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
__rt = 0;
|
||||
}
|
||||
}
|
||||
return __rt;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_filebuf<_CharT, _Traits>*
|
||||
@@ -617,7 +704,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
|
||||
static_cast<size_t>(__extbufend_ - __extbufnext_));
|
||||
codecvt_base::result __r;
|
||||
__st_last_ = __st_;
|
||||
size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
|
||||
size_t __nr = fread((void*) const_cast<char *>(__extbufnext_), 1, __nmemb, __file_);
|
||||
if (__nr != 0)
|
||||
{
|
||||
if (!__cv_)
|
||||
@@ -630,7 +717,8 @@ basic_filebuf<_CharT, _Traits>::underflow()
|
||||
this->eback() + __ibs_, __inext);
|
||||
if (__r == codecvt_base::noconv)
|
||||
{
|
||||
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
|
||||
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
|
||||
(char_type*)const_cast<char *>(__extbufend_));
|
||||
__c = traits_type::to_int_type(*this->gptr());
|
||||
}
|
||||
else if (__inext != this->eback() + __unget_sz)
|
||||
@@ -722,8 +810,8 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
this->setp((char_type*)__e, this->pptr());
|
||||
this->pbump(this->epptr() - this->pbase());
|
||||
this->setp(const_cast<char_type*>(__e), this->pptr());
|
||||
this->__pbump(this->epptr() - this->pbase());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1016,6 +1104,10 @@ public:
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
@@ -1035,6 +1127,9 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1061,6 +1156,17 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openm
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_istream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::in) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
|
||||
@@ -1138,6 +1244,18 @@ basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::in))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
@@ -1175,6 +1293,10 @@ public:
|
||||
basic_ofstream();
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
@@ -1193,6 +1315,9 @@ public:
|
||||
bool is_open() const;
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
void open(const char* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1219,6 +1344,17 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openm
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_ostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::out) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
|
||||
@@ -1296,6 +1432,18 @@ basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode | ios_base::out))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
@@ -1334,6 +1482,10 @@ public:
|
||||
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
@@ -1353,6 +1505,9 @@ public:
|
||||
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);
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
|
||||
#endif
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1379,6 +1534,17 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmod
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
|
||||
: basic_iostream<char_type, traits_type>(&__sb_)
|
||||
{
|
||||
if (__sb_.open(__s, __mode) == 0)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
inline
|
||||
basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
|
||||
@@ -1456,6 +1622,18 @@ basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
|
||||
{
|
||||
if (__sb_.open(__s, __mode))
|
||||
this->clear();
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
void
|
||||
basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode)
|
||||
|
||||
@@ -213,9 +213,9 @@ template<class T> struct is_bind_expression;
|
||||
template<class T> struct is_placeholder;
|
||||
|
||||
// See C++14 20.9.9, Function object binders
|
||||
template <class T> constexpr bool is_bind_expression_v
|
||||
template <class T> inline constexpr bool is_bind_expression_v
|
||||
= is_bind_expression<T>::value; // C++17
|
||||
template <class T> constexpr int is_placeholder_v
|
||||
template <class T> inline constexpr int is_placeholder_v
|
||||
= is_placeholder<T>::value; // C++17
|
||||
|
||||
|
||||
@@ -1597,9 +1597,11 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
|
||||
return reinterpret_cast<__base*>(p);
|
||||
}
|
||||
|
||||
template <class _Fp, bool = !is_same<_Fp, function>::value &&
|
||||
__invokable<_Fp&, _ArgTypes...>::value>
|
||||
struct __callable;
|
||||
template <class _Fp, bool = __lazy_and<
|
||||
integral_constant<bool, !is_same<__uncvref_t<_Fp>, function>::value>,
|
||||
__invokable<_Fp&, _ArgTypes...>
|
||||
>::value>
|
||||
struct __callable;
|
||||
template <class _Fp>
|
||||
struct __callable<_Fp, true>
|
||||
{
|
||||
@@ -1612,6 +1614,9 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <class _Fp>
|
||||
using _EnableIfCallable = typename enable_if<__callable<_Fp>::value>::type;
|
||||
public:
|
||||
typedef _Rp result_type;
|
||||
|
||||
@@ -1622,9 +1627,7 @@ public:
|
||||
function(nullptr_t) _NOEXCEPT : __f_(0) {}
|
||||
function(const function&);
|
||||
function(function&&) _NOEXCEPT;
|
||||
template<class _Fp, class = typename enable_if<
|
||||
__callable<_Fp>::value && !is_same<_Fp, function>::value
|
||||
>::type>
|
||||
template<class _Fp, class = _EnableIfCallable<_Fp>>
|
||||
function(_Fp);
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14
|
||||
@@ -1638,21 +1641,15 @@ public:
|
||||
function(allocator_arg_t, const _Alloc&, const function&);
|
||||
template<class _Alloc>
|
||||
function(allocator_arg_t, const _Alloc&, function&&);
|
||||
template<class _Fp, class _Alloc, class = typename enable_if<__callable<_Fp>::value>::type>
|
||||
template<class _Fp, class _Alloc, class = _EnableIfCallable<_Fp>>
|
||||
function(allocator_arg_t, const _Alloc& __a, _Fp __f);
|
||||
#endif
|
||||
|
||||
function& operator=(const function&);
|
||||
function& operator=(function&&) _NOEXCEPT;
|
||||
function& operator=(nullptr_t) _NOEXCEPT;
|
||||
template<class _Fp>
|
||||
typename enable_if
|
||||
<
|
||||
__callable<typename decay<_Fp>::type>::value &&
|
||||
!is_same<typename remove_reference<_Fp>::type, function>::value,
|
||||
function&
|
||||
>::type
|
||||
operator=(_Fp&&);
|
||||
template<class _Fp, class = _EnableIfCallable<_Fp>>
|
||||
function& operator=(_Fp&&);
|
||||
|
||||
~function();
|
||||
|
||||
@@ -1854,13 +1851,8 @@ function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT
|
||||
}
|
||||
|
||||
template<class _Rp, class ..._ArgTypes>
|
||||
template <class _Fp>
|
||||
typename enable_if
|
||||
<
|
||||
function<_Rp(_ArgTypes...)>::template __callable<typename decay<_Fp>::type>::value &&
|
||||
!is_same<typename remove_reference<_Fp>::type, function<_Rp(_ArgTypes...)>>::value,
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
>::type
|
||||
template <class _Fp, class>
|
||||
function<_Rp(_ArgTypes...)>&
|
||||
function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f)
|
||||
{
|
||||
function(_VSTD::forward<_Fp>(__f)).swap(*this);
|
||||
@@ -1941,8 +1933,8 @@ _Tp*
|
||||
function<_Rp(_ArgTypes...)>::target() _NOEXCEPT
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (_Tp*)0;
|
||||
return (_Tp*)__f_->target(typeid(_Tp));
|
||||
return nullptr;
|
||||
return (_Tp*) const_cast<void *>(__f_->target(typeid(_Tp)));
|
||||
}
|
||||
|
||||
template<class _Rp, class ..._ArgTypes>
|
||||
@@ -1951,7 +1943,7 @@ const _Tp*
|
||||
function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT
|
||||
{
|
||||
if (__f_ == 0)
|
||||
return (const _Tp*)0;
|
||||
return nullptr;
|
||||
return (const _Tp*)__f_->target(typeid(_Tp));
|
||||
}
|
||||
|
||||
@@ -1999,7 +1991,7 @@ template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
|
||||
#endif
|
||||
|
||||
template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {};
|
||||
@@ -2008,7 +2000,7 @@ template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
|
||||
#endif
|
||||
|
||||
namespace placeholders
|
||||
@@ -2028,16 +2020,16 @@ _LIBCPP_FUNC_VIS extern const __ph<8> _8;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<9> _9;
|
||||
_LIBCPP_FUNC_VIS extern const __ph<10> _10;
|
||||
#else
|
||||
constexpr __ph<1> _1{};
|
||||
constexpr __ph<2> _2{};
|
||||
constexpr __ph<3> _3{};
|
||||
constexpr __ph<4> _4{};
|
||||
constexpr __ph<5> _5{};
|
||||
constexpr __ph<6> _6{};
|
||||
constexpr __ph<7> _7{};
|
||||
constexpr __ph<8> _8{};
|
||||
constexpr __ph<9> _9{};
|
||||
constexpr __ph<10> _10{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{};
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{};
|
||||
#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
|
||||
|
||||
} // placeholders
|
||||
@@ -2419,6 +2411,118 @@ __not_fn_imp<decay_t<_RawFunc>> not_fn(_RawFunc&& __fn) {
|
||||
|
||||
// struct hash<T*> in <memory>
|
||||
|
||||
template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2>
|
||||
pair<_ForwardIterator1, _ForwardIterator1> _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
|
||||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred,
|
||||
forward_iterator_tag, forward_iterator_tag)
|
||||
{
|
||||
if (__first2 == __last2)
|
||||
return make_pair(__first1, __first1); // Everything matches an empty sequence
|
||||
while (true)
|
||||
{
|
||||
// Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks
|
||||
while (true)
|
||||
{
|
||||
if (__first1 == __last1) // return __last1 if no element matches *__first2
|
||||
return make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
// *__first1 matches *__first2, now match elements after here
|
||||
_ForwardIterator1 __m1 = __first1;
|
||||
_ForwardIterator2 __m2 = __first2;
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern)
|
||||
return make_pair(__first1, __m1);
|
||||
if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found
|
||||
return make_pair(__last1, __last1);
|
||||
if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
} // else there is a match, check next elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
pair<_RandomAccessIterator1, _RandomAccessIterator1>
|
||||
__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
|
||||
_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
|
||||
random_access_iterator_tag, random_access_iterator_tag)
|
||||
{
|
||||
typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
|
||||
typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
|
||||
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
|
||||
const _D2 __len2 = __last2 - __first2;
|
||||
if (__len2 == 0)
|
||||
return make_pair(__first1, __first1);
|
||||
const _D1 __len1 = __last1 - __first1;
|
||||
if (__len1 < __len2)
|
||||
return make_pair(__last1, __last1);
|
||||
const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (__first1 == __s)
|
||||
return make_pair(__last1, __last1);
|
||||
if (__pred(*__first1, *__first2))
|
||||
break;
|
||||
++__first1;
|
||||
}
|
||||
|
||||
_RandomAccessIterator1 __m1 = __first1;
|
||||
_RandomAccessIterator2 __m2 = __first2;
|
||||
while (true)
|
||||
{
|
||||
if (++__m2 == __last2)
|
||||
return make_pair(__first1, __first1 + __len2);
|
||||
++__m1; // no need to check range on __m1 because __s guarantees we have enough source
|
||||
if (!__pred(*__m1, *__m2))
|
||||
{
|
||||
++__first1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// default searcher
|
||||
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
|
||||
_LIBCPP_TYPE_VIS
|
||||
class default_searcher {
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
|
||||
_BinaryPredicate __p = _BinaryPredicate())
|
||||
: __first_(__f), __last_(__l), __pred_(__p) {}
|
||||
|
||||
template <typename _ForwardIterator2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
pair<_ForwardIterator2, _ForwardIterator2>
|
||||
operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const
|
||||
{
|
||||
return _VSTD::__search(__f, __l, __first_, __last_, __pred_,
|
||||
typename _VSTD::iterator_traits<_ForwardIterator>::iterator_category(),
|
||||
typename _VSTD::iterator_traits<_ForwardIterator2>::iterator_category());
|
||||
}
|
||||
|
||||
private:
|
||||
_ForwardIterator __first_;
|
||||
_ForwardIterator __last_;
|
||||
_BinaryPredicate __pred_;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_FUNCTIONAL
|
||||
|
||||
@@ -2335,6 +2335,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, lau
|
||||
{ return (int(__policy) & int(__value)) != 0; }
|
||||
|
||||
template <class _Fp, class... _Args>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17
|
||||
future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
|
||||
async(launch __policy, _Fp&& __f, _Args&&... __args)
|
||||
{
|
||||
@@ -2360,7 +2361,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args)
|
||||
}
|
||||
|
||||
template <class _Fp, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
|
||||
future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type>
|
||||
async(_Fp&& __f, _Args&&... __args)
|
||||
{
|
||||
|
||||
@@ -592,6 +592,9 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
// __true_value will generate undefined references when linking unless
|
||||
// we give it internal linkage.
|
||||
|
||||
|
||||
@@ -960,7 +960,6 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
|
||||
++__gc_;
|
||||
this->rdbuf()->sbumpc();
|
||||
}
|
||||
*__s = char_type();
|
||||
if (__gc_ == 0)
|
||||
__err |= ios_base::failbit;
|
||||
this->setstate(__err);
|
||||
@@ -968,10 +967,14 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
|
||||
else
|
||||
this->setstate(ios_base::failbit);
|
||||
}
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
@@ -1069,16 +1072,18 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
|
||||
this->rdbuf()->sbumpc();
|
||||
++__gc_;
|
||||
}
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
if (__gc_ == 0)
|
||||
__err |= ios_base::failbit;
|
||||
this->setstate(__err);
|
||||
}
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (__n > 0)
|
||||
*__s = char_type();
|
||||
this->__set_badbit_and_consider_rethrow();
|
||||
}
|
||||
#endif // _LIBCPP_NO_EXCEPTIONS
|
||||
|
||||
108
include/iterator
108
include/iterator
@@ -37,16 +37,6 @@ struct iterator_traits<T*>
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct iterator_traits<const T*>
|
||||
{
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef const T* pointer;
|
||||
typedef const T& reference;
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
template<class Category, class T, class Distance = ptrdiff_t,
|
||||
class Pointer = T*, class Reference = T&>
|
||||
struct iterator
|
||||
@@ -494,7 +484,7 @@ template<class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*>
|
||||
{
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef typename remove_const<_Tp>::type value_type;
|
||||
typedef typename remove_cv<_Tp>::type value_type;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Tp& reference;
|
||||
typedef random_access_iterator_tag iterator_category;
|
||||
@@ -604,21 +594,27 @@ distance(_InputIter __first, _InputIter __last)
|
||||
|
||||
template <class _InputIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_InputIter
|
||||
typename enable_if
|
||||
<
|
||||
__is_input_iterator<_InputIter>::value,
|
||||
_InputIter
|
||||
>::type
|
||||
next(_InputIter __x,
|
||||
typename iterator_traits<_InputIter>::difference_type __n = 1,
|
||||
typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
|
||||
typename iterator_traits<_InputIter>::difference_type __n = 1)
|
||||
{
|
||||
_VSTD::advance(__x, __n);
|
||||
return __x;
|
||||
}
|
||||
|
||||
template <class _BidiretionalIter>
|
||||
template <class _BidirectionalIter>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
_BidiretionalIter
|
||||
prev(_BidiretionalIter __x,
|
||||
typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
|
||||
typename enable_if<__is_bidirectional_iterator<_BidiretionalIter>::value>::type* = 0)
|
||||
typename enable_if
|
||||
<
|
||||
__is_bidirectional_iterator<_BidirectionalIter>::value,
|
||||
_BidirectionalIter
|
||||
>::type
|
||||
prev(_BidirectionalIter __x,
|
||||
typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
|
||||
{
|
||||
_VSTD::advance(__x, -__n);
|
||||
return __x;
|
||||
@@ -908,15 +904,37 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int)
|
||||
{istream_iterator __t(*this); ++(*this); return __t;}
|
||||
|
||||
template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const istream_iterator& __x, const istream_iterator& __y)
|
||||
{return __x.__in_stream_ == __y.__in_stream_;}
|
||||
bool
|
||||
operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
|
||||
const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
|
||||
|
||||
template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
|
||||
friend _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const istream_iterator& __x, const istream_iterator& __y)
|
||||
{return !(__x == __y);}
|
||||
bool
|
||||
operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
|
||||
const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
|
||||
};
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits, class _Distance>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
|
||||
const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
|
||||
{
|
||||
return __x.__in_stream_ == __y.__in_stream_;
|
||||
}
|
||||
|
||||
template <class _Tp, class _CharT, class _Traits, class _Distance>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool
|
||||
operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
|
||||
const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
|
||||
{
|
||||
return !(__x == __y);
|
||||
}
|
||||
|
||||
template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
|
||||
class _LIBCPP_TEMPLATE_VIS ostream_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
@@ -1794,31 +1812,67 @@ end(const _Cp& __c)
|
||||
#endif // !defined(_LIBCPP_CXX03_LANG)
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// #if _LIBCPP_STD_VER > 11
|
||||
// template <>
|
||||
// struct _LIBCPP_TEMPLATE_VIS plus<void>
|
||||
// {
|
||||
// template <class _T1, class _T2>
|
||||
// _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
// auto operator()(_T1&& __t, _T2&& __u) const
|
||||
// _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
|
||||
// -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
|
||||
// { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
|
||||
// typedef void is_transparent;
|
||||
// };
|
||||
// #endif
|
||||
|
||||
template <class _Cont>
|
||||
constexpr auto size(const _Cont& __c) -> decltype(__c.size()) { return __c.size(); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr auto size(const _Cont& __c)
|
||||
_NOEXCEPT_(noexcept(__c.size()))
|
||||
-> decltype (__c.size())
|
||||
{ return __c.size(); }
|
||||
|
||||
template <class _Tp, size_t _Sz>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
|
||||
|
||||
template <class _Cont>
|
||||
constexpr auto empty(const _Cont& __c) -> decltype(__c.empty()) { return __c.empty(); }
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr auto empty(const _Cont& __c)
|
||||
_NOEXCEPT_(noexcept(__c.empty()))
|
||||
-> decltype (__c.empty())
|
||||
{ return __c.empty(); }
|
||||
|
||||
template <class _Tp, size_t _Sz>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
|
||||
|
||||
template <class _Ep>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
|
||||
|
||||
template <class _Cont> constexpr
|
||||
auto data(_Cont& __c) -> decltype(__c.data()) { return __c.data(); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto data(_Cont& __c)
|
||||
_NOEXCEPT_(noexcept(__c.data()))
|
||||
-> decltype (__c.data())
|
||||
{ return __c.data(); }
|
||||
|
||||
template <class _Cont> constexpr
|
||||
auto data(const _Cont& __c) -> decltype(__c.data()) { return __c.data(); }
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto data(const _Cont& __c)
|
||||
_NOEXCEPT_(noexcept(__c.data()))
|
||||
-> decltype (__c.data())
|
||||
{ return __c.data(); }
|
||||
|
||||
template <class _Tp, size_t _Sz>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
|
||||
|
||||
template <class _Ep>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
|
||||
#endif
|
||||
|
||||
|
||||
85
include/list
85
include/list
@@ -481,7 +481,7 @@ public:
|
||||
{
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
|
||||
"Attempted to dereference a non-dereferenceable list::iterator");
|
||||
"Attempted to dereference a non-dereferenceable list::const_iterator");
|
||||
#endif
|
||||
return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_);
|
||||
}
|
||||
@@ -896,7 +896,7 @@ public:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return base::__sz();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return base::empty();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT
|
||||
@@ -992,6 +992,15 @@ public:
|
||||
void push_front(const value_type& __x);
|
||||
void push_back(const value_type& __x);
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
template <class _Arg>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __emplace_back(_Arg&& __arg) { emplace_back(_VSTD::forward<_Arg>(__arg)); }
|
||||
#else
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __emplace_back(value_type const& __arg) { push_back(__arg); }
|
||||
#endif
|
||||
|
||||
iterator insert(const_iterator __p, const value_type& __x);
|
||||
iterator insert(const_iterator __p, size_type __n, const value_type& __x);
|
||||
template <class _InpIter>
|
||||
@@ -1062,6 +1071,16 @@ public:
|
||||
|
||||
bool __invariants() const;
|
||||
|
||||
typedef __allocator_destructor<__node_allocator> __node_destructor;
|
||||
typedef unique_ptr<__node, __node_destructor> __hold_pointer;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__hold_pointer __allocate_node(__node_allocator& __na) {
|
||||
__node_pointer __p = __node_alloc_traits::allocate(__na, 1);
|
||||
__p->__prev_ = nullptr;
|
||||
return __hold_pointer(__p, __node_destructor(__na, 1));
|
||||
}
|
||||
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
bool __dereferenceable(const const_iterator* __i) const;
|
||||
@@ -1189,7 +1208,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l,
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
for (; __f != __l; ++__f)
|
||||
push_back(*__f);
|
||||
__emplace_back(*__f);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@@ -1202,7 +1221,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a,
|
||||
__get_db()->__insert_c(this);
|
||||
#endif
|
||||
for (; __f != __l; ++__f)
|
||||
push_back(*__f);
|
||||
__emplace_back(*__f);
|
||||
}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
@@ -1388,9 +1407,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x)
|
||||
" referring to this list");
|
||||
#endif
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link());
|
||||
++base::__sz();
|
||||
@@ -1417,9 +1434,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
|
||||
{
|
||||
size_type __ds = 0;
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
++__ds;
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@@ -1485,9 +1500,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l,
|
||||
{
|
||||
size_type __ds = 0;
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f);
|
||||
++__ds;
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@@ -1540,8 +1553,7 @@ void
|
||||
list<_Tp, _Alloc>::push_front(const value_type& __x)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_pointer __nl = __hold->__as_link();
|
||||
__link_nodes_at_front(__nl, __nl);
|
||||
@@ -1554,8 +1566,7 @@ void
|
||||
list<_Tp, _Alloc>::push_back(const value_type& __x)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
__link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
|
||||
++base::__sz();
|
||||
@@ -1569,8 +1580,7 @@ void
|
||||
list<_Tp, _Alloc>::push_front(value_type&& __x)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
|
||||
++base::__sz();
|
||||
@@ -1582,8 +1592,7 @@ void
|
||||
list<_Tp, _Alloc>::push_back(value_type&& __x)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link());
|
||||
++base::__sz();
|
||||
@@ -1600,8 +1609,7 @@ void
|
||||
list<_Tp, _Alloc>::emplace_front(_Args&&... __args)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link());
|
||||
++base::__sz();
|
||||
@@ -1622,8 +1630,7 @@ void
|
||||
list<_Tp, _Alloc>::emplace_back(_Args&&... __args)
|
||||
{
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_pointer __nl = __hold->__as_link();
|
||||
__link_nodes_at_back(__nl, __nl);
|
||||
@@ -1646,9 +1653,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args)
|
||||
" referring to this list");
|
||||
#endif
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...);
|
||||
__link_pointer __nl = __hold.get()->__as_link();
|
||||
__link_nodes(__p.__ptr_, __nl, __nl);
|
||||
@@ -1671,9 +1676,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x)
|
||||
" referring to this list");
|
||||
#endif
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x));
|
||||
__link_pointer __nl = __hold->__as_link();
|
||||
__link_nodes(__p.__ptr_, __nl, __nl);
|
||||
@@ -1846,9 +1849,7 @@ list<_Tp, _Alloc>::resize(size_type __n)
|
||||
__n -= base::__sz();
|
||||
size_type __ds = 0;
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_));
|
||||
++__ds;
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
@@ -1905,9 +1906,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x)
|
||||
__n -= base::__sz();
|
||||
size_type __ds = 0;
|
||||
__node_allocator& __na = base::__node_alloc();
|
||||
typedef __allocator_destructor<__node_allocator> _Dp;
|
||||
unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1));
|
||||
__hold->__prev_ = 0;
|
||||
__hold_pointer __hold = __allocate_node(__na);
|
||||
__node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x);
|
||||
++__ds;
|
||||
__link_pointer __nl = __hold.release()->__as_link();
|
||||
@@ -2059,15 +2058,15 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
|
||||
#endif
|
||||
if (__f != __l)
|
||||
{
|
||||
if (this != &__c)
|
||||
{
|
||||
size_type __s = _VSTD::distance(__f, __l);
|
||||
__c.__sz() -= __s;
|
||||
base::__sz() += __s;
|
||||
}
|
||||
__link_pointer __first = __f.__ptr_;
|
||||
--__l;
|
||||
__link_pointer __last = __l.__ptr_;
|
||||
if (this != &__c)
|
||||
{
|
||||
size_type __s = _VSTD::distance(__f, __l) + 1;
|
||||
__c.__sz() -= __s;
|
||||
base::__sz() += __s;
|
||||
}
|
||||
base::__unlink_nodes(__first, __last);
|
||||
__link_nodes(__p.__ptr_, __first, __last);
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
@@ -372,19 +372,57 @@ template <class _CharT>
|
||||
struct __num_get
|
||||
: protected __num_get_base
|
||||
{
|
||||
static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
|
||||
static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
|
||||
_CharT& __thousands_sep);
|
||||
static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
|
||||
unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
|
||||
unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
|
||||
|
||||
static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
|
||||
char* __a, char*& __a_end,
|
||||
_CharT __decimal_point, _CharT __thousands_sep,
|
||||
const string& __grouping, unsigned* __g,
|
||||
unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
|
||||
#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
|
||||
static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
|
||||
unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
|
||||
unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
|
||||
|
||||
#else
|
||||
static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
|
||||
{
|
||||
locale __loc = __iob.getloc();
|
||||
const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
|
||||
__thousands_sep = __np.thousands_sep();
|
||||
return __np.grouping();
|
||||
}
|
||||
|
||||
const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const
|
||||
{
|
||||
return __do_widen_p(__iob, __atoms);
|
||||
}
|
||||
|
||||
|
||||
static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
|
||||
unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
|
||||
unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
|
||||
private:
|
||||
template<typename T>
|
||||
const T* __do_widen_p(ios_base& __iob, T* __atoms) const
|
||||
{
|
||||
locale __loc = __iob.getloc();
|
||||
use_facet<ctype<T> >(__loc).widen(__src, __src + 26, __atoms);
|
||||
return __atoms;
|
||||
}
|
||||
|
||||
const char* __do_widen_p(ios_base& __iob, char* __atoms) const
|
||||
{
|
||||
(void)__iob;
|
||||
(void)__atoms;
|
||||
return __src;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
template <class _CharT>
|
||||
string
|
||||
__num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
|
||||
@@ -395,6 +433,7 @@ __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& _
|
||||
__thousands_sep = __np.thousands_sep();
|
||||
return __np.grouping();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT>
|
||||
string
|
||||
@@ -411,9 +450,16 @@ __num_get<_CharT>::__stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT&
|
||||
|
||||
template <class _CharT>
|
||||
int
|
||||
#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
|
||||
unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
|
||||
unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
|
||||
#else
|
||||
__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
|
||||
unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
|
||||
unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
|
||||
|
||||
#endif
|
||||
{
|
||||
if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
|
||||
{
|
||||
@@ -849,9 +895,16 @@ num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e,
|
||||
// Stage 1
|
||||
int __base = this->__get_base(__iob);
|
||||
// Stage 2
|
||||
char_type __atoms[26];
|
||||
char_type __thousands_sep;
|
||||
const int __atoms_size = 26;
|
||||
#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
char_type __atoms1[__atoms_size];
|
||||
const char_type *__atoms = this->__do_widen(__iob, __atoms1);
|
||||
string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
|
||||
#else
|
||||
char_type __atoms[__atoms_size];
|
||||
string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
|
||||
#endif
|
||||
string __buf;
|
||||
__buf.resize(__buf.capacity());
|
||||
char* __a = &__buf[0];
|
||||
@@ -899,9 +952,16 @@ num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e,
|
||||
// Stage 1
|
||||
int __base = this->__get_base(__iob);
|
||||
// Stage 2
|
||||
char_type __atoms[26];
|
||||
char_type __thousands_sep;
|
||||
const int __atoms_size = 26;
|
||||
#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
|
||||
char_type __atoms1[__atoms_size];
|
||||
const char_type *__atoms = this->__do_widen(__iob, __atoms1);
|
||||
string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
|
||||
#else
|
||||
char_type __atoms[__atoms_size];
|
||||
string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
|
||||
#endif
|
||||
string __buf;
|
||||
__buf.resize(__buf.capacity());
|
||||
char* __a = &__buf[0];
|
||||
@@ -3960,7 +4020,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
|
||||
this->egptr(), __inext);
|
||||
if (__r == codecvt_base::noconv)
|
||||
{
|
||||
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)__extbufend_);
|
||||
this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
|
||||
(char_type*) const_cast<char *>(__extbufend_));
|
||||
__c = *this->gptr();
|
||||
}
|
||||
else if (__inext != this->eback() + __unget_sz)
|
||||
@@ -4048,8 +4109,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
|
||||
return traits_type::eof();
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
this->setp((char_type*)__e, this->pptr());
|
||||
this->pbump(this->epptr() - this->pbase());
|
||||
this->setp(const_cast<char_type *>(__e), this->pptr());
|
||||
this->__pbump(this->epptr() - this->pbase());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1012,7 +1012,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __tree_.size();}
|
||||
@@ -1669,7 +1669,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __tree_.size();}
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// This include lives outside the header guard in order to support an MSVC
|
||||
// extension which allows users to do:
|
||||
//
|
||||
// #define _USE_MATH_DEFINES
|
||||
// #include <math.h>
|
||||
//
|
||||
// and receive the definitions of mathematical constants, even if <math.h>
|
||||
// has previously been included.
|
||||
#include_next <math.h>
|
||||
|
||||
#ifndef _LIBCPP_MATH_H
|
||||
#define _LIBCPP_MATH_H
|
||||
|
||||
@@ -298,8 +308,6 @@ long double truncl(long double x);
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include_next <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// We support including .h headers inside 'extern "C"' contexts, so switch
|
||||
|
||||
359
include/memory
359
include/memory
@@ -18,7 +18,7 @@ namespace std
|
||||
{
|
||||
|
||||
struct allocator_arg_t { };
|
||||
constexpr allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
inline constexpr allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
|
||||
template <class T, class Alloc> struct uses_allocator;
|
||||
|
||||
@@ -46,6 +46,9 @@ struct pointer_traits<T*>
|
||||
static pointer pointer_to(<details>) noexcept;
|
||||
};
|
||||
|
||||
template <class T> constexpr T* to_address(T* p) noexcept; // C++20
|
||||
template <class Ptr> auto to_address(const Ptr& p) noexcept; // C++20
|
||||
|
||||
template <class Alloc>
|
||||
struct allocator_traits
|
||||
{
|
||||
@@ -81,8 +84,8 @@ struct allocator_traits
|
||||
template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>;
|
||||
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
||||
|
||||
static pointer allocate(allocator_type& a, size_type n);
|
||||
static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint);
|
||||
static pointer allocate(allocator_type& a, size_type n); // [[nodiscard]] in C++20
|
||||
static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // [[nodiscard]] in C++20
|
||||
|
||||
static void deallocate(allocator_type& a, pointer p, size_type n) noexcept;
|
||||
|
||||
@@ -384,6 +387,9 @@ template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
|
||||
template<class T> unique_ptr<T> make_unique(size_t n); // C++14
|
||||
template<class T, class... Args> unspecified make_unique(Args&&...) = delete; // C++14, T == U[N]
|
||||
|
||||
template<class E, class T, class Y, class D>
|
||||
basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, unique_ptr<Y, D> const& p);
|
||||
|
||||
template<class T>
|
||||
class shared_ptr
|
||||
{
|
||||
@@ -625,6 +631,9 @@ template <class T> struct hash;
|
||||
template <class T, class D> struct hash<unique_ptr<T, D> >;
|
||||
template <class T> struct hash<shared_ptr<T> >;
|
||||
|
||||
template <class T, class Alloc>
|
||||
inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
|
||||
|
||||
// Pointer safety
|
||||
enum class pointer_safety { relaxed, preferred, strict };
|
||||
void declare_reachable(void *p);
|
||||
@@ -720,16 +729,12 @@ public:
|
||||
|
||||
// pointer_traits
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_element_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_element_type
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::element_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_element_type<_Tp,
|
||||
typename __void_t<typename _Tp::element_type>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, bool = __has_element_type<_Ptr>::value>
|
||||
struct __pointer_traits_element_type;
|
||||
@@ -808,16 +813,12 @@ struct __pointer_traits_element_type<_Sp<_Tp, _A0, _A1, _A2>, false>
|
||||
|
||||
#endif // _LIBCPP_HAS_NO_VARIADICS
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_difference_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_difference_type
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::difference_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_difference_type<_Tp,
|
||||
typename __void_t<typename _Tp::difference_type>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
|
||||
struct __pointer_traits_difference_type
|
||||
@@ -998,17 +999,12 @@ struct __rebind_pointer {
|
||||
|
||||
// allocator_traits
|
||||
|
||||
struct __has_pointer_type_imp
|
||||
{
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::pointer* = 0);
|
||||
};
|
||||
template <class _Tp, class = void>
|
||||
struct __has_pointer_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_pointer_type
|
||||
: public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1>
|
||||
{
|
||||
};
|
||||
struct __has_pointer_type<_Tp,
|
||||
typename __void_t<typename _Tp::pointer>::type> : true_type {};
|
||||
|
||||
namespace __pointer_type_imp
|
||||
{
|
||||
@@ -1033,16 +1029,12 @@ struct __pointer_type
|
||||
typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_const_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_const_pointer
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::const_pointer* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_const_pointer<_Tp,
|
||||
typename __void_t<typename _Tp::const_pointer>::type> : true_type {};
|
||||
|
||||
template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
|
||||
struct __const_pointer
|
||||
@@ -1060,16 +1052,12 @@ struct __const_pointer<_Tp, _Ptr, _Alloc, false>
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_void_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_void_pointer
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::void_pointer* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_void_pointer<_Tp,
|
||||
typename __void_t<typename _Tp::void_pointer>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
|
||||
struct __void_pointer
|
||||
@@ -1087,16 +1075,12 @@ struct __void_pointer<_Ptr, _Alloc, false>
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_const_void_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_const_void_pointer
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::const_void_pointer* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_const_void_pointer<_Tp,
|
||||
typename __void_t<typename _Tp::const_void_pointer>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
|
||||
struct __const_void_pointer
|
||||
@@ -1115,13 +1099,14 @@ struct __const_void_pointer<_Ptr, _Alloc, false>
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
_Tp*
|
||||
__to_raw_pointer(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
return __p;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER <= 17
|
||||
template <class _Pointer>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename pointer_traits<_Pointer>::element_type*
|
||||
@@ -1129,17 +1114,48 @@ __to_raw_pointer(_Pointer __p) _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__to_raw_pointer(__p.operator->());
|
||||
}
|
||||
#else
|
||||
template <class _Pointer>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__to_raw_pointer(const _Pointer& __p) _NOEXCEPT
|
||||
-> decltype(pointer_traits<_Pointer>::to_address(__p))
|
||||
{
|
||||
return pointer_traits<_Pointer>::to_address(__p);
|
||||
}
|
||||
|
||||
template <class _Pointer, class... _None>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
__to_raw_pointer(const _Pointer& __p, _None...) _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__to_raw_pointer(__p.operator->());
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_size_type
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr
|
||||
_Tp*
|
||||
to_address(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::size_type* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
static_assert(!is_function_v<_Tp>, "_Tp is a function type");
|
||||
return __p;
|
||||
}
|
||||
|
||||
template <class _Pointer>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
auto
|
||||
to_address(const _Pointer& __p) _NOEXCEPT
|
||||
{
|
||||
return _VSTD::__to_raw_pointer(__p);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_size_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_size_type<_Tp,
|
||||
typename __void_t<typename _Tp::size_type>::type> : true_type {};
|
||||
|
||||
template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
|
||||
struct __size_type
|
||||
@@ -1153,16 +1169,13 @@ struct __size_type<_Alloc, _DiffType, true>
|
||||
typedef typename _Alloc::size_type type;
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_propagate_on_container_copy_assignment : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_propagate_on_container_copy_assignment
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::propagate_on_container_copy_assignment* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_propagate_on_container_copy_assignment<_Tp,
|
||||
typename __void_t<typename _Tp::propagate_on_container_copy_assignment>::type>
|
||||
: true_type {};
|
||||
|
||||
template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
|
||||
struct __propagate_on_container_copy_assignment
|
||||
@@ -1176,16 +1189,13 @@ struct __propagate_on_container_copy_assignment<_Alloc, true>
|
||||
typedef typename _Alloc::propagate_on_container_copy_assignment type;
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_propagate_on_container_move_assignment : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_propagate_on_container_move_assignment
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::propagate_on_container_move_assignment* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_propagate_on_container_move_assignment<_Tp,
|
||||
typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
|
||||
: true_type {};
|
||||
|
||||
template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value>
|
||||
struct __propagate_on_container_move_assignment
|
||||
@@ -1199,16 +1209,13 @@ struct __propagate_on_container_move_assignment<_Alloc, true>
|
||||
typedef typename _Alloc::propagate_on_container_move_assignment type;
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_propagate_on_container_swap : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_propagate_on_container_swap
|
||||
{
|
||||
private:
|
||||
struct __two {char __lx; char __lxx;};
|
||||
template <class _Up> static __two __test(...);
|
||||
template <class _Up> static char __test(typename _Up::propagate_on_container_swap* = 0);
|
||||
public:
|
||||
static const bool value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
struct __has_propagate_on_container_swap<_Tp,
|
||||
typename __void_t<typename _Tp::propagate_on_container_swap>::type>
|
||||
: true_type {};
|
||||
|
||||
template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value>
|
||||
struct __propagate_on_container_swap
|
||||
@@ -1222,16 +1229,13 @@ struct __propagate_on_container_swap<_Alloc, true>
|
||||
typedef typename _Alloc::propagate_on_container_swap type;
|
||||
};
|
||||
|
||||
template <class _Tp, class = void>
|
||||
struct __has_is_always_equal : false_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;
|
||||
};
|
||||
struct __has_is_always_equal<_Tp,
|
||||
typename __void_t<typename _Tp::is_always_equal>::type>
|
||||
: true_type {};
|
||||
|
||||
template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
|
||||
struct __is_always_equal
|
||||
@@ -1343,7 +1347,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false>
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
auto
|
||||
__has_allocate_hint_test(_Alloc&& __a, _SizeType&& __sz, _ConstVoidPtr&& __p)
|
||||
-> decltype(__a.allocate(__sz, __p), true_type());
|
||||
-> decltype((void)__a.allocate(__sz, __p), true_type());
|
||||
|
||||
template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
auto
|
||||
@@ -1354,7 +1358,7 @@ template <class _Alloc, class _SizeType, class _ConstVoidPtr>
|
||||
struct __has_allocate_hint
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(__has_allocate_hint_test(declval<_Alloc>(),
|
||||
decltype(_VSTD::__has_allocate_hint_test(declval<_Alloc>(),
|
||||
declval<_SizeType>(),
|
||||
declval<_ConstVoidPtr>())),
|
||||
true_type>::value>
|
||||
@@ -1387,7 +1391,7 @@ template <class _Alloc, class _Pointer, class ..._Args>
|
||||
struct __has_construct
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(__has_construct_test(declval<_Alloc>(),
|
||||
decltype(_VSTD::__has_construct_test(declval<_Alloc>(),
|
||||
declval<_Pointer>(),
|
||||
declval<_Args>()...)),
|
||||
true_type>::value>
|
||||
@@ -1408,7 +1412,7 @@ template <class _Alloc, class _Pointer>
|
||||
struct __has_destroy
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(__has_destroy_test(declval<_Alloc>(),
|
||||
decltype(_VSTD::__has_destroy_test(declval<_Alloc>(),
|
||||
declval<_Pointer>())),
|
||||
true_type>::value>
|
||||
{
|
||||
@@ -1428,7 +1432,7 @@ template <class _Alloc>
|
||||
struct __has_max_size
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(__has_max_size_test(declval<_Alloc&>())),
|
||||
decltype(_VSTD::__has_max_size_test(declval<_Alloc&>())),
|
||||
true_type>::value>
|
||||
{
|
||||
};
|
||||
@@ -1447,7 +1451,7 @@ template <class _Alloc>
|
||||
struct __has_select_on_container_copy_construction
|
||||
: integral_constant<bool,
|
||||
is_same<
|
||||
decltype(__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
|
||||
decltype(_VSTD::__has_select_on_container_copy_construction_test(declval<_Alloc&>())),
|
||||
true_type>::value>
|
||||
{
|
||||
};
|
||||
@@ -1538,10 +1542,10 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
|
||||
{typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;};
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
static pointer allocate(allocator_type& __a, size_type __n)
|
||||
{return __a.allocate(__n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint)
|
||||
{return __allocate(__a, __n, __hint,
|
||||
__has_allocate_hint<allocator_type, size_type, const_void_pointer>());}
|
||||
@@ -1729,10 +1733,10 @@ private:
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __max_size(true_type, const allocator_type& __a)
|
||||
static size_type __max_size(true_type, const allocator_type& __a) _NOEXCEPT
|
||||
{return __a.max_size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
static size_type __max_size(false_type, const allocator_type&)
|
||||
static size_type __max_size(false_type, const allocator_type&) _NOEXCEPT
|
||||
{return numeric_limits<size_type>::max() / sizeof(value_type);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1780,7 +1784,8 @@ public:
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x) const _NOEXCEPT
|
||||
{return _VSTD::addressof(__x);}
|
||||
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
|
||||
{
|
||||
if (__n > max_size())
|
||||
__throw_length_error("allocator<T>::allocate(size_t n)"
|
||||
@@ -1884,7 +1889,7 @@ public:
|
||||
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
|
||||
{_VSTD::__libcpp_deallocate((void*)__p);}
|
||||
{_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p));}
|
||||
_LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT
|
||||
{return size_type(~0) / sizeof(_Tp);}
|
||||
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
@@ -1900,7 +1905,7 @@ public:
|
||||
void
|
||||
construct(pointer __p)
|
||||
{
|
||||
::new((void*)__p) _Tp();
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp();
|
||||
}
|
||||
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
|
||||
@@ -1909,14 +1914,14 @@ public:
|
||||
void
|
||||
construct(pointer __p, _A0& __a0)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
|
||||
}
|
||||
template <class _A0>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(pointer __p, const _A0& __a0)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0);
|
||||
}
|
||||
# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
|
||||
template <class _A0, class _A1>
|
||||
@@ -1924,28 +1929,28 @@ public:
|
||||
void
|
||||
construct(pointer __p, _A0& __a0, _A1& __a1)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0, __a1);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
|
||||
}
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(pointer __p, const _A0& __a0, _A1& __a1)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0, __a1);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
|
||||
}
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(pointer __p, _A0& __a0, const _A1& __a1)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0, __a1);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
|
||||
}
|
||||
template <class _A0, class _A1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void
|
||||
construct(pointer __p, const _A0& __a0, const _A1& __a1)
|
||||
{
|
||||
::new((void*)__p) _Tp(__a0, __a1);
|
||||
::new((void*) const_cast<_Tp *>(__p)) _Tp(__a0, __a1);
|
||||
}
|
||||
#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
|
||||
_LIBCPP_INLINE_VISIBILITY void destroy(pointer __p) {__p->~_Tp();}
|
||||
@@ -1982,11 +1987,12 @@ public:
|
||||
_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_; }
|
||||
_LIBCPP_INLINE_VISIBILITY _OutputIterator base() const { return __x_; }
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NO_CFI
|
||||
pair<_Tp*, ptrdiff_t>
|
||||
get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
{
|
||||
@@ -1998,7 +2004,38 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
__n = __m;
|
||||
while (__n > 0)
|
||||
{
|
||||
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
|
||||
#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
#else
|
||||
if (std::alignment_of<_Tp>::value >
|
||||
std::alignment_of<std::max_align_t>::value)
|
||||
#endif
|
||||
{
|
||||
std::align_val_t __al =
|
||||
std::align_val_t(std::alignment_of<_Tp>::value);
|
||||
__r.first = static_cast<_Tp*>(::operator new(
|
||||
__n * sizeof(_Tp), __al, nothrow));
|
||||
} else {
|
||||
__r.first = static_cast<_Tp*>(::operator new(
|
||||
__n * sizeof(_Tp), nothrow));
|
||||
}
|
||||
#else
|
||||
#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
#else
|
||||
if (std::alignment_of<_Tp>::value >
|
||||
std::alignment_of<std::max_align_t>::value)
|
||||
#endif
|
||||
{
|
||||
// Since aligned operator new is unavailable, return an empty
|
||||
// buffer rather than one with invalid alignment.
|
||||
return __r;
|
||||
}
|
||||
|
||||
__r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
|
||||
#endif
|
||||
|
||||
if (__r.first)
|
||||
{
|
||||
__r.second = __n;
|
||||
@@ -2011,7 +2048,23 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
|
||||
void return_temporary_buffer(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
|
||||
#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
|
||||
#else
|
||||
if (std::alignment_of<_Tp>::value >
|
||||
std::alignment_of<std::max_align_t>::value)
|
||||
#endif
|
||||
{
|
||||
std::align_val_t __al = std::align_val_t(std::alignment_of<_Tp>::value);
|
||||
::operator delete(__p, __al);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
::operator delete(__p);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
|
||||
template <class _Tp>
|
||||
@@ -2081,11 +2134,12 @@ struct __compressed_pair_elem {
|
||||
typedef const _Tp& const_reference;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
constexpr __compressed_pair_elem() : __value_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
|
||||
|
||||
template <class _Up, class = typename enable_if<
|
||||
!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit
|
||||
__compressed_pair_elem(_Up&& __u)
|
||||
: __value_(_VSTD::forward<_Up>(__u)){};
|
||||
@@ -2096,11 +2150,13 @@ struct __compressed_pair_elem {
|
||||
__tuple_indices<_Indexes...>)
|
||||
: __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
|
||||
#else
|
||||
__compressed_pair_elem() : __value_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
|
||||
#endif
|
||||
|
||||
reference __get() _NOEXCEPT { return __value_; }
|
||||
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference __get() const _NOEXCEPT { return __value_; }
|
||||
|
||||
private:
|
||||
@@ -2115,11 +2171,12 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
|
||||
typedef _Tp __value_type;
|
||||
|
||||
#ifndef _LIBCPP_CXX03_LANG
|
||||
constexpr __compressed_pair_elem() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
|
||||
|
||||
template <class _Up, class = typename enable_if<
|
||||
!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value
|
||||
>::type>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
constexpr explicit
|
||||
__compressed_pair_elem(_Up&& __u)
|
||||
: __value_type(_VSTD::forward<_Up>(__u)){};
|
||||
@@ -2130,12 +2187,14 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
|
||||
__tuple_indices<_Indexes...>)
|
||||
: __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
|
||||
#else
|
||||
__compressed_pair_elem() : __value_type() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__compressed_pair_elem(_ParamT __p)
|
||||
: __value_type(std::forward<_ParamT>(__p)) {}
|
||||
#endif
|
||||
|
||||
reference __get() _NOEXCEPT { return *this; }
|
||||
_LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reference __get() const _NOEXCEPT { return *this; }
|
||||
};
|
||||
|
||||
@@ -3890,7 +3949,9 @@ public:
|
||||
template <class _Dp>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Dp* __get_deleter() const _NOEXCEPT
|
||||
{return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);}
|
||||
{return static_cast<_Dp*>(__cntrl_
|
||||
? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
|
||||
: nullptr);}
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
||||
@@ -4255,6 +4316,7 @@ template<class ..._Args>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::make_shared(_Args&& ...__args)
|
||||
{
|
||||
static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in make_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
|
||||
typedef allocator<_CntrlBlk> _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
@@ -4273,6 +4335,7 @@ template<class _Alloc, class ..._Args>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args)
|
||||
{
|
||||
static_assert( is_constructible<_Tp, _Args...>::value, "Can't construct object in allocate_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
|
||||
typedef __allocator_destructor<_A2> _D2;
|
||||
@@ -4293,6 +4356,7 @@ template<class _Tp>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::make_shared()
|
||||
{
|
||||
static_assert((is_constructible<_Tp>::value), "Can't construct object in make_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
|
||||
typedef allocator<_CntrlBlk> _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4311,6 +4375,7 @@ template<class _A0>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::make_shared(_A0& __a0)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0>::value), "Can't construct object in make_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
|
||||
typedef allocator<_CntrlBlk> _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4329,6 +4394,7 @@ template<class _A0, class _A1>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't construct object in make_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
|
||||
typedef allocator<_CntrlBlk> _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4347,6 +4413,7 @@ template<class _A0, class _A1, class _A2>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::make_shared(_A0& __a0, _A1& __a1, _A2& __a2)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
|
||||
typedef allocator<_CntrlBlk> _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4365,6 +4432,7 @@ template<class _Alloc>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a)
|
||||
{
|
||||
static_assert((is_constructible<_Tp>::value), "Can't construct object in allocate_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4384,6 +4452,7 @@ template<class _Alloc, class _A0>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0>::value), "Can't construct object in allocate_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4403,6 +4472,7 @@ template<class _Alloc, class _A0, class _A1>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0, _A1>::value), "Can't construct object in allocate_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4422,6 +4492,7 @@ template<class _Alloc, class _A0, class _A1, class _A2>
|
||||
shared_ptr<_Tp>
|
||||
shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _A0& __a0, _A1& __a1, _A2& __a2)
|
||||
{
|
||||
static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
|
||||
typedef __shared_ptr_emplace<_Tp, _Alloc> _CntrlBlk;
|
||||
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _Alloc2;
|
||||
typedef __allocator_destructor<_Alloc2> _D2;
|
||||
@@ -4516,7 +4587,7 @@ inline
|
||||
typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
|
||||
typename shared_ptr<_Tp>::element_type*>::value,
|
||||
shared_ptr<_Tp>&
|
||||
>::type
|
||||
@@ -4551,7 +4622,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
!is_array<_Yp>::value &&
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
|
||||
is_convertible<typename unique_ptr<_Yp, _Dp>::pointer,
|
||||
typename shared_ptr<_Tp>::element_type*>::value,
|
||||
shared_ptr<_Tp>&
|
||||
>::type
|
||||
@@ -5350,7 +5421,7 @@ atomic_load(const shared_ptr<_Tp>* __p)
|
||||
__m.unlock();
|
||||
return __q;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
|
||||
@@ -5391,7 +5462,7 @@ atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r)
|
||||
__m.unlock();
|
||||
return __r;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
|
||||
@@ -5523,7 +5594,7 @@ void __swap_allocator(_Alloc & __a1, _Alloc & __a2)
|
||||
_NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
|
||||
#endif
|
||||
{
|
||||
__swap_allocator(__a1, __a2,
|
||||
__swap_allocator(__a1, __a2,
|
||||
integral_constant<bool, _VSTD::allocator_traits<_Alloc>::propagate_on_container_swap::value>());
|
||||
}
|
||||
|
||||
@@ -5545,7 +5616,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {}
|
||||
|
||||
template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> >
|
||||
struct __noexcept_move_assign_container : public integral_constant<bool,
|
||||
struct __noexcept_move_assign_container : public integral_constant<bool,
|
||||
_Traits::propagate_on_container_move_assignment::value
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|| _Traits::is_always_equal::value
|
||||
@@ -5559,21 +5630,31 @@ struct __noexcept_move_assign_container : public integral_constant<bool,
|
||||
template <class _Tp, class _Alloc>
|
||||
struct __temp_value {
|
||||
typedef allocator_traits<_Alloc> _Traits;
|
||||
|
||||
|
||||
typename aligned_storage<sizeof(_Tp), alignof(_Tp)>::type __v;
|
||||
_Alloc &__a;
|
||||
|
||||
_Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
|
||||
_Tp & get() { return *__addr(); }
|
||||
|
||||
|
||||
template<class... _Args>
|
||||
__temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc)
|
||||
{ _Traits::construct(__a, __addr(), _VSTD::forward<_Args>(__args)...); }
|
||||
|
||||
|
||||
~__temp_value() { _Traits::destroy(__a, __addr()); }
|
||||
};
|
||||
#endif
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template<typename _Alloc, typename = void>
|
||||
struct __is_allocator : false_type {};
|
||||
|
||||
template<typename _Alloc>
|
||||
struct __is_allocator<_Alloc,
|
||||
void_t<typename _Alloc::value_type, decltype(_VSTD::declval<_Alloc&>().allocate(size_t{}))>>
|
||||
: true_type {};
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
@@ -492,14 +492,6 @@ module std [system] {
|
||||
module algorithm {
|
||||
header "experimental/algorithm"
|
||||
export *
|
||||
}
|
||||
module any {
|
||||
header "experimental/any"
|
||||
export *
|
||||
}
|
||||
module chrono {
|
||||
header "experimental/chrono"
|
||||
export *
|
||||
}
|
||||
module coroutine {
|
||||
requires coroutines
|
||||
@@ -542,22 +534,10 @@ module std [system] {
|
||||
header "experimental/memory_resource"
|
||||
export *
|
||||
}
|
||||
module numeric {
|
||||
header "experimental/numeric"
|
||||
export *
|
||||
}
|
||||
module optional {
|
||||
header "experimental/optional"
|
||||
export *
|
||||
}
|
||||
module propagate_const {
|
||||
header "experimental/propagate_const"
|
||||
export *
|
||||
}
|
||||
module ratio {
|
||||
header "experimental/ratio"
|
||||
export *
|
||||
}
|
||||
module regex {
|
||||
header "experimental/regex"
|
||||
export *
|
||||
@@ -570,18 +550,6 @@ module std [system] {
|
||||
header "experimental/string"
|
||||
export *
|
||||
}
|
||||
module string_view {
|
||||
header "experimental/string_view"
|
||||
export *
|
||||
}
|
||||
module system_error {
|
||||
header "experimental/system_error"
|
||||
export *
|
||||
}
|
||||
module tuple {
|
||||
header "experimental/tuple"
|
||||
export *
|
||||
}
|
||||
module type_traits {
|
||||
header "experimental/type_traits"
|
||||
export *
|
||||
|
||||
@@ -91,9 +91,9 @@ struct defer_lock_t {};
|
||||
struct try_to_lock_t {};
|
||||
struct adopt_lock_t {};
|
||||
|
||||
constexpr defer_lock_t defer_lock{};
|
||||
constexpr try_to_lock_t try_to_lock{};
|
||||
constexpr adopt_lock_t adopt_lock{};
|
||||
inline constexpr defer_lock_t defer_lock{};
|
||||
inline constexpr try_to_lock_t try_to_lock{};
|
||||
inline constexpr adopt_lock_t adopt_lock{};
|
||||
|
||||
template <class Mutex>
|
||||
class lock_guard
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex
|
||||
|
||||
explicit scoped_lock(MutexTypes&... m);
|
||||
scoped_lock(MutexTypes&... m, adopt_lock_t);
|
||||
scoped_lock(adopt_lock_t, MutexTypes&... m);
|
||||
~scoped_lock();
|
||||
scoped_lock(scoped_lock const&) = delete;
|
||||
scoped_lock& operator=(scoped_lock const&) = delete;
|
||||
@@ -500,9 +500,8 @@ public:
|
||||
~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit scoped_lock(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
|
||||
explicit scoped_lock(adopt_lock_t, mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
|
||||
: __m_(__m) {}
|
||||
|
||||
|
||||
scoped_lock(scoped_lock const&) = delete;
|
||||
scoped_lock& operator=(scoped_lock const&) = delete;
|
||||
@@ -523,7 +522,7 @@ public:
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
scoped_lock(_MArgs&... __margs, adopt_lock_t)
|
||||
scoped_lock(adopt_lock_t, _MArgs&... __margs)
|
||||
: __t_(__margs...)
|
||||
{
|
||||
}
|
||||
|
||||
75
include/new
75
include/new
@@ -46,13 +46,15 @@ typedef void (*new_handler)();
|
||||
new_handler set_new_handler(new_handler new_p) noexcept;
|
||||
new_handler get_new_handler() noexcept;
|
||||
|
||||
// 21.6.4, pointer optimization barrier
|
||||
template <class T> constexpr T* launder(T* p) noexcept; // C++17
|
||||
} // std
|
||||
|
||||
void* operator new(std::size_t size); // replaceable
|
||||
void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17
|
||||
void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable
|
||||
void* operator new(std::size_t size); // replaceable, nodiscard in C++2a
|
||||
void* operator new(std::size_t size, std::align_val_t alignment); // replaceable, C++17, nodiscard in C++2a
|
||||
void* operator new(std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++2a
|
||||
void* operator new(std::size_t size, std::align_val_t alignment,
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++2a
|
||||
void operator delete(void* ptr) noexcept; // replaceable
|
||||
void operator delete(void* ptr, std::size_t size) noexcept; // replaceable, C++14
|
||||
void operator delete(void* ptr, std::align_val_t alignment) noexcept; // replaceable, C++17
|
||||
@@ -62,12 +64,12 @@ void operator delete(void* ptr, const std::nothrow_t&) noexcept; // repla
|
||||
void operator delete(void* ptr, std:align_val_t alignment,
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17
|
||||
|
||||
void* operator new[](std::size_t size); // replaceable
|
||||
void* operator new[](std::size_t size); // replaceable, nodiscard in C++2a
|
||||
void* operator new[](std::size_t size,
|
||||
std::align_val_t alignment) noexcept; // replaceable, C++17
|
||||
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
|
||||
std::align_val_t alignment) noexcept; // replaceable, C++17, nodiscard in C++2a
|
||||
void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable, nodiscard in C++2a
|
||||
void* operator new[](std::size_t size, std::align_val_t alignment,
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17, nodiscard in C++2a
|
||||
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,
|
||||
@@ -78,8 +80,8 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla
|
||||
void operator delete[](void* ptr, std::align_val_t alignment,
|
||||
const std::nothrow_t&) noexcept; // replaceable, C++17
|
||||
|
||||
void* operator new (std::size_t size, void* ptr) noexcept;
|
||||
void* operator new[](std::size_t size, void* ptr) noexcept;
|
||||
void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++2a
|
||||
void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++2a
|
||||
void operator delete (void* ptr, void*) noexcept;
|
||||
void operator delete[](void* ptr, void*) noexcept;
|
||||
|
||||
@@ -92,7 +94,7 @@ void operator delete[](void* ptr, void*) noexcept;
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include <new.h>
|
||||
#endif
|
||||
|
||||
@@ -114,7 +116,7 @@ void operator delete[](void* ptr, void*) noexcept;
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
|
||||
struct _LIBCPP_TYPE_VIS nothrow_t {};
|
||||
extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
|
||||
|
||||
@@ -140,7 +142,7 @@ typedef void (*new_handler)();
|
||||
_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
|
||||
_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
|
||||
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
|
||||
|
||||
@@ -174,18 +176,18 @@ enum align_val_t { __zero = 0, __max = (size_t)-1 };
|
||||
#define _THROW_BAD_ALLOC
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
|
||||
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
@@ -193,16 +195,16 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
|
||||
#endif
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
|
||||
#endif
|
||||
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
|
||||
#ifndef _LIBCPP_HAS_NO_SIZED_DEALLOCATION
|
||||
@@ -210,12 +212,12 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
|
||||
#endif
|
||||
#endif
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
|
||||
inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;}
|
||||
inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
|
||||
inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
|
||||
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@@ -250,6 +252,29 @@ void __throw_bad_array_length()
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline
|
||||
_LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
static_assert (!(is_function<_Tp>::value), "can't launder functions" );
|
||||
static_assert (!(is_same<void, typename remove_cv<_Tp>::type>::value), "can't launder cv-void" );
|
||||
#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
|
||||
return __builtin_launder(__p);
|
||||
#else
|
||||
return __p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _Tp* launder(_Tp* __p) noexcept
|
||||
{
|
||||
return _VSTD::__launder(__p);
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP_NEW
|
||||
|
||||
251
include/numeric
251
include/numeric
@@ -25,6 +25,18 @@ template <class InputIterator, class T, class BinaryOperation>
|
||||
T
|
||||
accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
|
||||
|
||||
template<class InputIterator>
|
||||
typename iterator_traits<InputIterator>::value_type
|
||||
reduce(InputIterator first, InputIterator last); // C++17
|
||||
|
||||
template<class InputIterator, class T>
|
||||
T
|
||||
reduce(InputIterator first, InputIterator last, T init); // C++17
|
||||
|
||||
template<class InputIterator, class T, class BinaryOperation>
|
||||
T
|
||||
reduce(InputIterator first, InputIterator last, T init, BinaryOperation binary_op); // C++17
|
||||
|
||||
template <class InputIterator1, class InputIterator2, class T>
|
||||
T
|
||||
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
|
||||
@@ -34,6 +46,23 @@ template <class InputIterator1, class InputIterator2, class T, class BinaryOpera
|
||||
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
|
||||
T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
|
||||
|
||||
|
||||
template<class InputIterator1, class InputIterator2, class T>
|
||||
T
|
||||
transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init); // C++17
|
||||
|
||||
template<class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
|
||||
T
|
||||
transform_reduce(InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, T init,
|
||||
BinaryOperation1 binary_op1, BinaryOperation2 binary_op2); // C++17
|
||||
|
||||
template<class InputIterator, class T, class BinaryOperation, class UnaryOperation>
|
||||
T
|
||||
transform_reduce(InputIterator first, InputIterator last, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
OutputIterator
|
||||
partial_sum(InputIterator first, InputIterator last, OutputIterator result);
|
||||
@@ -42,6 +71,52 @@ template <class InputIterator, class OutputIterator, class BinaryOperation>
|
||||
OutputIterator
|
||||
partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
|
||||
|
||||
template<class InputIterator, class OutputIterator, class T>
|
||||
OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator, class T, class BinaryOperation>
|
||||
OutputIterator
|
||||
exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init, BinaryOperation binary_op); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator>
|
||||
OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last, OutputIterator result); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator, class BinaryOperation>
|
||||
OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator, class BinaryOperation, class T>
|
||||
OutputIterator
|
||||
inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, BinaryOperation binary_op, T init); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator, class T,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
OutputIterator
|
||||
transform_exclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result, T init,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator,
|
||||
class BinaryOperation, class UnaryOperation>
|
||||
OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op); // C++17
|
||||
|
||||
template<class InputIterator, class OutputIterator,
|
||||
class BinaryOperation, class UnaryOperation, class T>
|
||||
OutputIterator
|
||||
transform_inclusive_scan(InputIterator first, InputIterator last,
|
||||
OutputIterator result,
|
||||
BinaryOperation binary_op, UnaryOperation unary_op,
|
||||
T init); // C++17
|
||||
|
||||
template <class InputIterator, class OutputIterator>
|
||||
OutputIterator
|
||||
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
|
||||
@@ -66,6 +141,7 @@ template <class M, class N>
|
||||
#include <__config>
|
||||
#include <iterator>
|
||||
#include <limits> // for numeric_limits
|
||||
#include <functional>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@@ -96,6 +172,35 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOpe
|
||||
return __init;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _InputIterator, class _Tp, class _BinaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__init = __b(__init, *__first);
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
reduce(_InputIterator __first, _InputIterator __last, _Tp __init)
|
||||
{
|
||||
return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>());
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename iterator_traits<_InputIterator>::value_type
|
||||
reduce(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
return _VSTD::reduce(__first, __last,
|
||||
typename iterator_traits<_InputIterator>::value_type{});
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
@@ -117,6 +222,41 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
|
||||
return __init;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
transform_reduce(_InputIterator __first, _InputIterator __last,
|
||||
_Tp __init, _BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
__init = __b(__init, __u(*__first));
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2,
|
||||
class _Tp, class _BinaryOp1, class _BinaryOp2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2)
|
||||
{
|
||||
for (; __first1 != __last1; ++__first1, (void) ++__first2)
|
||||
__init = __b1(__init, __b2(*__first1, *__first2));
|
||||
return __init;
|
||||
}
|
||||
|
||||
template <class _InputIterator1, class _InputIterator2, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_Tp
|
||||
transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
_InputIterator2 __first2, _Tp __init)
|
||||
{
|
||||
return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init),
|
||||
_VSTD::plus<>(), _VSTD::multiplies<>());
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
@@ -154,6 +294,117 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res
|
||||
return __result;
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init, _BinaryOp __b)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
_Tp __saved = __init;
|
||||
do
|
||||
{
|
||||
__init = __b(__init, *__first);
|
||||
*__result = __saved;
|
||||
__saved = __init;
|
||||
++__result;
|
||||
} while (++__first != __last);
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init)
|
||||
{
|
||||
return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>());
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _Tp __init)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result) {
|
||||
__init = __b(__init, *__first);
|
||||
*__result = __init;
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOp>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b)
|
||||
{
|
||||
if (__first != __last) {
|
||||
typename std::iterator_traits<_InputIterator>::value_type __init = *__first;
|
||||
*__result++ = __init;
|
||||
if (++__first != __last)
|
||||
return _VSTD::inclusive_scan(__first, __last, __result, __b, __init);
|
||||
}
|
||||
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
_OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result)
|
||||
{
|
||||
return _VSTD::inclusive_scan(__first, __last, __result, std::plus<>());
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp,
|
||||
class _BinaryOp, class _UnaryOp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
transform_exclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _Tp __init,
|
||||
_BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
_Tp __saved = __init;
|
||||
do
|
||||
{
|
||||
__init = __b(__init, __u(*__first));
|
||||
*__result = __saved;
|
||||
__saved = __init;
|
||||
++__result;
|
||||
} while (++__first != __last);
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init)
|
||||
{
|
||||
for (; __first != __last; ++__first, (void) ++__result) {
|
||||
__init = __b(__init, __u(*__first));
|
||||
*__result = __init;
|
||||
}
|
||||
|
||||
return __result;
|
||||
}
|
||||
|
||||
template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp>
|
||||
_OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last,
|
||||
_OutputIterator __result, _BinaryOp __b, _UnaryOp __u)
|
||||
{
|
||||
if (__first != __last) {
|
||||
typename std::iterator_traits<_InputIterator>::value_type __init = __u(*__first);
|
||||
*__result++ = __init;
|
||||
if (++__first != __last)
|
||||
return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init);
|
||||
}
|
||||
|
||||
return __result;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _InputIterator, class _OutputIterator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
|
||||
126
include/optional
126
include/optional
@@ -22,7 +22,7 @@ namespace std {
|
||||
|
||||
// 23.6.4, no-value state indicator
|
||||
struct nullopt_t{see below };
|
||||
constexpr nullopt_t nullopt(unspecified );
|
||||
inline constexpr nullopt_t nullopt(unspecified );
|
||||
|
||||
// 23.6.5, class bad_optional_access
|
||||
class bad_optional_access;
|
||||
@@ -57,17 +57,17 @@ namespace std {
|
||||
|
||||
// 23.6.8, comparison with T
|
||||
template <class T, class U> constexpr bool operator==(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator==(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator==(const T&, const optional<U>&);
|
||||
template <class T, class U> constexpr bool operator!=(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator!=(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator!=(const T&, const optional<U>&);
|
||||
template <class T, class U> constexpr bool operator<(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator<(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator<(const T&, const optional<U>&);
|
||||
template <class T, class U> constexpr bool operator<=(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator<=(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator<=(const T&, const optional<U>&);
|
||||
template <class T, class U> constexpr bool operator>(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator>(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator>(const T&, const optional<U>&);
|
||||
template <class T, class U> constexpr bool operator>=(const optional<T>&, const U&);
|
||||
template <class T, class U> constexpr bool operator>=(const U&, const optional<T>&);
|
||||
template <class T, class U> constexpr bool operator>=(const T&, const optional<U>&);
|
||||
|
||||
// 23.6.9, specialized algorithms
|
||||
template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below );
|
||||
@@ -195,7 +195,7 @@ struct nullopt_t
|
||||
_LIBCPP_INLINE_VISIBILITY constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {}
|
||||
};
|
||||
|
||||
/* inline */ constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};
|
||||
_LIBCPP_INLINE_VAR constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};
|
||||
|
||||
template <class _Tp, bool = is_trivially_destructible<_Tp>::value>
|
||||
struct __optional_destruct_base;
|
||||
@@ -439,46 +439,122 @@ struct __optional_storage_base<_Tp, true>
|
||||
}
|
||||
};
|
||||
|
||||
template <class _Tp, bool = is_trivially_copyable<_Tp>::value>
|
||||
struct __optional_storage;
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_storage<_Tp, true> : __optional_storage_base<_Tp>
|
||||
template <class _Tp, bool = is_trivially_copy_constructible<_Tp>::value>
|
||||
struct __optional_copy_base : __optional_storage_base<_Tp>
|
||||
{
|
||||
using __optional_storage_base<_Tp>::__optional_storage_base;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_storage<_Tp, false> : __optional_storage_base<_Tp>
|
||||
struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
|
||||
{
|
||||
using value_type = _Tp;
|
||||
using __optional_storage_base<_Tp>::__optional_storage_base;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage() = default;
|
||||
__optional_copy_base() = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(const __optional_storage& __opt)
|
||||
__optional_copy_base(const __optional_copy_base& __opt)
|
||||
{
|
||||
this->__construct_from(__opt);
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage(__optional_storage&& __opt)
|
||||
__optional_copy_base(__optional_copy_base&&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_base& operator=(const __optional_copy_base&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_base& operator=(__optional_copy_base&&) = default;
|
||||
};
|
||||
|
||||
template <class _Tp, bool = is_trivially_move_constructible<_Tp>::value>
|
||||
struct __optional_move_base : __optional_copy_base<_Tp>
|
||||
{
|
||||
using __optional_copy_base<_Tp>::__optional_copy_base;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
|
||||
{
|
||||
using value_type = _Tp;
|
||||
using __optional_copy_base<_Tp>::__optional_copy_base;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_base() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_base(const __optional_move_base&) = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_base(__optional_move_base&& __opt)
|
||||
noexcept(is_nothrow_move_constructible_v<value_type>)
|
||||
{
|
||||
this->__construct_from(_VSTD::move(__opt));
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage& operator=(const __optional_storage& __opt)
|
||||
__optional_move_base& operator=(const __optional_move_base&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_base& operator=(__optional_move_base&&) = default;
|
||||
};
|
||||
|
||||
template <class _Tp, bool =
|
||||
is_trivially_destructible<_Tp>::value &&
|
||||
is_trivially_copy_constructible<_Tp>::value &&
|
||||
is_trivially_copy_assignable<_Tp>::value>
|
||||
struct __optional_copy_assign_base : __optional_move_base<_Tp>
|
||||
{
|
||||
using __optional_move_base<_Tp>::__optional_move_base;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp>
|
||||
{
|
||||
using __optional_move_base<_Tp>::__optional_move_base;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_assign_base() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_assign_base(const __optional_copy_assign_base&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_assign_base(__optional_copy_assign_base&&) = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_copy_assign_base& operator=(const __optional_copy_assign_base& __opt)
|
||||
{
|
||||
this->__assign_from(__opt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_storage& operator=(__optional_storage&& __opt)
|
||||
__optional_copy_assign_base& operator=(__optional_copy_assign_base&&) = default;
|
||||
};
|
||||
|
||||
template <class _Tp, bool =
|
||||
is_trivially_destructible<_Tp>::value &&
|
||||
is_trivially_move_constructible<_Tp>::value &&
|
||||
is_trivially_move_assignable<_Tp>::value>
|
||||
struct __optional_move_assign_base : __optional_copy_assign_base<_Tp>
|
||||
{
|
||||
using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp>
|
||||
{
|
||||
using value_type = _Tp;
|
||||
using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_assign_base() = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_assign_base(const __optional_move_assign_base& __opt) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_assign_base(__optional_move_assign_base&&) = default;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_assign_base& operator=(const __optional_move_assign_base&) = default;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__optional_move_assign_base& operator=(__optional_move_assign_base&& __opt)
|
||||
noexcept(is_nothrow_move_assignable_v<value_type> &&
|
||||
is_nothrow_move_constructible_v<value_type>)
|
||||
{
|
||||
@@ -501,11 +577,11 @@ using __optional_sfinae_assign_base_t = __sfinae_assign_base<
|
||||
|
||||
template <class _Tp>
|
||||
class optional
|
||||
: private __optional_storage<_Tp>
|
||||
: private __optional_move_assign_base<_Tp>
|
||||
, private __optional_sfinae_ctor_base_t<_Tp>
|
||||
, private __optional_sfinae_assign_base_t<_Tp>
|
||||
{
|
||||
using __base = __optional_storage<_Tp>;
|
||||
using __base = __optional_move_assign_base<_Tp>;
|
||||
public:
|
||||
using value_type = _Tp;
|
||||
|
||||
@@ -536,8 +612,8 @@ private:
|
||||
};
|
||||
template <class _Up>
|
||||
using _CheckOptionalArgsCtor = conditional_t<
|
||||
!is_same_v<decay_t<_Up>, in_place_t> &&
|
||||
!is_same_v<decay_t<_Up>, optional>,
|
||||
!is_same_v<__uncvref_t<_Up>, in_place_t> &&
|
||||
!is_same_v<__uncvref_t<_Up>, optional>,
|
||||
_CheckOptionalArgsConstructor,
|
||||
__check_tuple_constructor_fail
|
||||
>;
|
||||
@@ -685,7 +761,7 @@ public:
|
||||
class = enable_if_t
|
||||
<__lazy_and<
|
||||
integral_constant<bool,
|
||||
!is_same_v<decay_t<_Up>, optional> &&
|
||||
!is_same_v<__uncvref_t<_Up>, optional> &&
|
||||
!(is_same_v<_Up, value_type> && is_scalar_v<value_type>)
|
||||
>,
|
||||
is_constructible<value_type, _Up>,
|
||||
|
||||
@@ -1071,6 +1071,20 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
|
||||
return __os << __p.get();
|
||||
}
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DECLTYPE
|
||||
template<class _CharT, class _Traits, class _Yp, class _Dp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
<
|
||||
is_same<void, typename __void_t<decltype(declval<basic_ostream<_CharT, _Traits>&>() << declval<_Yp>())>::type>::value,
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
>::type
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
|
||||
{
|
||||
return __os << __p.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits, size_t _Size>
|
||||
basic_ostream<_CharT, _Traits>&
|
||||
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
|
||||
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return c.empty();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return c.size();}
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
reference emplace(_Args&&... __args)
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
@@ -490,7 +490,7 @@ public:
|
||||
_Alloc>::value>::type* = 0);
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return c.empty();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return c.size();}
|
||||
|
||||
@@ -2308,6 +2308,7 @@ template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
|
||||
void
|
||||
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b,
|
||||
__t, __c, __l, __f>::seed(result_type __sd)
|
||||
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
|
||||
{ // __w >= 2
|
||||
__x_[0] = __sd & _Max;
|
||||
for (size_t __i = 1; __i < __n; ++__i)
|
||||
@@ -4672,7 +4673,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr
|
||||
double __py;
|
||||
if (__x < 10)
|
||||
{
|
||||
const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
|
||||
const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,
|
||||
40320, 362880};
|
||||
__px = -__pr.__mean_;
|
||||
__py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x];
|
||||
|
||||
@@ -63,17 +63,17 @@ typedef ratio< 1000000000000000000000, 1> zetta; // not supported
|
||||
typedef ratio<1000000000000000000000000, 1> yotta; // not supported
|
||||
|
||||
// 20.11.5, ratio comparison
|
||||
template <class R1, class R2> constexpr bool ratio_equal_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_equal_v
|
||||
= ratio_equal<R1, R2>::value; // C++17
|
||||
template <class R1, class R2> constexpr bool ratio_not_equal_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_not_equal_v
|
||||
= ratio_not_equal<R1, R2>::value; // C++17
|
||||
template <class R1, class R2> constexpr bool ratio_less_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_less_v
|
||||
= ratio_less<R1, R2>::value; // C++17
|
||||
template <class R1, class R2> constexpr bool ratio_less_equal_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_less_equal_v
|
||||
= ratio_less_equal<R1, R2>::value; // C++17
|
||||
template <class R1, class R2> constexpr bool ratio_greater_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_greater_v
|
||||
= ratio_greater<R1, R2>::value; // C++17
|
||||
template <class R1, class R2> constexpr bool ratio_greater_equal_v
|
||||
template <class R1, class R2> inline constexpr bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<R1, R2>::value; // C++17
|
||||
}
|
||||
*/
|
||||
@@ -501,22 +501,28 @@ struct __ratio_gcd
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_equal_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_equal_v
|
||||
= ratio_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_not_equal_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_not_equal_v
|
||||
= ratio_not_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_v
|
||||
= ratio_less<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_less_equal_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_equal_v
|
||||
= ratio_less_equal<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_v
|
||||
= ratio_greater<_R1, _R2>::value;
|
||||
|
||||
template <class _R1, class _R2> _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
|
||||
template <class _R1, class _R2>
|
||||
_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_equal_v
|
||||
= ratio_greater_equal<_R1, _R2>::value;
|
||||
#endif
|
||||
|
||||
|
||||
142
include/regex
142
include/regex
@@ -773,6 +773,8 @@ _LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
|
||||
#define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
namespace regex_constants
|
||||
@@ -2413,17 +2415,28 @@ __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
if (!__neg_chars_.empty())
|
||||
// set of "__found" chars =
|
||||
// union(complement(union(__neg_chars_, __neg_mask_)),
|
||||
// other cases...)
|
||||
//
|
||||
// __neg_chars_ and __neg_mask_'d better be handled together, as there
|
||||
// are no short circuit opportunities.
|
||||
//
|
||||
// In addition, when __neg_mask_/__neg_chars_ is empty, they should be
|
||||
// treated as all ones/all chars.
|
||||
{
|
||||
for (size_t __i = 0; __i < __neg_chars_.size(); ++__i)
|
||||
{
|
||||
if (__ch == __neg_chars_[__i])
|
||||
goto __is_neg_char;
|
||||
}
|
||||
const bool __in_neg_mask = (__neg_mask_ == 0) ||
|
||||
__traits_.isctype(__ch, __neg_mask_);
|
||||
const bool __in_neg_chars =
|
||||
__neg_chars_.empty() ||
|
||||
std::find(__neg_chars_.begin(), __neg_chars_.end(), __ch) !=
|
||||
__neg_chars_.end();
|
||||
if (!(__in_neg_mask || __in_neg_chars))
|
||||
{
|
||||
__found = true;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
__is_neg_char:
|
||||
if (!__ranges_.empty())
|
||||
{
|
||||
string_type __s2 = __collate_ ?
|
||||
@@ -2455,11 +2468,6 @@ __is_neg_char:
|
||||
__found = true;
|
||||
goto __exit;
|
||||
}
|
||||
if (__neg_mask_ && !__traits_.isctype(__ch, __neg_mask_))
|
||||
{
|
||||
__found = true;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
__found = __negate_; // force reject
|
||||
@@ -4011,7 +4019,7 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
|
||||
char_class_type __class_type =
|
||||
__traits_.lookup_classname(__first, __temp, __flags_ & icase);
|
||||
if (__class_type == 0)
|
||||
__throw_regex_error<regex_constants::error_brack>();
|
||||
__throw_regex_error<regex_constants::error_ctype>();
|
||||
__ml->__add_class(__class_type);
|
||||
__first = _VSTD::next(__temp, 2);
|
||||
return __first;
|
||||
@@ -4062,6 +4070,8 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first,
|
||||
__first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
|
||||
++__first)
|
||||
{
|
||||
if (__c >= std::numeric_limits<int>::max() / 10)
|
||||
__throw_regex_error<regex_constants::error_badbrace>();
|
||||
__c *= 10;
|
||||
__c += __val;
|
||||
}
|
||||
@@ -4323,8 +4333,12 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
|
||||
unsigned __v = *__first - '0';
|
||||
for (++__first;
|
||||
__first != __last && '0' <= *__first && *__first <= '9'; ++__first)
|
||||
{
|
||||
if (__v >= std::numeric_limits<unsigned>::max() / 10)
|
||||
__throw_regex_error<regex_constants::error_backref>();
|
||||
__v = 10 * __v + *__first - '0';
|
||||
if (__v > mark_count())
|
||||
}
|
||||
if (__v == 0 || __v > mark_count())
|
||||
__throw_regex_error<regex_constants::error_backref>();
|
||||
__push_back_ref(__v);
|
||||
}
|
||||
@@ -5232,11 +5246,11 @@ public:
|
||||
|
||||
// size:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return __matches_.size();}
|
||||
size_type size() const _NOEXCEPT {return __matches_.size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const {return __matches_.max_size();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return size() == 0;}
|
||||
size_type max_size() const _NOEXCEPT {return __matches_.max_size();}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return size() == 0;}
|
||||
|
||||
// element access:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -5269,15 +5283,15 @@ public:
|
||||
// format:
|
||||
template <class _OutputIter>
|
||||
_OutputIter
|
||||
format(_OutputIter __output, const char_type* __fmt_first,
|
||||
format(_OutputIter __output_iter, const char_type* __fmt_first,
|
||||
const char_type* __fmt_last,
|
||||
regex_constants::match_flag_type __flags = regex_constants::format_default) const;
|
||||
template <class _OutputIter, class _ST, class _SA>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIter
|
||||
format(_OutputIter __output, const basic_string<char_type, _ST, _SA>& __fmt,
|
||||
format(_OutputIter __output_iter, const basic_string<char_type, _ST, _SA>& __fmt,
|
||||
regex_constants::match_flag_type __flags = regex_constants::format_default) const
|
||||
{return format(__output, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
|
||||
{return format(__output_iter, __fmt.data(), __fmt.data() + __fmt.size(), __flags);}
|
||||
template <class _ST, class _SA>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
basic_string<char_type, _ST, _SA>
|
||||
@@ -5389,7 +5403,7 @@ match_results<_BidirectionalIterator, _Allocator>::__init(unsigned __s,
|
||||
template <class _BidirectionalIterator, class _Allocator>
|
||||
template <class _OutputIter>
|
||||
_OutputIter
|
||||
match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output,
|
||||
match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output_iter,
|
||||
const char_type* __fmt_first, const char_type* __fmt_last,
|
||||
regex_constants::match_flag_type __flags) const
|
||||
{
|
||||
@@ -5398,27 +5412,27 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output,
|
||||
for (; __fmt_first != __fmt_last; ++__fmt_first)
|
||||
{
|
||||
if (*__fmt_first == '&')
|
||||
__output = _VSTD::copy(__matches_[0].first, __matches_[0].second,
|
||||
__output);
|
||||
__output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
|
||||
__output_iter);
|
||||
else if (*__fmt_first == '\\' && __fmt_first + 1 != __fmt_last)
|
||||
{
|
||||
++__fmt_first;
|
||||
if ('0' <= *__fmt_first && *__fmt_first <= '9')
|
||||
{
|
||||
size_t __i = *__fmt_first - '0';
|
||||
__output = _VSTD::copy((*this)[__i].first,
|
||||
(*this)[__i].second, __output);
|
||||
__output_iter = _VSTD::copy((*this)[__i].first,
|
||||
(*this)[__i].second, __output_iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
*__output = *__fmt_first;
|
||||
++__output;
|
||||
*__output_iter = *__fmt_first;
|
||||
++__output_iter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*__output = *__fmt_first;
|
||||
++__output;
|
||||
*__output_iter = *__fmt_first;
|
||||
++__output_iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5431,52 +5445,54 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __output,
|
||||
switch (__fmt_first[1])
|
||||
{
|
||||
case '$':
|
||||
*__output = *++__fmt_first;
|
||||
++__output;
|
||||
*__output_iter = *++__fmt_first;
|
||||
++__output_iter;
|
||||
break;
|
||||
case '&':
|
||||
++__fmt_first;
|
||||
__output = _VSTD::copy(__matches_[0].first, __matches_[0].second,
|
||||
__output);
|
||||
__output_iter = _VSTD::copy(__matches_[0].first, __matches_[0].second,
|
||||
__output_iter);
|
||||
break;
|
||||
case '`':
|
||||
++__fmt_first;
|
||||
__output = _VSTD::copy(__prefix_.first, __prefix_.second, __output);
|
||||
__output_iter = _VSTD::copy(__prefix_.first, __prefix_.second, __output_iter);
|
||||
break;
|
||||
case '\'':
|
||||
++__fmt_first;
|
||||
__output = _VSTD::copy(__suffix_.first, __suffix_.second, __output);
|
||||
__output_iter = _VSTD::copy(__suffix_.first, __suffix_.second, __output_iter);
|
||||
break;
|
||||
default:
|
||||
if ('0' <= __fmt_first[1] && __fmt_first[1] <= '9')
|
||||
{
|
||||
++__fmt_first;
|
||||
size_t __i = *__fmt_first - '0';
|
||||
size_t __idx = *__fmt_first - '0';
|
||||
if (__fmt_first + 1 != __fmt_last &&
|
||||
'0' <= __fmt_first[1] && __fmt_first[1] <= '9')
|
||||
{
|
||||
++__fmt_first;
|
||||
__i = 10 * __i + *__fmt_first - '0';
|
||||
if (__idx >= std::numeric_limits<size_t>::max() / 10)
|
||||
__throw_regex_error<regex_constants::error_escape>();
|
||||
__idx = 10 * __idx + *__fmt_first - '0';
|
||||
}
|
||||
__output = _VSTD::copy((*this)[__i].first,
|
||||
(*this)[__i].second, __output);
|
||||
__output_iter = _VSTD::copy((*this)[__idx].first,
|
||||
(*this)[__idx].second, __output_iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
*__output = *__fmt_first;
|
||||
++__output;
|
||||
*__output_iter = *__fmt_first;
|
||||
++__output_iter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*__output = *__fmt_first;
|
||||
++__output;
|
||||
*__output_iter = *__fmt_first;
|
||||
++__output_iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __output;
|
||||
return __output_iter;
|
||||
}
|
||||
|
||||
template <class _BidirectionalIterator, class _Allocator>
|
||||
@@ -5558,8 +5574,14 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
|
||||
__states.back().__node_ = __st;
|
||||
__states.back().__flags_ = __flags;
|
||||
__states.back().__at_first_ = __at_first;
|
||||
int __counter = 0;
|
||||
int __length = __last - __first;
|
||||
do
|
||||
{
|
||||
++__counter;
|
||||
if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
|
||||
__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
|
||||
__throw_regex_error<regex_constants::error_complexity>();
|
||||
__state& __s = __states.back();
|
||||
if (__s.__node_)
|
||||
__s.__node_->__exec(__s);
|
||||
@@ -5633,8 +5655,14 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
|
||||
__states.back().__flags_ = __flags;
|
||||
__states.back().__at_first_ = __at_first;
|
||||
bool __matched = false;
|
||||
int __counter = 0;
|
||||
int __length = __last - __first;
|
||||
do
|
||||
{
|
||||
++__counter;
|
||||
if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
|
||||
__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
|
||||
__throw_regex_error<regex_constants::error_complexity>();
|
||||
__state& __s = __states.back();
|
||||
if (__s.__node_)
|
||||
__s.__node_->__exec(__s);
|
||||
@@ -5730,8 +5758,14 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
|
||||
__states.back().__at_first_ = __at_first;
|
||||
const _CharT* __current = __first;
|
||||
bool __matched = false;
|
||||
int __counter = 0;
|
||||
int __length = __last - __first;
|
||||
do
|
||||
{
|
||||
++__counter;
|
||||
if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 &&
|
||||
__counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
|
||||
__throw_regex_error<regex_constants::error_complexity>();
|
||||
__state& __s = __states.back();
|
||||
if (__s.__node_)
|
||||
__s.__node_->__exec(__s);
|
||||
@@ -6148,7 +6182,7 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++()
|
||||
{
|
||||
__flags_ |= regex_constants::__no_update_pos;
|
||||
_BidirectionalIterator __start = __match_[0].second;
|
||||
if (__match_.empty())
|
||||
if (__match_[0].first == __match_[0].second)
|
||||
{
|
||||
if (__start == __end_)
|
||||
{
|
||||
@@ -6466,7 +6500,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
|
||||
template <class _OutputIterator, class _BidirectionalIterator,
|
||||
class _Traits, class _CharT>
|
||||
_OutputIterator
|
||||
regex_replace(_OutputIterator __output,
|
||||
regex_replace(_OutputIterator __output_iter,
|
||||
_BidirectionalIterator __first, _BidirectionalIterator __last,
|
||||
const basic_regex<_CharT, _Traits>& __e, const _CharT* __fmt,
|
||||
regex_constants::match_flag_type __flags = regex_constants::match_default)
|
||||
@@ -6477,7 +6511,7 @@ regex_replace(_OutputIterator __output,
|
||||
if (__i == __eof)
|
||||
{
|
||||
if (!(__flags & regex_constants::format_no_copy))
|
||||
__output = _VSTD::copy(__first, __last, __output);
|
||||
__output_iter = _VSTD::copy(__first, __last, __output_iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6485,29 +6519,29 @@ regex_replace(_OutputIterator __output,
|
||||
for (size_t __len = char_traits<_CharT>::length(__fmt); __i != __eof; ++__i)
|
||||
{
|
||||
if (!(__flags & regex_constants::format_no_copy))
|
||||
__output = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output);
|
||||
__output = __i->format(__output, __fmt, __fmt + __len, __flags);
|
||||
__output_iter = _VSTD::copy(__i->prefix().first, __i->prefix().second, __output_iter);
|
||||
__output_iter = __i->format(__output_iter, __fmt, __fmt + __len, __flags);
|
||||
__lm = __i->suffix();
|
||||
if (__flags & regex_constants::format_first_only)
|
||||
break;
|
||||
}
|
||||
if (!(__flags & regex_constants::format_no_copy))
|
||||
__output = _VSTD::copy(__lm.first, __lm.second, __output);
|
||||
__output_iter = _VSTD::copy(__lm.first, __lm.second, __output_iter);
|
||||
}
|
||||
return __output;
|
||||
return __output_iter;
|
||||
}
|
||||
|
||||
template <class _OutputIterator, class _BidirectionalIterator,
|
||||
class _Traits, class _CharT, class _ST, class _SA>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_OutputIterator
|
||||
regex_replace(_OutputIterator __output,
|
||||
regex_replace(_OutputIterator __output_iter,
|
||||
_BidirectionalIterator __first, _BidirectionalIterator __last,
|
||||
const basic_regex<_CharT, _Traits>& __e,
|
||||
const basic_string<_CharT, _ST, _SA>& __fmt,
|
||||
regex_constants::match_flag_type __flags = regex_constants::match_default)
|
||||
{
|
||||
return _VSTD::regex_replace(__output, __first, __last, __e, __fmt.c_str(), __flags);
|
||||
return _VSTD::regex_replace(__output_iter, __first, __last, __e, __fmt.c_str(), __flags);
|
||||
}
|
||||
|
||||
template <class _Traits, class _CharT, class _ST, class _SA, class _FST,
|
||||
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
outer_allocator_type& outer_allocator() noexcept;
|
||||
const outer_allocator_type& outer_allocator() const noexcept;
|
||||
|
||||
pointer allocate(size_type n);
|
||||
pointer allocate(size_type n, const_void_pointer hint);
|
||||
pointer allocate(size_type n); // [[nodiscard]] in C++20
|
||||
pointer allocate(size_type n, const_void_pointer hint); // [[nodiscard]] in C++20
|
||||
void deallocate(pointer p, size_type n) noexcept;
|
||||
|
||||
size_type max_size() const;
|
||||
@@ -477,11 +477,11 @@ public:
|
||||
const outer_allocator_type& outer_allocator() const _NOEXCEPT
|
||||
{return base::outer_allocator();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n)
|
||||
{return allocator_traits<outer_allocator_type>::
|
||||
allocate(outer_allocator(), __n);}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
pointer allocate(size_type __n, const_void_pointer __hint)
|
||||
{return allocator_traits<outer_allocator_type>::
|
||||
allocate(outer_allocator(), __n, __hint);}
|
||||
|
||||
@@ -575,7 +575,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __tree_.size();}
|
||||
@@ -984,7 +984,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __tree_.size();}
|
||||
@@ -1077,7 +1077,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
|
||||
|
||||
@@ -243,13 +243,13 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode
|
||||
: __hm_(0),
|
||||
__mode_(__wch)
|
||||
{
|
||||
str(string_type());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
|
||||
ios_base::openmode __wch)
|
||||
: __hm_(0),
|
||||
: __str_(__s.get_allocator()),
|
||||
__hm_(0),
|
||||
__mode_(__wch)
|
||||
{
|
||||
str(__s);
|
||||
@@ -288,7 +288,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&&
|
||||
if (__bout != -1)
|
||||
{
|
||||
this->setp(__p + __bout, __p + __eout);
|
||||
this->pbump(__nout);
|
||||
this->__pbump(__nout);
|
||||
}
|
||||
__hm_ = __hm == -1 ? nullptr : __p + __hm;
|
||||
__p = const_cast<char_type*>(__rhs.__str_.data());
|
||||
@@ -331,7 +331,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
|
||||
if (__bout != -1)
|
||||
{
|
||||
this->setp(__p + __bout, __p + __eout);
|
||||
this->pbump(__nout);
|
||||
this->__pbump(__nout);
|
||||
}
|
||||
else
|
||||
this->setp(nullptr, nullptr);
|
||||
@@ -402,7 +402,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
|
||||
if (__rbout != -1)
|
||||
{
|
||||
this->setp(__p + __rbout, __p + __reout);
|
||||
this->pbump(__rnout);
|
||||
this->__pbump(__rnout);
|
||||
}
|
||||
else
|
||||
this->setp(nullptr, nullptr);
|
||||
@@ -415,7 +415,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
|
||||
if (__lbout != -1)
|
||||
{
|
||||
__rhs.setp(__p + __lbout, __p + __leout);
|
||||
__rhs.pbump(__lnout);
|
||||
__rhs.__pbump(__lnout);
|
||||
}
|
||||
else
|
||||
__rhs.setp(nullptr, nullptr);
|
||||
@@ -470,7 +470,15 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
|
||||
this->setp(const_cast<char_type*>(__str_.data()),
|
||||
const_cast<char_type*>(__str_.data()) + __str_.size());
|
||||
if (__mode_ & (ios_base::app | ios_base::ate))
|
||||
this->pbump(__sz);
|
||||
{
|
||||
while (__sz > INT_MAX)
|
||||
{
|
||||
this->pbump(INT_MAX);
|
||||
__sz -= INT_MAX;
|
||||
}
|
||||
if (__sz > 0)
|
||||
this->pbump(__sz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +543,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
|
||||
__str_.resize(__str_.capacity());
|
||||
char_type* __p = const_cast<char_type*>(__str_.data());
|
||||
this->setp(__p, __p + __str_.size());
|
||||
this->pbump(__nout);
|
||||
this->__pbump(__nout);
|
||||
__hm_ = this->pbase() + __hm;
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
}
|
||||
@@ -569,6 +577,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
|
||||
if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
|
||||
&& __way == ios_base::cur)
|
||||
return pos_type(-1);
|
||||
const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data();
|
||||
off_type __noff;
|
||||
switch (__way)
|
||||
{
|
||||
@@ -582,13 +591,13 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
|
||||
__noff = this->pptr() - this->pbase();
|
||||
break;
|
||||
case ios_base::end:
|
||||
__noff = __hm_ - __str_.data();
|
||||
__noff = __hm;
|
||||
break;
|
||||
default:
|
||||
return pos_type(-1);
|
||||
}
|
||||
__noff += __off;
|
||||
if (__noff < 0 || __hm_ - __str_.data() < __noff)
|
||||
if (__noff < 0 || __hm < __noff)
|
||||
return pos_type(-1);
|
||||
if (__noff != 0)
|
||||
{
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
: c(_VSTD::move(__s.c), __a) {}
|
||||
#endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const {return c.empty();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const {return c.size();}
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
template <class... _Args>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
reference emplace(_Args&&... __args)
|
||||
decltype(auto) emplace(_Args&&... __args)
|
||||
{ return c.emplace_back(_VSTD::forward<_Args>(__args)...);}
|
||||
#else
|
||||
void emplace(_Args&&... __args)
|
||||
|
||||
@@ -109,13 +109,6 @@ void perror(const char* s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
// snprintf
|
||||
#if defined(_LIBCPP_MSVCRT_LIKE)
|
||||
extern "C" {
|
||||
int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef getc
|
||||
#undef putc
|
||||
#undef clearerr
|
||||
|
||||
@@ -132,6 +132,9 @@ public:
|
||||
typedef typename traits_type::pos_type pos_type;
|
||||
typedef typename traits_type::off_type off_type;
|
||||
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
virtual ~basic_streambuf();
|
||||
|
||||
// 27.6.2.2.1 locales:
|
||||
@@ -255,6 +258,9 @@ protected:
|
||||
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||
void pbump(int __n) { __nout_ += __n; }
|
||||
|
||||
_LIBCPP_ALWAYS_INLINE
|
||||
void __pbump(streamsize __n) { __nout_ += __n; }
|
||||
|
||||
inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
|
||||
void setp(char_type* __pbeg, char_type* __pend) {
|
||||
__bout_ = __nout_ = __pbeg;
|
||||
@@ -404,7 +410,8 @@ basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
|
||||
{
|
||||
if (__ninp_ < __einp_)
|
||||
{
|
||||
const streamsize __len = _VSTD::min(__einp_ - __ninp_, __n - __i);
|
||||
const streamsize __len = _VSTD::min(static_cast<streamsize>(INT_MAX),
|
||||
_VSTD::min(__einp_ - __ninp_, __n - __i));
|
||||
traits_type::copy(__s, __ninp_, __len);
|
||||
__s += __len;
|
||||
__i += __len;
|
||||
|
||||
126
include/string
126
include/string
@@ -259,7 +259,7 @@ public:
|
||||
size_type find(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type rfind(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type ffind(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
size_type rfind(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type rfind(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type rfind(value_type c, size_type pos = npos) const noexcept;
|
||||
@@ -271,7 +271,7 @@ public:
|
||||
size_type find_first_of(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
size_type find_last_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type find_last_of(value_type c, size_type pos = npos) const noexcept;
|
||||
@@ -283,7 +283,7 @@ public:
|
||||
size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept;
|
||||
|
||||
size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept;
|
||||
size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = 0) const noexcept;
|
||||
size_type find_last_not_of(basic_string_view<charT, traits> sv, size_type pos = npos) const noexcept;
|
||||
size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept;
|
||||
size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept;
|
||||
size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept;
|
||||
@@ -301,6 +301,13 @@ public:
|
||||
int compare(size_type pos1, size_type n1, const value_type* s) const;
|
||||
int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const;
|
||||
|
||||
bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a
|
||||
bool starts_with(charT c) const noexcept; // C++2a
|
||||
bool starts_with(const charT* s) const; // C++2a
|
||||
bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a
|
||||
bool ends_with(charT c) const noexcept; // C++2a
|
||||
bool ends_with(const charT* s) const; // C++2a
|
||||
|
||||
bool __invariants() const;
|
||||
};
|
||||
|
||||
@@ -556,6 +563,8 @@ template<class _CharT, class _Traits, class _Allocator>
|
||||
basic_string<_CharT, _Traits, _Allocator>
|
||||
operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
|
||||
|
||||
template <bool>
|
||||
class _LIBCPP_TEMPLATE_VIS __basic_string_common
|
||||
{
|
||||
@@ -578,14 +587,7 @@ __basic_string_common<__b>::__throw_out_of_range() const
|
||||
_VSTD::__throw_out_of_range("basic_string");
|
||||
}
|
||||
|
||||
#ifdef _LIBCPP_MSVC
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable: 4231 )
|
||||
#endif // _LIBCPP_MSVC
|
||||
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>)
|
||||
#ifdef _LIBCPP_MSVC
|
||||
#pragma warning( pop )
|
||||
#endif // _LIBCPP_MSVC
|
||||
|
||||
#ifdef _LIBCPP_NO_EXCEPTIONS
|
||||
template <class _Iter>
|
||||
@@ -613,7 +615,7 @@ struct __libcpp_string_gets_noexcept_iterator
|
||||
|
||||
template <class _CharT, class _Traits, class _Tp>
|
||||
struct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT(
|
||||
( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
|
||||
( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value &&
|
||||
!is_convertible<const _Tp&, const _CharT*>::value)) {};
|
||||
|
||||
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
|
||||
@@ -649,7 +651,7 @@ public:
|
||||
typedef typename __alloc_traits::pointer pointer;
|
||||
typedef typename __alloc_traits::const_pointer const_pointer;
|
||||
|
||||
static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD");
|
||||
static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial");
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
|
||||
@@ -675,12 +677,12 @@ private:
|
||||
size_type __cap_;
|
||||
};
|
||||
|
||||
#if _LIBCPP_BIG_ENDIAN
|
||||
enum {__short_mask = 0x01};
|
||||
enum {__long_mask = 0x1ul};
|
||||
#ifdef _LIBCPP_BIG_ENDIAN
|
||||
static const size_type __short_mask = 0x01;
|
||||
static const size_type __long_mask = 0x1ul;
|
||||
#else // _LIBCPP_BIG_ENDIAN
|
||||
enum {__short_mask = 0x80};
|
||||
enum {__long_mask = ~(size_type(~0) >> 1)};
|
||||
static const size_type __short_mask = 0x80;
|
||||
static const size_type __long_mask = ~(size_type(~0) >> 1);
|
||||
#endif // _LIBCPP_BIG_ENDIAN
|
||||
|
||||
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
|
||||
@@ -705,12 +707,12 @@ private:
|
||||
pointer __data_;
|
||||
};
|
||||
|
||||
#if _LIBCPP_BIG_ENDIAN
|
||||
enum {__short_mask = 0x80};
|
||||
enum {__long_mask = ~(size_type(~0) >> 1)};
|
||||
#ifdef _LIBCPP_BIG_ENDIAN
|
||||
static const size_type __short_mask = 0x80;
|
||||
static const size_type __long_mask = ~(size_type(~0) >> 1);
|
||||
#else // _LIBCPP_BIG_ENDIAN
|
||||
enum {__short_mask = 0x01};
|
||||
enum {__long_mask = 0x1ul};
|
||||
static const size_type __short_mask = 0x01;
|
||||
static const size_type __long_mask = 0x1ul;
|
||||
#endif // _LIBCPP_BIG_ENDIAN
|
||||
|
||||
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
|
||||
@@ -906,7 +908,8 @@ public:
|
||||
void shrink_to_fit() _NOEXCEPT {reserve();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void clear() _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 0;}
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return size() == 0;}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT;
|
||||
@@ -1132,7 +1135,7 @@ public:
|
||||
const value_type* c_str() const _NOEXCEPT {return data();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());}
|
||||
#endif
|
||||
@@ -1152,7 +1155,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
size_type rfind(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@@ -1171,7 +1174,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
size_type find_last_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@@ -1191,7 +1194,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(__self_view __sv, size_type __pos = 0) const _NOEXCEPT;
|
||||
size_type find_last_not_of(__self_view __sv, size_type __pos = npos) const _NOEXCEPT;
|
||||
size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;
|
||||
@@ -1219,6 +1222,32 @@ public:
|
||||
int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
|
||||
int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(__self_view __sv) const _NOEXCEPT
|
||||
{ return __self_view(data(), size()).starts_with(__sv); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(value_type __c) const _NOEXCEPT
|
||||
{ return !empty() && _Traits::eq(front(), __c); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(const value_type* __s) const _NOEXCEPT
|
||||
{ return starts_with(__self_view(__s)); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(__self_view __sv) const _NOEXCEPT
|
||||
{ return __self_view(data(), size()).ends_with( __sv); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(value_type __c) const _NOEXCEPT
|
||||
{ return !empty() && _Traits::eq(back(), __c); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(const value_type* __s) const _NOEXCEPT
|
||||
{ return ends_with(__self_view(__s)); }
|
||||
#endif
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY bool __invariants() const;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -1246,7 +1275,7 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __set_short_size(size_type __s) _NOEXCEPT
|
||||
# if _LIBCPP_BIG_ENDIAN
|
||||
# ifdef _LIBCPP_BIG_ENDIAN
|
||||
{__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
|
||||
# else
|
||||
{__r_.first().__s.__size_ = (unsigned char)(__s);}
|
||||
@@ -1254,7 +1283,7 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type __get_short_size() const _NOEXCEPT
|
||||
# if _LIBCPP_BIG_ENDIAN
|
||||
# ifdef _LIBCPP_BIG_ENDIAN
|
||||
{return __r_.first().__s.__size_ >> 1;}
|
||||
# else
|
||||
{return __r_.first().__s.__size_;}
|
||||
@@ -1264,7 +1293,7 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
void __set_short_size(size_type __s) _NOEXCEPT
|
||||
# if _LIBCPP_BIG_ENDIAN
|
||||
# ifdef _LIBCPP_BIG_ENDIAN
|
||||
{__r_.first().__s.__size_ = (unsigned char)(__s);}
|
||||
# else
|
||||
{__r_.first().__s.__size_ = (unsigned char)(__s << 1);}
|
||||
@@ -1272,7 +1301,7 @@ private:
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type __get_short_size() const _NOEXCEPT
|
||||
# if _LIBCPP_BIG_ENDIAN
|
||||
# ifdef _LIBCPP_BIG_ENDIAN
|
||||
{return __r_.first().__s.__size_;}
|
||||
# else
|
||||
{return __r_.first().__s.__size_ >> 1;}
|
||||
@@ -1334,9 +1363,13 @@ private:
|
||||
enum {__alignment = 16};
|
||||
static _LIBCPP_INLINE_VISIBILITY
|
||||
size_type __recommend(size_type __s) _NOEXCEPT
|
||||
{return (__s < __min_cap ? static_cast<size_type>(__min_cap) :
|
||||
__align_it<sizeof(value_type) < __alignment ?
|
||||
__alignment/sizeof(value_type) : 1 > (__s+1)) - 1;}
|
||||
{
|
||||
if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1;
|
||||
size_type __guess = __align_it<sizeof(value_type) < __alignment ?
|
||||
__alignment/sizeof(value_type) : 1 > (__s+1) - 1;
|
||||
if (__guess == __min_cap) ++__guess;
|
||||
return __guess;
|
||||
}
|
||||
|
||||
inline
|
||||
void __init(const value_type* __s, size_type __sz, size_type __reserve);
|
||||
@@ -1761,10 +1794,10 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
template <class _Tp>
|
||||
basic_string<_CharT, _Traits, _Allocator>::basic_string(
|
||||
const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a,
|
||||
typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *)
|
||||
typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type *)
|
||||
: __r_(__second_tag(), __a)
|
||||
{
|
||||
__self_view __sv = __self_view(__t).substr(__pos, __n);
|
||||
__self_view __sv = __self_view(__t).substr(__pos, __n);
|
||||
__init(__sv.data(), __sv.size());
|
||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||
__get_db()->__insert_c(this);
|
||||
@@ -2150,7 +2183,7 @@ template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n)
|
||||
{
|
||||
@@ -2498,7 +2531,7 @@ template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t,
|
||||
size_type __pos2, size_type __n)
|
||||
@@ -2687,8 +2720,8 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
basic_string<_CharT, _Traits, _Allocator>&
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t,
|
||||
size_type __pos2, size_type __n2)
|
||||
@@ -2875,7 +2908,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::size_type
|
||||
basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT
|
||||
{
|
||||
size_type __m = __alloc_traits::max_size(__alloc());
|
||||
#if _LIBCPP_BIG_ENDIAN
|
||||
#ifdef _LIBCPP_BIG_ENDIAN
|
||||
return (__m <= ~__long_mask ? __m : __m/2) - __alignment;
|
||||
#else
|
||||
return __m - __alignment;
|
||||
@@ -3467,8 +3500,8 @@ template <class _CharT, class _Traits, class _Allocator>
|
||||
template <class _Tp>
|
||||
typename enable_if
|
||||
<
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value,
|
||||
int
|
||||
>::type
|
||||
basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1,
|
||||
size_type __n1,
|
||||
@@ -4004,6 +4037,9 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
|
||||
|
||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>)
|
||||
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>)
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
// Literal suffixes for basic_string [basic.string.literals]
|
||||
inline namespace literals
|
||||
@@ -4037,10 +4073,6 @@ inline namespace literals
|
||||
}
|
||||
#endif
|
||||
|
||||
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>)
|
||||
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>)
|
||||
_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&))
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
@@ -143,6 +143,13 @@ namespace std {
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const;
|
||||
constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const;
|
||||
|
||||
constexpr bool starts_with(basic_string_view s) const noexcept; // C++2a
|
||||
constexpr bool starts_with(charT c) const noexcept; // C++2a
|
||||
constexpr bool starts_with(const charT* s) const; // C++2a
|
||||
constexpr bool ends_with(basic_string_view s) const noexcept; // C++2a
|
||||
constexpr bool ends_with(charT c) const noexcept; // C++2a
|
||||
constexpr bool ends_with(const charT* s) const; // C++2a
|
||||
|
||||
private:
|
||||
const_pointer data_; // exposition only
|
||||
size_type size_; // exposition only
|
||||
@@ -155,10 +162,10 @@ namespace std {
|
||||
template <> struct hash<u32string_view>;
|
||||
template <> struct hash<wstring_view>;
|
||||
|
||||
constexpr basic_string<char> operator "" s( const char *str, size_t len ); // C++17
|
||||
constexpr basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++17
|
||||
constexpr basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++17
|
||||
constexpr basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++17
|
||||
constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;
|
||||
constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept;
|
||||
constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
|
||||
constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
|
||||
|
||||
} // namespace std
|
||||
|
||||
@@ -186,388 +193,414 @@ _LIBCPP_BEGIN_NAMESPACE_STD
|
||||
template<class _CharT, class _Traits = char_traits<_CharT> >
|
||||
class _LIBCPP_TEMPLATE_VIS basic_string_view {
|
||||
public:
|
||||
// types
|
||||
typedef _Traits traits_type;
|
||||
typedef _CharT value_type;
|
||||
typedef const _CharT* pointer;
|
||||
typedef const _CharT* const_pointer;
|
||||
typedef const _CharT& reference;
|
||||
typedef const _CharT& const_reference;
|
||||
typedef const_pointer const_iterator; // See [string.view.iterators]
|
||||
typedef const_iterator iterator;
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
// types
|
||||
typedef _Traits traits_type;
|
||||
typedef _CharT value_type;
|
||||
typedef _CharT* pointer;
|
||||
typedef const _CharT* const_pointer;
|
||||
typedef _CharT& reference;
|
||||
typedef const _CharT& const_reference;
|
||||
typedef const_pointer const_iterator; // See [string.view.iterators]
|
||||
typedef const_iterator iterator;
|
||||
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
|
||||
|
||||
static_assert(is_pod<value_type>::value, "Character type of basic_string_view must be a POD");
|
||||
static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");
|
||||
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
|
||||
"traits_type::char_type must be the same type as CharT");
|
||||
|
||||
// [string.view.cons], construct/copy
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
|
||||
// [string.view.cons], construct/copy
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s, size_type __len)
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
|
||||
: __data(__s), __size(__len)
|
||||
{
|
||||
// #if _LIBCPP_STD_VER > 11
|
||||
// _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr");
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s)
|
||||
: __data(__s), __size(_Traits::length(__s)) {}
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view(const _CharT* __s)
|
||||
: __data(__s), __size(_Traits::length(__s)) {}
|
||||
|
||||
// [string.view.iterators], iterators
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT { return cbegin(); }
|
||||
// [string.view.iterators], iterators
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator begin() const _NOEXCEPT { return cbegin(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT { return cend(); }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator end() const _NOEXCEPT { return cend(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT { return __data; }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cbegin() const _NOEXCEPT { return __data; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT { return __data + __size; }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_iterator cend() const _NOEXCEPT { return __data + __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY
|
||||
const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); }
|
||||
|
||||
// [string.view.capacity], capacity
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT { return __size; }
|
||||
// [string.view.capacity], capacity
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type length() const _NOEXCEPT { return __size; }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type length() const _NOEXCEPT { return __size; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); }
|
||||
|
||||
_LIBCPP_CONSTEXPR bool _LIBCPP_INLINE_VISIBILITY
|
||||
empty() const _NOEXCEPT { return __size == 0; }
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
bool empty() const _NOEXCEPT { return __size == 0; }
|
||||
|
||||
// [string.view.access], element access
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; }
|
||||
// [string.view.access], element access
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; }
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? (__throw_out_of_range("string_view::at"), __data[0])
|
||||
: __data[__pos];
|
||||
}
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference at(size_type __pos) const
|
||||
{
|
||||
return __pos >= size()
|
||||
? (__throw_out_of_range("string_view::at"), __data[0])
|
||||
: __data[__pos];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
|
||||
}
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference front() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
|
||||
}
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_reference back() const
|
||||
{
|
||||
return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1];
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer data() const _NOEXCEPT { return __data; }
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
const_pointer data() const _NOEXCEPT { return __data; }
|
||||
|
||||
// [string.view.modifiers], modifiers:
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_prefix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
|
||||
__data += __n;
|
||||
__size -= __n;
|
||||
}
|
||||
// [string.view.modifiers], modifiers:
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_prefix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()");
|
||||
__data += __n;
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_suffix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
|
||||
__size -= __n;
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void remove_suffix(size_type __n) _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()");
|
||||
__size -= __n;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_string_view& __other) _NOEXCEPT
|
||||
{
|
||||
const value_type *__p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
void swap(basic_string_view& __other) _NOEXCEPT
|
||||
{
|
||||
const value_type *__p = __data;
|
||||
__data = __other.__data;
|
||||
__other.__data = __p;
|
||||
|
||||
size_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
}
|
||||
size_type __sz = __size;
|
||||
__size = __other.__size;
|
||||
__other.__size = __sz;
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if (__pos > size())
|
||||
__throw_out_of_range("string_view::copy");
|
||||
size_type __rlen = _VSTD::min(__n, size() - __pos);
|
||||
_Traits::copy(__s, data() + __pos, __rlen);
|
||||
return __rlen;
|
||||
}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{
|
||||
if (__pos > size())
|
||||
__throw_out_of_range("string_view::copy");
|
||||
size_type __rlen = _VSTD::min(__n, size() - __pos);
|
||||
_Traits::copy(__s, data() + __pos, __rlen);
|
||||
return __rlen;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{
|
||||
return __pos > size()
|
||||
? (__throw_out_of_range("string_view::substr"), basic_string_view())
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
|
||||
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{
|
||||
return __pos > size()
|
||||
? (__throw_out_of_range("string_view::substr"), basic_string_view())
|
||||
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare( size_type __pos1, size_type __n1,
|
||||
basic_string_view __sv, size_type __pos2, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare( size_type __pos1, size_type __n1,
|
||||
basic_string_view __sv, size_type __pos2, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const _CharT* __s) const _NOEXCEPT
|
||||
{
|
||||
return compare(basic_string_view(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(const _CharT* __s) const _NOEXCEPT
|
||||
{
|
||||
return compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s));
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
|
||||
{
|
||||
return substr(__pos1, __n1).compare(basic_string_view(__s, __n2));
|
||||
}
|
||||
|
||||
// find
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// find
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_find<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// rfind
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// rfind
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type rfind(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr");
|
||||
return __str_rfind<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// find_first_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{ return find(__c, __pos); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT
|
||||
{ return find(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr");
|
||||
return __str_find_first_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// find_last_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{ return rfind(__c, __pos); }
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT
|
||||
{ return rfind(__c, __pos); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr");
|
||||
return __str_find_last_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_first_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// find_first_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT
|
||||
{
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr");
|
||||
return __str_find_first_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
// find_last_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
// find_last_not_of
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
_LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s.data(), __pos, __s.size());
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT
|
||||
{
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __c, __pos);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, __n);
|
||||
}
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const
|
||||
{
|
||||
_LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr");
|
||||
return __str_find_last_not_of<value_type, size_type, traits_type, npos>
|
||||
(data(), size(), __s, __pos, traits_type::length(__s));
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(basic_string_view __s) const _NOEXCEPT
|
||||
{ return size() >= __s.size() && compare(0, __s.size(), __s) == 0; }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(value_type __c) const _NOEXCEPT
|
||||
{ return !empty() && _Traits::eq(front(), __c); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool starts_with(const value_type* __s) const _NOEXCEPT
|
||||
{ return starts_with(basic_string_view(__s)); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(basic_string_view __s) const _NOEXCEPT
|
||||
{ return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(value_type __c) const _NOEXCEPT
|
||||
{ return !empty() && _Traits::eq(back(), __c); }
|
||||
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool ends_with(const value_type* __s) const _NOEXCEPT
|
||||
{ return ends_with(basic_string_view(__s)); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
const value_type* __data;
|
||||
size_type __size;
|
||||
const value_type* __data;
|
||||
size_type __size;
|
||||
};
|
||||
|
||||
|
||||
@@ -576,28 +609,28 @@ private:
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
if ( __lhs.size() != __rhs.size()) return false;
|
||||
return __lhs.compare(__rhs) == 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -606,29 +639,29 @@ template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
if ( __lhs.size() != __rhs.size())
|
||||
return true;
|
||||
return __lhs.compare(__rhs) != 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -637,23 +670,23 @@ template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
return __lhs.compare(__rhs) < 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -662,23 +695,23 @@ template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
return __lhs.compare(__rhs) > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -687,23 +720,23 @@ template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
return __lhs.compare(__rhs) <= 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -712,24 +745,24 @@ template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(basic_string_view<_CharT, _Traits> __lhs,
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
template<class _CharT, class _Traits>
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
|
||||
bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs,
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT
|
||||
{
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
return __lhs.compare(__rhs) >= 0;
|
||||
}
|
||||
|
||||
typedef basic_string_view<char> string_view;
|
||||
@@ -760,25 +793,25 @@ inline namespace literals
|
||||
inline namespace string_view_literals
|
||||
{
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
basic_string_view<char> operator "" sv(const char *__str, size_t __len)
|
||||
basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
|
||||
{
|
||||
return basic_string_view<char> (__str, __len);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
|
||||
basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT
|
||||
{
|
||||
return basic_string_view<wchar_t> (__str, __len);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
|
||||
basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
|
||||
{
|
||||
return basic_string_view<char16_t> (__str, __len);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
|
||||
basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT
|
||||
{
|
||||
return basic_string_view<char32_t> (__str, __len);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <support/xlocale/__posix_l_fallback.h>
|
||||
#include <support/xlocale/__strtonum_fallback.h>
|
||||
|
||||
#endif // defined(__BIONIC__)
|
||||
#endif // _LIBCPP_SUPPORT_ANDROID_LOCALE_BIONIC_H
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
#include <clocale>
|
||||
#include <cwctype>
|
||||
#include <ctype.h>
|
||||
#if !defined(__NEWLIB__) || __NEWLIB__ < 2 || \
|
||||
__NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
|
||||
#include <support/xlocale/__nop_locale_mgmt.h>
|
||||
#endif
|
||||
#include <support/xlocale/__posix_l_fallback.h>
|
||||
#include <support/xlocale/__strtonum_fallback.h>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <__config>
|
||||
#include <stdio.h>
|
||||
#include <xlocinfo.h> // _locale_t
|
||||
#include <__nullptr>
|
||||
|
||||
#define LC_COLLATE_MASK _M_COLLATE
|
||||
#define LC_CTYPE_MASK _M_CTYPE
|
||||
@@ -28,13 +29,77 @@
|
||||
| LC_NUMERIC_MASK \
|
||||
| LC_TIME_MASK )
|
||||
|
||||
#define locale_t _locale_t
|
||||
class locale_t {
|
||||
public:
|
||||
locale_t()
|
||||
: __locale(nullptr), __locale_str(nullptr) {}
|
||||
locale_t(std::nullptr_t)
|
||||
: __locale(nullptr), __locale_str(nullptr) {}
|
||||
locale_t(_locale_t __locale, const char* __locale_str)
|
||||
: __locale(__locale), __locale_str(__locale_str) {}
|
||||
|
||||
friend bool operator==(const locale_t& __left, const locale_t& __right) {
|
||||
return __left.__locale == __right.__locale;
|
||||
}
|
||||
|
||||
friend bool operator==(const locale_t& __left, int __right) {
|
||||
return __left.__locale == nullptr && __right == 0;
|
||||
}
|
||||
|
||||
friend bool operator==(const locale_t& __left, std::nullptr_t) {
|
||||
return __left.__locale == nullptr;
|
||||
}
|
||||
|
||||
friend bool operator==(int __left, const locale_t& __right) {
|
||||
return __left == 0 && nullptr == __right.__locale;
|
||||
}
|
||||
|
||||
friend bool operator==(std::nullptr_t, const locale_t& __right) {
|
||||
return nullptr == __right.__locale;
|
||||
}
|
||||
|
||||
friend bool operator!=(const locale_t& __left, const locale_t& __right) {
|
||||
return !(__left == __right);
|
||||
}
|
||||
|
||||
friend bool operator!=(const locale_t& __left, int __right) {
|
||||
return !(__left == __right);
|
||||
}
|
||||
|
||||
friend bool operator!=(const locale_t& __left, std::nullptr_t __right) {
|
||||
return !(__left == __right);
|
||||
}
|
||||
|
||||
friend bool operator!=(int __left, const locale_t& __right) {
|
||||
return !(__left == __right);
|
||||
}
|
||||
|
||||
friend bool operator!=(std::nullptr_t __left, const locale_t& __right) {
|
||||
return !(__left == __right);
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return __locale != nullptr;
|
||||
}
|
||||
|
||||
const char* __get_locale() const { return __locale_str; }
|
||||
|
||||
operator _locale_t() const {
|
||||
return __locale;
|
||||
}
|
||||
private:
|
||||
_locale_t __locale;
|
||||
const char* __locale_str;
|
||||
};
|
||||
|
||||
// Locale management functions
|
||||
#define freelocale _free_locale
|
||||
// FIXME: base currently unused. Needs manual work to construct the new locale
|
||||
locale_t newlocale( int mask, const char * locale, locale_t base );
|
||||
locale_t uselocale( locale_t newloc );
|
||||
// uselocale can't be implemented on Windows because Windows allows partial modification
|
||||
// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
|
||||
// not create any copies.
|
||||
// We can still implement raii even without uselocale though.
|
||||
|
||||
|
||||
lconv *localeconv_l( locale_t loc );
|
||||
@@ -100,9 +165,12 @@ isupper_l(int c, _locale_t loc)
|
||||
#define iswxdigit_l _iswxdigit_l
|
||||
#define towupper_l _towupper_l
|
||||
#define towlower_l _towlower_l
|
||||
#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
|
||||
#define strftime_l( __s, __l, __f, __tm, __loc ) strftime( __s, __l, __f, __tm )
|
||||
#else
|
||||
#define strftime_l _strftime_l
|
||||
#endif
|
||||
#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
|
||||
#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
|
||||
#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
|
||||
#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
|
||||
#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
|
||||
|
||||
@@ -47,10 +47,10 @@ template <class T> struct is_error_condition_enum
|
||||
: public false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17
|
||||
inline constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17
|
||||
|
||||
template <class _Tp>
|
||||
constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17
|
||||
inline constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17
|
||||
|
||||
class error_code
|
||||
{
|
||||
@@ -230,6 +230,7 @@ template <> struct hash<std::error_condition>;
|
||||
#include <type_traits>
|
||||
#include <stdexcept>
|
||||
#include <__functional_base>
|
||||
#include <string>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
@@ -245,7 +246,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_code_enum
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value;
|
||||
#endif
|
||||
|
||||
// is_error_condition_enum
|
||||
@@ -256,7 +257,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value;
|
||||
#endif
|
||||
|
||||
// Some error codes are not present on all platforms, so we provide equivalents
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
|
||||
};
|
||||
|
||||
const unspecified ignore;
|
||||
inline constexpr unspecified ignore;
|
||||
|
||||
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
|
||||
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
|
||||
@@ -87,7 +87,7 @@ template <class T, class Tuple>
|
||||
template <class T> class tuple_size; // undefined
|
||||
template <class... T> class tuple_size<tuple<T...>>;
|
||||
template <class T>
|
||||
constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
|
||||
inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
|
||||
template <size_t I, class T> class tuple_element; // undefined
|
||||
template <size_t I, class... T> class tuple_element<I, tuple<T...>>;
|
||||
template <size_t I, class T>
|
||||
@@ -173,16 +173,11 @@ class __tuple_leaf
|
||||
|
||||
template <class _Tp>
|
||||
static constexpr bool __can_bind_reference() {
|
||||
using _RawTp = typename remove_reference<_Tp>::type;
|
||||
using _RawHp = typename remove_reference<_Hp>::type;
|
||||
using _CheckLValueArg = integral_constant<bool,
|
||||
is_lvalue_reference<_Tp>::value
|
||||
|| is_same<_RawTp, reference_wrapper<_RawHp>>::value
|
||||
|| is_same<_RawTp, reference_wrapper<typename remove_const<_RawHp>::type>>::value
|
||||
>;
|
||||
return !is_reference<_Hp>::value
|
||||
|| (is_lvalue_reference<_Hp>::value && _CheckLValueArg::value)
|
||||
|| (is_rvalue_reference<_Hp>::value && !is_lvalue_reference<_Tp>::value);
|
||||
#if __has_keyword(__reference_binds_to_temporary)
|
||||
return !__reference_binds_to_temporary(_Hp, _Tp);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
__tuple_leaf& operator=(const __tuple_leaf&);
|
||||
@@ -216,7 +211,7 @@ public:
|
||||
template <class _Tp,
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
__lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
@@ -224,15 +219,15 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
||||
: __value_(_VSTD::forward<_Tp>(__t))
|
||||
{static_assert(__can_bind_reference<_Tp>(),
|
||||
"Attempted to construct a reference element in a tuple with an rvalue");}
|
||||
{static_assert(__can_bind_reference<_Tp&&>(),
|
||||
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
|
||||
: __value_(_VSTD::forward<_Tp>(__t))
|
||||
{static_assert(__can_bind_reference<_Tp>(),
|
||||
"Attempted to construct a reference element in a tuple with an rvalue");}
|
||||
{static_assert(__can_bind_reference<_Tp&&>(),
|
||||
"Attempted construction of reference element binds to a temporary whose lifetime has ended");}
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@@ -298,7 +293,7 @@ public:
|
||||
template <class _Tp,
|
||||
class = typename enable_if<
|
||||
__lazy_and<
|
||||
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
||||
__lazy_not<is_same<typename __uncvref<_Tp>::type, __tuple_leaf>>
|
||||
, is_constructible<_Hp, _Tp>
|
||||
>::value
|
||||
>::type
|
||||
@@ -929,6 +924,16 @@ public:
|
||||
void swap(tuple&) _NOEXCEPT {}
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
// NOTE: These are not yet standardized, but are required to simulate the
|
||||
// implicit deduction guide that should be generated had libc++ declared the
|
||||
// tuple-like constructors "correctly"
|
||||
template <class _Alloc, class ..._Args>
|
||||
tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
|
||||
template <class _Alloc, class ..._Args>
|
||||
tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
|
||||
#endif
|
||||
|
||||
template <class ..._Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if
|
||||
@@ -1002,10 +1007,10 @@ constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
|
||||
|
||||
template <class _T1, class ..._Args>
|
||||
struct __find_exactly_one_checked {
|
||||
static constexpr bool __matches[] = {is_same<_T1, _Args>::value...};
|
||||
static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
|
||||
static constexpr size_t value = __find_detail::__find_idx(0, __matches);
|
||||
static_assert (value != __not_found, "type not found in type list" );
|
||||
static_assert(value != __ambiguous,"type occurs more than once in type list");
|
||||
static_assert(value != __not_found, "type not found in type list" );
|
||||
static_assert(value != __ambiguous, "type occurs more than once in type list");
|
||||
};
|
||||
|
||||
template <class _T1>
|
||||
@@ -1069,7 +1074,7 @@ struct __ignore_t
|
||||
};
|
||||
|
||||
namespace {
|
||||
constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
|
||||
_LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
@@ -1358,7 +1363,7 @@ pair<_T1, _T2>::pair(piecewise_construct_t,
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
template <class _Tp>
|
||||
constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
|
||||
_LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
|
||||
|
||||
#define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
|
||||
|
||||
@@ -1378,7 +1383,7 @@ constexpr decltype(auto) apply(_Fn && __f, _Tuple && __t)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_VSTD::__apply_tuple_impl(
|
||||
_VSTD::forward<_Fn>(__f), _VSTD::forward<_Tuple>(__t),
|
||||
typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
|
||||
typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
template <class _Tp, class _Tuple, size_t... _Idx>
|
||||
@@ -1393,7 +1398,7 @@ inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr _Tp make_from_tuple(_Tuple&& __t)
|
||||
_LIBCPP_NOEXCEPT_RETURN(
|
||||
_VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t),
|
||||
typename __make_tuple_indices<tuple_size_v<decay_t<_Tuple>>>::type{})
|
||||
typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{})
|
||||
)
|
||||
|
||||
#undef _LIBCPP_NOEXCEPT_RETURN
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -69,18 +69,21 @@ public:
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include <vcruntime_typeinfo.h>
|
||||
#elif defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
|
||||
#else
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
|
||||
#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
|
||||
#else
|
||||
#define _LIBCPP_HAS_UNIQUE_TYPEINFO
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace std // purposefully not using versioning namespace
|
||||
{
|
||||
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
class _LIBCPP_EXCEPTION_ABI type_info
|
||||
{
|
||||
type_info& operator=(const type_info&);
|
||||
@@ -92,7 +95,17 @@ class _LIBCPP_EXCEPTION_ABI type_info
|
||||
{ return __builtin_strcmp(name(), __arg.name()); }
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
mutable struct {
|
||||
const char *__undecorated_name;
|
||||
const char __decorated_name[1];
|
||||
} __data;
|
||||
|
||||
int __compare(const type_info &__rhs) const _NOEXCEPT;
|
||||
#endif // _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
protected:
|
||||
#if !defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
|
||||
// A const char* with the non-unique RTTI bit possibly set.
|
||||
uintptr_t __type_name;
|
||||
@@ -106,11 +119,27 @@ protected:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit type_info(const char* __n) : __type_name(__n) {}
|
||||
#endif
|
||||
#endif // ! _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
public:
|
||||
_LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
|
||||
virtual ~type_info();
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
const char *name() const _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool before(const type_info& __arg) const _NOEXCEPT {
|
||||
return __compare(__arg) < 0;
|
||||
}
|
||||
|
||||
size_t hash_code() const _NOEXCEPT;
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator==(const type_info& __arg) const _NOEXCEPT {
|
||||
return __compare(__arg) == 0;
|
||||
}
|
||||
#else
|
||||
#if defined(_LIBCPP_HAS_NONUNIQUE_TYPEINFO)
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
const char* name() const _NOEXCEPT
|
||||
@@ -167,6 +196,7 @@ public:
|
||||
bool operator==(const type_info& __arg) const _NOEXCEPT
|
||||
{ return __type_name == __arg.__type_name; }
|
||||
#endif
|
||||
#endif // _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator!=(const type_info& __arg) const _NOEXCEPT
|
||||
@@ -191,10 +221,10 @@ public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT
|
||||
|
||||
} // std
|
||||
|
||||
#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
void __throw_bad_cast()
|
||||
|
||||
@@ -885,7 +885,7 @@ public:
|
||||
allocator_type get_allocator() const _NOEXCEPT
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __table_.size();}
|
||||
@@ -1634,7 +1634,7 @@ public:
|
||||
allocator_type get_allocator() const _NOEXCEPT
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __table_.size();}
|
||||
|
||||
@@ -450,7 +450,7 @@ public:
|
||||
allocator_type get_allocator() const _NOEXCEPT
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __table_.size();}
|
||||
@@ -968,7 +968,7 @@ public:
|
||||
allocator_type get_allocator() const _NOEXCEPT
|
||||
{return allocator_type(__table_.__node_alloc());}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT {return __table_.size();}
|
||||
|
||||
@@ -99,7 +99,7 @@ void
|
||||
swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
|
||||
|
||||
struct piecewise_construct_t { };
|
||||
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||
inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||
|
||||
template <class T> class tuple_size;
|
||||
template <size_t I, class T> class tuple_element;
|
||||
@@ -296,7 +296,7 @@ struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { };
|
||||
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_UTILITY)
|
||||
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
|
||||
#else
|
||||
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||
/* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
|
||||
@@ -545,6 +545,11 @@ private:
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
template<class _T1, class _T2>
|
||||
pair(_T1, _T2) -> pair<_T1, _T2>;
|
||||
#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES
|
||||
|
||||
template <class _T1, class _T2>
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||
bool
|
||||
@@ -653,6 +658,12 @@ template <class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
|
||||
: public integral_constant<size_t, 2> {};
|
||||
|
||||
template <size_t _Ip, class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> >
|
||||
{
|
||||
static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
|
||||
};
|
||||
|
||||
template <class _T1, class _T2>
|
||||
class _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> >
|
||||
{
|
||||
@@ -879,7 +890,7 @@ template<class... _Tp>
|
||||
|
||||
#if _LIBCPP_STD_VER > 11
|
||||
template<class _T1, class _T2 = _T1>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
|
||||
_T1 exchange(_T1& __obj, _T2 && __new_value)
|
||||
{
|
||||
_T1 __old_value = _VSTD::move(__obj);
|
||||
@@ -893,30 +904,21 @@ _T1 exchange(_T1& __obj, _T2 && __new_value)
|
||||
struct _LIBCPP_TYPE_VIS in_place_t {
|
||||
explicit in_place_t() = default;
|
||||
};
|
||||
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
|
||||
inline
|
||||
#endif
|
||||
constexpr in_place_t in_place{};
|
||||
_LIBCPP_INLINE_VAR constexpr in_place_t in_place{};
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS in_place_type_t {
|
||||
explicit in_place_type_t() = default;
|
||||
};
|
||||
template <class _Tp>
|
||||
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
|
||||
inline
|
||||
#endif
|
||||
constexpr in_place_type_t<_Tp> in_place_type{};
|
||||
_LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{};
|
||||
|
||||
template <size_t _Idx>
|
||||
struct _LIBCPP_TYPE_VIS in_place_index_t {
|
||||
explicit in_place_index_t() = default;
|
||||
};
|
||||
template <size_t _Idx>
|
||||
#ifndef _LIBCPP_HAS_NO_INLINE_VARIABLES
|
||||
inline
|
||||
#endif
|
||||
constexpr in_place_index_t<_Idx> in_place_index{};
|
||||
_LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{};
|
||||
|
||||
template <class _Tp> struct __is_inplace_type_imp : false_type {};
|
||||
template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {};
|
||||
@@ -924,6 +926,12 @@ template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_t
|
||||
template <class _Tp>
|
||||
using __is_inplace_type = __is_inplace_type_imp<__uncvref_t<_Tp>>;
|
||||
|
||||
template <class _Tp> struct __is_inplace_index_imp : false_type {};
|
||||
template <size_t _Idx> struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
|
||||
|
||||
template <class _Tp>
|
||||
using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
template <class _Arg, class _Result>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user