Vendor import of libc++ trunk r321017:
https://llvm.org/svn/llvm-project/libcxx/trunk@321017
This commit is contained in:
parent
dbabdb5220
commit
0564cdb94a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/libc++/dist/; revision=326945 svn path=/vendor/libc++/libc++-trunk-r321017/; revision=326946; tag=vendor/libc++/libc++-trunk-r321017
@ -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.0)
|
||||
set(PACKAGE_VERSION 6.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)
|
||||
@ -337,6 +340,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
|
||||
#===============================================================================
|
||||
@ -594,6 +601,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)
|
||||
@ -606,6 +615,19 @@ config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD)
|
||||
config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
|
||||
config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
|
||||
config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
|
||||
config_define_if(LIBCXX_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
|
||||
@ -615,9 +637,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
|
||||
@ -627,6 +650,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()
|
||||
|
||||
#===============================================================================
|
||||
@ -647,6 +675,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()
|
||||
@ -654,6 +683,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.
|
||||
|
@ -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"
|
||||
|
@ -56,7 +56,7 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
|
||||
if (LIBCXX_INSTALL_HEADERS)
|
||||
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
|
||||
DESTINATION ${LIBCXX_INSTALL_PREFIX}include/c++/v1/${dstdir}
|
||||
COMPONENT libcxx
|
||||
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 ^
|
||||
@ -347,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
|
||||
|
@ -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 @@
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '5.0'
|
||||
version = '6.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '5.0'
|
||||
release = '6.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
|
551
fuzzing/fuzzing.cpp
Normal file
551
fuzzing/fuzzing.cpp
Normal file
@ -0,0 +1,551 @@
|
||||
// -*- 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;
|
||||
|
||||
// == 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 (!std::is_permutation(data, data + size, working.begin())) 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 (!std::is_permutation(input.begin(), input.end(), working.begin())) 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 (!std::is_permutation(data, data + size, working.begin())) 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 (!std::is_permutation(input.begin(), input.end(), working.begin())) 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 (!std::is_permutation(data + 1, data + size, working.begin())) 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 (!std::is_permutation(data + 1, data + size, working.begin())) 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 (!std::is_permutation(data, data + size, working.begin())) 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 (!std::is_permutation(data, data + size, working.begin())) 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
|
@ -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()
|
||||
|
105
include/__config
105
include/__config
@ -33,7 +33,7 @@
|
||||
#define _GNUC_VER_NEW 0
|
||||
#endif
|
||||
|
||||
#define _LIBCPP_VERSION 5000
|
||||
#define _LIBCPP_VERSION 6000
|
||||
|
||||
#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,9 +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
|
||||
@ -121,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
|
||||
@ -157,11 +164,21 @@
|
||||
|
||||
// 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.
|
||||
@ -174,36 +191,30 @@
|
||||
|
||||
#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
|
||||
@ -213,19 +224,16 @@
|
||||
#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
|
||||
@ -255,11 +263,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__
|
||||
|
||||
@ -269,6 +275,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
|
||||
@ -280,18 +288,16 @@
|
||||
# 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__) && !defined(_LIBCPP_COMPILER_GCC)
|
||||
#define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
|
||||
@ -454,6 +460,10 @@ 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
|
||||
|
||||
#elif defined(_LIBCPP_COMPILER_GCC)
|
||||
|
||||
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
|
||||
@ -536,6 +546,10 @@ namespace std {
|
||||
#define _LIBCPP_HAS_NO_ASAN
|
||||
#endif
|
||||
|
||||
#if _GNUC_VER >= 700
|
||||
#define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER
|
||||
#endif
|
||||
|
||||
#elif defined(_LIBCPP_COMPILER_MSVC)
|
||||
|
||||
#define _LIBCPP_TOSTRING2(x) #x
|
||||
@ -880,7 +894,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
|
||||
@ -954,6 +968,18 @@ template <unsigned> struct __static_assert_check {};
|
||||
#define _LIBCPP_CONSTEXPR_AFTER_CXX14
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
// 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
|
||||
@ -1241,6 +1267,13 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
# endif
|
||||
#endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
# if defined(_DLL)
|
||||
# pragma(lib, "c++.lib")
|
||||
# else
|
||||
# pragma(lib, "libc++.lib")
|
||||
# endif
|
||||
#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
@ -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
|
||||
@ -23,5 +25,8 @@
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
|
||||
#cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
|
||||
#cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
#cmakedefine _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
@_LIBCPP_ABI_DEFINES@
|
||||
|
||||
#endif // _LIBCPP_CONFIG_SITE
|
||||
|
@ -1 +1 @@
|
||||
5000
|
||||
6000
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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>
|
||||
|
@ -734,15 +734,15 @@ struct __less<_T1, const _T1>
|
||||
};
|
||||
|
||||
template <class _Predicate>
|
||||
class __negate
|
||||
class __invert // invert the sense of a comparison
|
||||
{
|
||||
private:
|
||||
_Predicate __p_;
|
||||
public:
|
||||
_LIBCPP_INLINE_VISIBILITY __negate() {}
|
||||
_LIBCPP_INLINE_VISIBILITY __invert() {}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
explicit __negate(_Predicate __p) : __p_(__p) {}
|
||||
explicit __invert(_Predicate __p) : __p_(__p) {}
|
||||
|
||||
template <class _T1>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
@ -750,7 +750,7 @@ public:
|
||||
|
||||
template <class _T1, class _T2>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);}
|
||||
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
|
||||
};
|
||||
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
@ -797,7 +797,7 @@ unsigned __ctz(unsigned __x) {
|
||||
unsigned long where;
|
||||
// Search from LSB to MSB for first set bit.
|
||||
// Returns zero if no set bit is found.
|
||||
if (_BitScanForward(&where, mask))
|
||||
if (_BitScanForward(&where, __x))
|
||||
return where;
|
||||
return 32;
|
||||
#endif
|
||||
@ -823,15 +823,15 @@ unsigned long long __ctz(unsigned long long __x) {
|
||||
// Returns zero if no set bit is found.
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
(defined(_M_AMD64) || defined(__x86_64__))
|
||||
if (_BitScanForward64(&where, mask))
|
||||
if (_BitScanForward64(&where, __x))
|
||||
return static_cast<int>(where);
|
||||
#else
|
||||
// Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
|
||||
// Scan the Low Word.
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(__x)))
|
||||
return where;
|
||||
// Scan the High Word.
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
|
||||
if (_BitScanForward(&where, static_cast<unsigned long>(__x >> 32)))
|
||||
return where + 32; // Create a bit offset from the LSB.
|
||||
#endif
|
||||
return 64;
|
||||
@ -849,7 +849,7 @@ unsigned __clz(unsigned __x) {
|
||||
unsigned long where;
|
||||
// Search from LSB to MSB for first set bit.
|
||||
// Returns zero if no set bit is found.
|
||||
if (_BitScanReverse(&where, mask))
|
||||
if (_BitScanReverse(&where, __x))
|
||||
return 31 - where;
|
||||
return 32; // Undefined Behavior.
|
||||
#endif
|
||||
@ -874,14 +874,14 @@ unsigned long long __clz(unsigned long long __x) {
|
||||
// BitScanReverse scans from MSB to LSB for first set bit.
|
||||
// Returns 0 if no set bit is found.
|
||||
#if defined(_LIBCPP_HAS_BITSCAN64)
|
||||
if (_BitScanReverse64(&where, mask))
|
||||
if (_BitScanReverse64(&where, __x))
|
||||
return static_cast<int>(63 - where);
|
||||
#else
|
||||
// Scan the high 32 bits.
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(__x >> 32)))
|
||||
return 63 - (where + 32); // Create a bit offset from the MSB.
|
||||
// Scan the low 32 bits.
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
|
||||
if (_BitScanReverse(&where, static_cast<unsigned long>(__x)))
|
||||
return 63 - where;
|
||||
#endif
|
||||
return 64; // Undefined Behavior.
|
||||
@ -3210,28 +3210,28 @@ template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n,
|
||||
_UniformRandomNumberGenerator & __g,
|
||||
input_iterator_tag) {
|
||||
|
||||
_Distance __k = 0;
|
||||
for (; __first != __last && __k < __n; ++__first, (void)++__k)
|
||||
__output[__k] = *__first;
|
||||
__output_iter[__k] = *__first;
|
||||
_Distance __sz = __k;
|
||||
for (; __first != __last; ++__first, (void)++__k) {
|
||||
_Distance __r = _VSTD::uniform_int_distribution<_Distance>(0, __k)(__g);
|
||||
if (__r < __sz)
|
||||
__output[__r] = *__first;
|
||||
__output_iter[__r] = *__first;
|
||||
}
|
||||
return __output + _VSTD::min(__n, __k);
|
||||
return __output_iter + _VSTD::min(__n, __k);
|
||||
}
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n,
|
||||
_UniformRandomNumberGenerator& __g,
|
||||
forward_iterator_tag) {
|
||||
@ -3240,18 +3240,18 @@ _SampleIterator __sample(_PopulationIterator __first,
|
||||
_Distance __r =
|
||||
_VSTD::uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
|
||||
if (__r < __n) {
|
||||
*__output++ = *__first;
|
||||
*__output_iter++ = *__first;
|
||||
--__n;
|
||||
}
|
||||
}
|
||||
return __output;
|
||||
return __output_iter;
|
||||
}
|
||||
|
||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator __sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n, _UniformRandomNumberGenerator& __g) {
|
||||
typedef typename iterator_traits<_PopulationIterator>::iterator_category
|
||||
_PopCategory;
|
||||
@ -3263,7 +3263,7 @@ _SampleIterator __sample(_PopulationIterator __first,
|
||||
typedef typename common_type<_Distance, _Difference>::type _CommonType;
|
||||
_LIBCPP_ASSERT(__n >= 0, "N must be a positive number.");
|
||||
return _VSTD::__sample(
|
||||
__first, __last, __output, _CommonType(__n),
|
||||
__first, __last, __output_iter, _CommonType(__n),
|
||||
__g, _PopCategory());
|
||||
}
|
||||
|
||||
@ -3272,9 +3272,9 @@ template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator sample(_PopulationIterator __first,
|
||||
_PopulationIterator __last, _SampleIterator __output,
|
||||
_PopulationIterator __last, _SampleIterator __output_iter,
|
||||
_Distance __n, _UniformRandomNumberGenerator&& __g) {
|
||||
return _VSTD::__sample(__first, __last, __output, __n, __g);
|
||||
return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
|
||||
}
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
@ -4568,7 +4568,7 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
|
||||
typedef reverse_iterator<value_type*> _Rv;
|
||||
__half_inplace_merge(_Rv(__p), _Rv(__buff),
|
||||
_RBi(__middle), _RBi(__first),
|
||||
_RBi(__last), __negate<_Compare>(__comp));
|
||||
_RBi(__last), __invert<_Compare>(__comp));
|
||||
}
|
||||
}
|
||||
|
||||
@ -5547,9 +5547,9 @@ __set_union(_InputIterator1 __first1, _InputIterator1 __last1,
|
||||
}
|
||||
else
|
||||
{
|
||||
*__result = *__first1;
|
||||
if (!__comp(*__first1, *__first2))
|
||||
++__first2;
|
||||
*__result = *__first1;
|
||||
++__first1;
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ 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_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
|
||||
|
||||
// element access:
|
||||
|
@ -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)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
@ -1087,67 +1087,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);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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) \
|
||||
|
@ -61,9 +61,9 @@ template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||
class _UniformRandomNumberGenerator>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
|
||||
_SampleIterator __output, _Distance __n,
|
||||
_SampleIterator __output_iter, _Distance __n,
|
||||
_UniformRandomNumberGenerator &&__g) {
|
||||
return _VSTD::__sample(__first, __last, __output, __n, __g);
|
||||
return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
|
||||
}
|
||||
|
||||
_LIBCPP_END_NAMESPACE_LFTS
|
||||
|
@ -81,10 +81,10 @@
|
||||
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;
|
||||
@ -972,7 +972,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(); }
|
||||
@ -1351,7 +1352,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 +1363,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);
|
||||
}
|
||||
|
||||
@ -1561,7 +1562,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);
|
||||
}
|
||||
|
||||
@ -1903,12 +1904,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 +1944,7 @@ public:
|
||||
return __p;
|
||||
}
|
||||
|
||||
directory_iterator& increment(error_code& __ec) _NOEXCEPT
|
||||
directory_iterator& increment(error_code& __ec)
|
||||
{ return __increment(&__ec); }
|
||||
|
||||
private:
|
||||
@ -2013,12 +2014,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 +2061,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;
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -315,7 +315,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 +434,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 +450,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -724,7 +724,7 @@ basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
this->setp(const_cast<char_type*>(__e), this->pptr());
|
||||
this->pbump(this->epptr() - this->pbase());
|
||||
this->__pbump(this->epptr() - this->pbase());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1069,16 +1069,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
|
||||
|
||||
|
60
include/list
60
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
|
||||
@ -1071,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;
|
||||
@ -1397,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();
|
||||
@ -1426,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
|
||||
@ -1494,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
|
||||
@ -1549,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);
|
||||
@ -1563,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();
|
||||
@ -1578,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();
|
||||
@ -1591,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();
|
||||
@ -1609,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();
|
||||
@ -1631,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);
|
||||
@ -1655,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);
|
||||
@ -1680,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);
|
||||
@ -1855,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
|
||||
@ -1914,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();
|
||||
|
@ -4110,7 +4110,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c)
|
||||
if (__r == codecvt_base::partial)
|
||||
{
|
||||
this->setp(const_cast<char_type *>(__e), this->pptr());
|
||||
this->pbump(this->epptr() - this->pbase());
|
||||
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();}
|
||||
|
139
include/memory
139
include/memory
@ -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
|
||||
{
|
||||
@ -724,7 +730,7 @@ template <class _Tp, class = void>
|
||||
struct __has_element_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_element_type<_Tp,
|
||||
struct __has_element_type<_Tp,
|
||||
typename __void_t<typename _Tp::element_type>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, bool = __has_element_type<_Ptr>::value>
|
||||
@ -808,7 +814,7 @@ template <class _Tp, class = void>
|
||||
struct __has_difference_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_difference_type<_Tp,
|
||||
struct __has_difference_type<_Tp,
|
||||
typename __void_t<typename _Tp::difference_type>::type> : true_type {};
|
||||
|
||||
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
|
||||
@ -994,7 +1000,7 @@ template <class _Tp, class = void>
|
||||
struct __has_pointer_type : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_pointer_type<_Tp,
|
||||
struct __has_pointer_type<_Tp,
|
||||
typename __void_t<typename _Tp::pointer>::type> : true_type {};
|
||||
|
||||
namespace __pointer_type_imp
|
||||
@ -1024,7 +1030,7 @@ template <class _Tp, class = void>
|
||||
struct __has_const_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_const_pointer<_Tp,
|
||||
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>
|
||||
@ -1047,7 +1053,7 @@ template <class _Tp, class = void>
|
||||
struct __has_void_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_void_pointer<_Tp,
|
||||
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>
|
||||
@ -1070,7 +1076,7 @@ template <class _Tp, class = void>
|
||||
struct __has_const_void_pointer : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_const_void_pointer<_Tp,
|
||||
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>
|
||||
@ -1090,13 +1096,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*
|
||||
@ -1104,6 +1111,41 @@ __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>
|
||||
inline _LIBCPP_INLINE_VISIBILITY constexpr
|
||||
_Tp*
|
||||
to_address(_Tp* __p) _NOEXCEPT
|
||||
{
|
||||
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 {};
|
||||
@ -1148,7 +1190,7 @@ template <class _Tp, class = void>
|
||||
struct __has_propagate_on_container_move_assignment : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_propagate_on_container_move_assignment<_Tp,
|
||||
struct __has_propagate_on_container_move_assignment<_Tp,
|
||||
typename __void_t<typename _Tp::propagate_on_container_move_assignment>::type>
|
||||
: true_type {};
|
||||
|
||||
@ -1168,7 +1210,7 @@ template <class _Tp, class = void>
|
||||
struct __has_propagate_on_container_swap : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_propagate_on_container_swap<_Tp,
|
||||
struct __has_propagate_on_container_swap<_Tp,
|
||||
typename __void_t<typename _Tp::propagate_on_container_swap>::type>
|
||||
: true_type {};
|
||||
|
||||
@ -1188,7 +1230,7 @@ template <class _Tp, class = void>
|
||||
struct __has_is_always_equal : false_type {};
|
||||
|
||||
template <class _Tp>
|
||||
struct __has_is_always_equal<_Tp,
|
||||
struct __has_is_always_equal<_Tp,
|
||||
typename __void_t<typename _Tp::is_always_equal>::type>
|
||||
: true_type {};
|
||||
|
||||
@ -1302,7 +1344,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
|
||||
@ -1313,7 +1355,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>
|
||||
@ -1346,7 +1388,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>
|
||||
@ -1367,7 +1409,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>
|
||||
{
|
||||
@ -1387,7 +1429,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>
|
||||
{
|
||||
};
|
||||
@ -1406,7 +1448,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>
|
||||
{
|
||||
};
|
||||
@ -1497,10 +1539,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>());}
|
||||
@ -1688,10 +1730,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
|
||||
@ -1739,7 +1781,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)"
|
||||
@ -1941,7 +1984,7 @@ 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
|
||||
};
|
||||
|
||||
@ -2040,11 +2083,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)){};
|
||||
@ -2055,11 +2099,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:
|
||||
@ -2074,11 +2120,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)){};
|
||||
@ -2089,12 +2136,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; }
|
||||
};
|
||||
|
||||
@ -3850,7 +3899,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_Dp* __get_deleter() const _NOEXCEPT
|
||||
{return static_cast<_Dp*>(__cntrl_
|
||||
? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
|
||||
? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp)))
|
||||
: nullptr);}
|
||||
#endif // _LIBCPP_NO_RTTI
|
||||
|
||||
@ -4216,6 +4265,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;
|
||||
@ -4234,6 +4284,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;
|
||||
@ -4254,6 +4305,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;
|
||||
@ -4272,6 +4324,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;
|
||||
@ -4290,6 +4343,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;
|
||||
@ -4308,6 +4362,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;
|
||||
@ -4326,6 +4381,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;
|
||||
@ -4345,6 +4401,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;
|
||||
@ -4364,6 +4421,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;
|
||||
@ -4383,6 +4441,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;
|
||||
@ -4477,7 +4536,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
|
||||
@ -4512,7 +4571,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
|
||||
@ -5311,7 +5370,7 @@ atomic_load(const shared_ptr<_Tp>* __p)
|
||||
__m.unlock();
|
||||
return __q;
|
||||
}
|
||||
|
||||
|
||||
template <class _Tp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
|
||||
@ -5352,7 +5411,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
|
||||
@ -5484,7 +5543,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>());
|
||||
}
|
||||
|
||||
@ -5506,7 +5565,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
|
||||
@ -5520,17 +5579,17 @@ 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
|
||||
|
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
|
||||
|
@ -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 );
|
||||
|
@ -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();}
|
||||
@ -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)
|
||||
|
138
include/regex
138
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
|
||||
@ -2407,17 +2409,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_ ?
|
||||
@ -2449,11 +2462,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
|
||||
@ -4056,6 +4064,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;
|
||||
}
|
||||
@ -4317,8 +4327,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);
|
||||
}
|
||||
@ -5226,11 +5240,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
|
||||
@ -5263,15 +5277,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>
|
||||
@ -5383,7 +5397,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
|
||||
{
|
||||
@ -5392,27 +5406,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5425,52 +5439,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>
|
||||
@ -5552,8 +5568,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);
|
||||
@ -5627,8 +5649,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);
|
||||
@ -5724,8 +5752,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);
|
||||
@ -6460,7 +6494,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)
|
||||
@ -6471,7 +6505,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
|
||||
{
|
||||
@ -6479,29 +6513,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();}
|
||||
|
@ -243,7 +243,6 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode
|
||||
: __hm_(0),
|
||||
__mode_(__wch)
|
||||
{
|
||||
str(string_type());
|
||||
}
|
||||
|
||||
template <class _CharT, class _Traits, class _Allocator>
|
||||
@ -289,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());
|
||||
@ -332,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);
|
||||
@ -403,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);
|
||||
@ -416,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);
|
||||
@ -471,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,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
|
||||
}
|
||||
|
@ -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();}
|
||||
|
@ -255,6 +255,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 +407,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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
@ -608,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
|
||||
@ -670,7 +677,7 @@ private:
|
||||
size_type __cap_;
|
||||
};
|
||||
|
||||
#if _LIBCPP_BIG_ENDIAN
|
||||
#ifdef _LIBCPP_BIG_ENDIAN
|
||||
static const size_type __short_mask = 0x01;
|
||||
static const size_type __long_mask = 0x1ul;
|
||||
#else // _LIBCPP_BIG_ENDIAN
|
||||
@ -700,7 +707,7 @@ private:
|
||||
pointer __data_;
|
||||
};
|
||||
|
||||
#if _LIBCPP_BIG_ENDIAN
|
||||
#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
|
||||
@ -901,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;
|
||||
@ -1127,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
|
||||
@ -1214,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
|
||||
@ -1241,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);}
|
||||
@ -1249,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_;}
|
||||
@ -1259,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);}
|
||||
@ -1267,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;}
|
||||
@ -1756,10 +1790,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);
|
||||
@ -2145,7 +2179,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)
|
||||
{
|
||||
@ -2493,7 +2527,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)
|
||||
@ -2682,8 +2716,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)
|
||||
@ -2870,7 +2904,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;
|
||||
@ -3462,8 +3496,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,
|
||||
|
@ -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 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);
|
||||
|
||||
static_assert(is_pod<value_type>::value, "Character type of basic_string_view must be a POD");
|
||||
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);
|
||||
}
|
||||
|
@ -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__ )
|
||||
|
@ -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
|
||||
|
@ -929,7 +929,7 @@ public:
|
||||
void swap(tuple&) _NOEXCEPT {}
|
||||
};
|
||||
|
||||
#ifdef __cpp_deduction_guides
|
||||
#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"
|
||||
@ -1012,10 +1012,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>
|
||||
|
@ -137,25 +137,25 @@ namespace std
|
||||
template <class Base, class Derived> struct is_base_of;
|
||||
template <class From, class To> struct is_convertible;
|
||||
|
||||
template <class, class R = void> struct is_callable; // not defined
|
||||
template <class Fn, class... ArgTypes, class R>
|
||||
struct is_callable<Fn(ArgTypes...), R>;
|
||||
template <class Fn, class... ArgTypes> struct is_invocable;
|
||||
template <class R, class Fn, class... ArgTypes> struct is_invocable_r;
|
||||
|
||||
template <class, class R = void> struct is_nothrow_callable; // not defined
|
||||
template <class Fn, class... ArgTypes, class R>
|
||||
struct is_nothrow_callable<Fn(ArgTypes...), R>;
|
||||
template <class Fn, class... ArgTypes> struct is_nothrow_invocable;
|
||||
template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;
|
||||
|
||||
// Alignment properties and transformations:
|
||||
template <class T> struct alignment_of;
|
||||
template <size_t Len, size_t Align = most_stringent_alignment_requirement>
|
||||
struct aligned_storage;
|
||||
template <size_t Len, class... Types> struct aligned_union;
|
||||
template <class T> struct remove_cvref; // C++20
|
||||
|
||||
template <class T> struct decay;
|
||||
template <class... T> struct common_type;
|
||||
template <class T> struct underlying_type;
|
||||
template <class> class result_of; // undefined
|
||||
template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>;
|
||||
template <class Fn, class... ArgTypes> struct invoke_result; // C++17
|
||||
|
||||
// const-volatile modifications:
|
||||
template <class T>
|
||||
@ -202,6 +202,8 @@ namespace std
|
||||
using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14
|
||||
template <std::size_t Len, class... Types>
|
||||
using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14
|
||||
template <class T>
|
||||
using remove_cvref_t = typename remove_cvref<T>::type; // C++20
|
||||
template <class T>
|
||||
using decay_t = typename decay<T>::type; // C++14
|
||||
template <bool b, class T=void>
|
||||
@ -212,8 +214,10 @@ namespace std
|
||||
using common_type_t = typename common_type<T...>::type; // C++14
|
||||
template <class T>
|
||||
using underlying_type_t = typename underlying_type<T>::type; // C++14
|
||||
template <class F, class... ArgTypes>
|
||||
using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14
|
||||
template <class T>
|
||||
using result_of_t = typename result_of<T>::type; // C++14
|
||||
template <class Fn, class... ArgTypes>
|
||||
using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17
|
||||
|
||||
template <class...>
|
||||
using void_t = void; // C++17
|
||||
@ -367,10 +371,14 @@ namespace std
|
||||
= is_base_of<Base, Derived>::value; // C++17
|
||||
template <class From, class To> constexpr bool is_convertible_v
|
||||
= is_convertible<From, To>::value; // C++17
|
||||
template <class T, class R = void> constexpr bool is_callable_v
|
||||
= is_callable<T, R>::value; // C++17
|
||||
template <class T, class R = void> constexpr bool is_nothrow_callable_v
|
||||
= is_nothrow_callable<T, R>::value; // C++17
|
||||
template <class Fn, class... ArgTypes> constexpr bool is_invocable_v
|
||||
= is_invocable<Fn, ArgTypes...>::value; // C++17
|
||||
template <class R, class Fn, class... ArgTypes> constexpr bool is_invocable_r_v
|
||||
= is_invocable_r<R, Fn, ArgTypes...>::value; // C++17
|
||||
template <class Fn, class... ArgTypes> constexpr bool is_nothrow_invocable_v
|
||||
= is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17
|
||||
template <class R, class Fn, class... ArgTypes> constexpr bool is_nothrow_invocable_r_v
|
||||
= is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17
|
||||
|
||||
// [meta.logical], logical operator traits:
|
||||
template<class... B> struct conjunction; // C++17
|
||||
@ -1141,6 +1149,17 @@ template <class _Tp, class _Up>
|
||||
struct __is_same_uncvref : is_same<typename __uncvref<_Tp>::type,
|
||||
typename __uncvref<_Up>::type> {};
|
||||
|
||||
#if _LIBCPP_STD_VER > 17
|
||||
// aligned_union - same as __uncvref
|
||||
template <class _Tp>
|
||||
struct remove_cvref {
|
||||
using type = remove_cv_t<remove_reference_t<_Tp>>;
|
||||
};
|
||||
|
||||
template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type;
|
||||
#endif
|
||||
|
||||
|
||||
struct __any
|
||||
{
|
||||
__any(...);
|
||||
@ -4387,6 +4406,13 @@ using __nothrow_invokable_r =
|
||||
_Ret, _Fp, _Args...
|
||||
>;
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
using __nothrow_invokable =
|
||||
__nothrow_invokable_r_imp<
|
||||
__invokable<_Fp, _Args...>::value,
|
||||
true, void, _Fp, _Args...
|
||||
>;
|
||||
|
||||
template <class _Fp, class ..._Args>
|
||||
struct __invoke_of
|
||||
: public enable_if<
|
||||
@ -4409,30 +4435,48 @@ template <class _Tp> using result_of_t = typename result_of<_Tp>::type;
|
||||
|
||||
#if _LIBCPP_STD_VER > 14
|
||||
|
||||
// is_callable
|
||||
// invoke_result
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_callable;
|
||||
template <class _Fn, class... _Args>
|
||||
struct _LIBCPP_TEMPLATE_VIS invoke_result
|
||||
: __invoke_of<_Fn, _Args...>
|
||||
{
|
||||
};
|
||||
|
||||
template <class _Fn, class ..._Args, class _Ret>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_callable<_Fn(_Args...), _Ret>
|
||||
template <class _Fn, class... _Args>
|
||||
using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
|
||||
|
||||
// is_invocable
|
||||
|
||||
template <class _Fn, class ..._Args>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_invocable
|
||||
: integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
|
||||
|
||||
template <class _Ret, class _Fn, class ..._Args>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_invocable_r
|
||||
: integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
constexpr bool is_callable_v = is_callable<_Fn, _Ret>::value;
|
||||
template <class _Fn, class ..._Args>
|
||||
constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
|
||||
|
||||
template <class _Ret, class _Fn, class ..._Args>
|
||||
constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
|
||||
|
||||
// is_nothrow_callable
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable;
|
||||
template <class _Fn, class ..._Args>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable
|
||||
: integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {};
|
||||
|
||||
template <class _Fn, class ..._Args, class _Ret>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_callable<_Fn(_Args...), _Ret>
|
||||
: integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value>
|
||||
{};
|
||||
template <class _Ret, class _Fn, class ..._Args>
|
||||
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
|
||||
: integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
|
||||
|
||||
template <class _Fn, class _Ret = void>
|
||||
constexpr bool is_nothrow_callable_v = is_nothrow_callable<_Fn, _Ret>::value;
|
||||
template <class _Fn, class ..._Args>
|
||||
constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
|
||||
|
||||
template <class _Ret, class _Fn, class ..._Args>
|
||||
constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
|
||||
|
||||
#endif // _LIBCPP_STD_VER > 14
|
||||
|
||||
@ -4638,6 +4682,11 @@ long long __convert_to_integral(long long __val) { return __val; }
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
unsigned long long __convert_to_integral(unsigned long long __val) {return __val; }
|
||||
|
||||
template<typename _Fp>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
typename enable_if<is_floating_point<_Fp>::value, long long>::type
|
||||
__convert_to_integral(_Fp __val) { return __val; }
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_INT128
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
__int128_t __convert_to_integral(__int128_t __val) { return __val; }
|
||||
@ -4747,26 +4796,26 @@ namespace std // purposefully not versioned
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
|
||||
operator<<=(byte& __lhs, _Integer __shift) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) << __shift); }
|
||||
{ return __lhs = __lhs << __shift; }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator<< (byte __lhs, _Integer __shift) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) << __shift); }
|
||||
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
|
||||
operator>>=(byte& __lhs, _Integer __shift) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) >> __shift); }
|
||||
{ return __lhs = __lhs >> __shift; }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator>> (byte __lhs, _Integer __shift) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) >> __shift); }
|
||||
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
|
||||
to_integer(byte __b) noexcept { return _Integer(__b); }
|
||||
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -69,18 +69,17 @@ public:
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#include <vcruntime_typeinfo.h>
|
||||
#elif defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
|
||||
#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 +91,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 +115,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 +192,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,8 +217,6 @@ public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
#endif // !_LIBCPP_ABI_MICROSOFT
|
||||
|
||||
} // std
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
@ -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();}
|
||||
|
@ -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
|
||||
|
@ -207,11 +207,15 @@ namespace std {
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <limits>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
namespace std { // explicitly not using versioning namespace
|
||||
|
||||
class _LIBCPP_EXCEPTION_ABI bad_variant_access : public exception {
|
||||
@ -283,7 +287,28 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
|
||||
};
|
||||
|
||||
constexpr size_t variant_npos = static_cast<size_t>(-1);
|
||||
constexpr unsigned int __variant_npos = static_cast<unsigned int>(-1);
|
||||
|
||||
constexpr int __choose_index_type(unsigned int __num_elem) {
|
||||
if (__num_elem < std::numeric_limits<unsigned char>::max())
|
||||
return 0;
|
||||
if (__num_elem < std::numeric_limits<unsigned short>::max())
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
template <size_t _NumAlts>
|
||||
using __variant_index_t =
|
||||
#ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
|
||||
unsigned int;
|
||||
#else
|
||||
std::tuple_element_t<
|
||||
__choose_index_type(_NumAlts),
|
||||
std::tuple<unsigned char, unsigned short, unsigned int>
|
||||
>;
|
||||
#endif
|
||||
|
||||
template <class _IndexType>
|
||||
constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
|
||||
|
||||
namespace __find_detail {
|
||||
|
||||
@ -557,7 +582,7 @@ struct __variant {
|
||||
private:
|
||||
template <class _Visitor, class... _Values>
|
||||
static constexpr void __std_visit_exhaustive_visitor_check() {
|
||||
static_assert(is_callable_v<_Visitor(_Values...)>,
|
||||
static_assert(is_invocable_v<_Visitor, _Values...>,
|
||||
"`std::visit` requires the visitor to be exhaustive.");
|
||||
}
|
||||
|
||||
@ -647,9 +672,11 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, ~__union() = delete;);
|
||||
template <_Trait _DestructibleTrait, class... _Types>
|
||||
class _LIBCPP_TEMPLATE_VIS __base {
|
||||
public:
|
||||
using __index_t = __variant_index_t<sizeof...(_Types)>;
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
explicit constexpr __base(__valueless_t tag) noexcept
|
||||
: __data(tag), __index(__variant_npos) {}
|
||||
: __data(tag), __index(__variant_npos<__index_t>) {}
|
||||
|
||||
template <size_t _Ip, class... _Args>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
@ -665,7 +692,7 @@ public:
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
constexpr size_t index() const noexcept {
|
||||
return __index == __variant_npos ? variant_npos : __index;
|
||||
return __index == __variant_npos<__index_t> ? variant_npos : __index;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -685,7 +712,7 @@ protected:
|
||||
static constexpr size_t __size() { return sizeof...(_Types); }
|
||||
|
||||
__union<_DestructibleTrait, 0, _Types...> __data;
|
||||
unsigned int __index;
|
||||
__index_t __index;
|
||||
|
||||
friend struct __access::__base;
|
||||
friend struct __visitation::__base;
|
||||
@ -696,10 +723,11 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
|
||||
|
||||
#define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
|
||||
template <class... _Types> \
|
||||
class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \
|
||||
class _LIBCPP_TEMPLATE_VIS __destructor<__traits<_Types...>, \
|
||||
destructible_trait> \
|
||||
: public __base<destructible_trait, _Types...> { \
|
||||
using __base_type = __base<destructible_trait, _Types...>; \
|
||||
using __index_t = typename __base_type::__index_t; \
|
||||
\
|
||||
public: \
|
||||
using __base_type::__base_type; \
|
||||
@ -719,7 +747,7 @@ class _LIBCPP_TEMPLATE_VIS __destructor;
|
||||
_LIBCPP_VARIANT_DESTRUCTOR(
|
||||
_Trait::_TriviallyAvailable,
|
||||
~__destructor() = default;,
|
||||
void __destroy() noexcept { this->__index = __variant_npos; });
|
||||
void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });
|
||||
|
||||
_LIBCPP_VARIANT_DESTRUCTOR(
|
||||
_Trait::_Available,
|
||||
@ -733,7 +761,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(
|
||||
},
|
||||
*this);
|
||||
}
|
||||
this->__index = __variant_npos;
|
||||
this->__index = __variant_npos<__index_t>;
|
||||
});
|
||||
|
||||
_LIBCPP_VARIANT_DESTRUCTOR(
|
||||
@ -1561,4 +1589,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP_VARIANT
|
||||
|
@ -634,7 +634,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type capacity() const _NOEXCEPT
|
||||
{return __base::capacity();}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT
|
||||
{return this->__begin_ == this->__end_;}
|
||||
size_type max_size() const _NOEXCEPT;
|
||||
@ -2290,7 +2290,7 @@ public:
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
size_type size() const _NOEXCEPT
|
||||
{return __size_;}
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
|
||||
bool empty() const _NOEXCEPT
|
||||
{return __size_ == 0;}
|
||||
void reserve(size_type __n);
|
||||
|
@ -125,6 +125,10 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
|
||||
# if __GLIBC_PREREQ(2, 10)
|
||||
# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
|
||||
# endif
|
||||
#elif defined(_LIBCPP_MSVCRT)
|
||||
# if defined(_CRT_CONST_CORRECT_OVERLOADS)
|
||||
# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
|
||||
|
@ -91,6 +91,7 @@ else()
|
||||
add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
|
||||
endif()
|
||||
add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
|
||||
add_library_flags_if(MINGW "${MINGW_LIBRARIES}")
|
||||
|
||||
# Add the unwinder library.
|
||||
if (LIBCXXABI_USE_LLVM_UNWINDER)
|
||||
@ -269,6 +270,7 @@ if (LIBCXX_ENABLE_STATIC)
|
||||
${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/merge_archives.py
|
||||
ARGS
|
||||
-o $<TARGET_LINKER_FILE:cxx_static>
|
||||
--ar "${CMAKE_AR}"
|
||||
"$<TARGET_LINKER_FILE:cxx_static>"
|
||||
"${MERGE_ARCHIVES_ABI_TARGET}"
|
||||
"${MERGE_ARCHIVES_SEARCH_PATHS}"
|
||||
@ -387,5 +389,13 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DCMAKE_INSTALL_COMPONENT=cxx
|
||||
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
||||
add_custom_target(install-cxx-stripped
|
||||
DEPENDS ${lib_install_target}
|
||||
${experimental_lib_install_target}
|
||||
${header_install_target}
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-DCMAKE_INSTALL_COMPONENT=cxx
|
||||
-DCMAKE_INSTALL_DO_STRIP=1
|
||||
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
||||
add_custom_target(install-libcxx DEPENDS install-cxx)
|
||||
endif()
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,16 @@ New entries should be added directly below the "Version" header.
|
||||
Version 5.0
|
||||
-----------
|
||||
|
||||
* r313500 - Fix undefined "___cxa_deleted_virtual" symbol in macosx
|
||||
|
||||
x86_64-linux-gnu
|
||||
----------------
|
||||
No changes
|
||||
|
||||
x86_64-apple-darwin16.0
|
||||
-----------------------
|
||||
Symbol added: ___cxa_deleted_virtual
|
||||
|
||||
* r296729 - Remove std::num_get template methods which should be inline
|
||||
|
||||
These functions should never have had visible definitions in the dylib but
|
||||
|
@ -2323,6 +2323,8 @@
|
||||
{'type': 'I', 'is_defined': True, 'name': '___cxa_current_exception_type'}
|
||||
{'type': 'U', 'is_defined': False, 'name': '___cxa_current_primary_exception'}
|
||||
{'type': 'U', 'is_defined': False, 'name': '___cxa_decrement_exception_refcount'}
|
||||
{'type': 'U', 'is_defined': False, 'name': '___cxa_deleted_virtual'}
|
||||
{'type': 'I', 'is_defined': True, 'name': '___cxa_deleted_virtual'}
|
||||
{'type': 'U', 'is_defined': False, 'name': '___cxa_demangle'}
|
||||
{'type': 'I', 'is_defined': True, 'name': '___cxa_demangle'}
|
||||
{'type': 'U', 'is_defined': False, 'name': '___cxa_end_catch'}
|
||||
|
@ -12,6 +12,7 @@ ___cxa_guard_acquire
|
||||
___cxa_guard_release
|
||||
___cxa_rethrow
|
||||
___cxa_pure_virtual
|
||||
___cxa_deleted_virtual
|
||||
___cxa_begin_catch
|
||||
___cxa_throw
|
||||
___cxa_vec_cctor
|
||||
|
@ -12,6 +12,7 @@ ___cxa_guard_acquire
|
||||
___cxa_guard_release
|
||||
___cxa_rethrow
|
||||
___cxa_pure_virtual
|
||||
___cxa_deleted_virtual
|
||||
___cxa_begin_catch
|
||||
___cxa_throw
|
||||
___cxa_vec_cctor
|
||||
|
@ -12,6 +12,7 @@ ___cxa_guard_acquire
|
||||
___cxa_guard_release
|
||||
___cxa_rethrow
|
||||
___cxa_pure_virtual
|
||||
___cxa_deleted_virtual
|
||||
___cxa_begin_catch
|
||||
___cxa_throw
|
||||
___cxa_vec_cctor
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "support/runtime/exception_glibcxx.ipp"
|
||||
#include "support/runtime/exception_pointer_glibcxx.ipp"
|
||||
#else
|
||||
#include "include/atomic_support.h"
|
||||
#include "support/runtime/exception_fallback.ipp"
|
||||
#include "support/runtime/exception_pointer_unimplemented.ipp"
|
||||
#endif
|
||||
|
@ -296,24 +296,43 @@ void recursive_directory_iterator::__advance(error_code* ec) {
|
||||
}
|
||||
|
||||
bool recursive_directory_iterator::__try_recursion(error_code *ec) {
|
||||
|
||||
bool rec_sym =
|
||||
bool(options() & directory_options::follow_directory_symlink);
|
||||
|
||||
auto& curr_it = __imp_->__stack_.top();
|
||||
|
||||
if (is_directory(curr_it.__entry_.status()) &&
|
||||
(!is_symlink(curr_it.__entry_.symlink_status()) || rec_sym))
|
||||
{
|
||||
std::error_code m_ec;
|
||||
bool skip_rec = false;
|
||||
std::error_code m_ec;
|
||||
if (!rec_sym) {
|
||||
file_status st = curr_it.__entry_.symlink_status(m_ec);
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || is_symlink(st) || !is_directory(st))
|
||||
skip_rec = true;
|
||||
} else {
|
||||
file_status st = curr_it.__entry_.status(m_ec);
|
||||
if (m_ec && status_known(st))
|
||||
m_ec.clear();
|
||||
if (m_ec || !is_directory(st))
|
||||
skip_rec = true;
|
||||
}
|
||||
|
||||
if (!skip_rec) {
|
||||
__dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec);
|
||||
if (new_it.good()) {
|
||||
__imp_->__stack_.push(_VSTD::move(new_it));
|
||||
return true;
|
||||
}
|
||||
if (m_ec) {
|
||||
__imp_.reset();
|
||||
set_or_throw(m_ec, ec,
|
||||
"recursive_directory_iterator::operator++()");
|
||||
}
|
||||
if (m_ec) {
|
||||
const bool allow_eacess = bool(__imp_->__options_
|
||||
& directory_options::skip_permission_denied);
|
||||
if (m_ec.value() == EACCES && allow_eacess) {
|
||||
if (ec) ec->clear();
|
||||
} else {
|
||||
__imp_.reset();
|
||||
set_or_throw(m_ec, ec,
|
||||
"recursive_directory_iterator::operator++()");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -182,20 +182,20 @@ void __copy(const path& from, const path& to, copy_options options,
|
||||
const bool sym_status2 = bool(options &
|
||||
copy_options::copy_symlinks);
|
||||
|
||||
std::error_code m_ec;
|
||||
std::error_code m_ec1;
|
||||
struct ::stat f_st = {};
|
||||
const file_status f = sym_status || sym_status2
|
||||
? detail::posix_lstat(from, f_st, &m_ec)
|
||||
: detail::posix_stat(from, f_st, &m_ec);
|
||||
if (m_ec)
|
||||
return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
? detail::posix_lstat(from, f_st, &m_ec1)
|
||||
: detail::posix_stat(from, f_st, &m_ec1);
|
||||
if (m_ec1)
|
||||
return set_or_throw(m_ec1, ec, "copy", from, to);
|
||||
|
||||
struct ::stat t_st = {};
|
||||
const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec)
|
||||
: detail::posix_stat(to, t_st, &m_ec);
|
||||
const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1)
|
||||
: detail::posix_stat(to, t_st, &m_ec1);
|
||||
|
||||
if (not status_known(t))
|
||||
return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
return set_or_throw(m_ec1, ec, "copy", from, to);
|
||||
|
||||
if (!exists(f) || is_other(f) || is_other(t)
|
||||
|| (is_directory(f) && is_regular_file(t))
|
||||
@ -249,9 +249,9 @@ void __copy(const path& from, const path& to, copy_options options,
|
||||
directory_iterator it = ec ? directory_iterator(from, *ec)
|
||||
: directory_iterator(from);
|
||||
if (ec && *ec) { return; }
|
||||
std::error_code m_ec;
|
||||
for (; it != directory_iterator(); it.increment(m_ec)) {
|
||||
if (m_ec) return set_or_throw(m_ec, ec, "copy", from, to);
|
||||
std::error_code m_ec2;
|
||||
for (; it != directory_iterator(); it.increment(m_ec2)) {
|
||||
if (m_ec2) return set_or_throw(m_ec2, ec, "copy", from, to);
|
||||
__copy(it->path(), to / it->path().filename(),
|
||||
options | copy_options::__in_recursive_copy, ec);
|
||||
if (ec && *ec) { return; }
|
||||
|
@ -16,6 +16,7 @@
|
||||
#if defined(__clang__) && __has_builtin(__atomic_load_n) \
|
||||
&& __has_builtin(__atomic_store_n) \
|
||||
&& __has_builtin(__atomic_add_fetch) \
|
||||
&& __has_builtin(__atomic_exchange_n) \
|
||||
&& __has_builtin(__atomic_compare_exchange_n) \
|
||||
&& defined(__ATOMIC_RELAXED) \
|
||||
&& defined(__ATOMIC_CONSUME) \
|
||||
@ -82,6 +83,14 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
|
||||
return __atomic_add_fetch(__val, __a, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_exchange(_ValueType* __target,
|
||||
_ValueType __value, int __order = _AO_Seq)
|
||||
{
|
||||
return __atomic_exchange_n(__target, __value, __order);
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
|
||||
@ -135,6 +144,16 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
|
||||
return *__val += __a;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
_ValueType __libcpp_atomic_exchange(_ValueType* __target,
|
||||
_ValueType __value, int __order = _AO_Seq)
|
||||
{
|
||||
_ValueType old = *__target;
|
||||
*__target = __value;
|
||||
return old;
|
||||
}
|
||||
|
||||
template <class _ValueType>
|
||||
inline _LIBCPP_INLINE_VISIBILITY
|
||||
bool __libcpp_atomic_compare_exchange(_ValueType* __val,
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define _LIBCPP_ELAST __ELASTERROR
|
||||
#elif defined(__Fuchsia__)
|
||||
// No _LIBCPP_ELAST needed on Fuchsia
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
|
||||
#define _LIBCPP_ELAST 4095
|
||||
#elif defined(__APPLE__)
|
||||
// No _LIBCPP_ELAST needed on Apple
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
#include "atomic_support.h"
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
@ -83,7 +84,7 @@ __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) _NOEXCEPT
|
||||
: __imp_(s.__imp_)
|
||||
{
|
||||
if (__uses_refcount())
|
||||
__sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
|
||||
__libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
|
||||
}
|
||||
|
||||
inline
|
||||
@ -92,10 +93,10 @@ __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) _
|
||||
struct _Rep_base *old_rep = rep_from_data(__imp_);
|
||||
__imp_ = s.__imp_;
|
||||
if (__uses_refcount())
|
||||
__sync_add_and_fetch(&rep_from_data(__imp_)->count, 1);
|
||||
__libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
|
||||
if (adjust_old_count)
|
||||
{
|
||||
if (__sync_add_and_fetch(&old_rep->count, count_t(-1)) < 0)
|
||||
if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0)
|
||||
{
|
||||
::operator delete(old_rep);
|
||||
}
|
||||
@ -107,7 +108,7 @@ inline
|
||||
__libcpp_refstring::~__libcpp_refstring() {
|
||||
if (__uses_refcount()) {
|
||||
_Rep_base* rep = rep_from_data(__imp_);
|
||||
if (__sync_add_and_fetch(&rep->count, count_t(-1)) < 0) {
|
||||
if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {
|
||||
::operator delete(rep);
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,23 @@
|
||||
#include "string"
|
||||
#include "new"
|
||||
|
||||
#define _str(s) #s
|
||||
#define str(s) _str(s)
|
||||
#define _LIBCPP_NAMESPACE_STR str(_LIBCPP_NAMESPACE)
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_STDIN
|
||||
_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cin@__1@std@@3V?$basic_istream@DU?$char_traits@D@__1@std@@@12@A")
|
||||
__asm__("?cin@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin[sizeof(__stdinbuf <char>)];
|
||||
static mbstate_t mb_cin;
|
||||
_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcin@__1@std@@3V?$basic_istream@_WU?$char_traits@_W@__1@std@@@12@A")
|
||||
__asm__("?wcin@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin[sizeof(__stdinbuf <wchar_t>)];
|
||||
@ -33,14 +37,14 @@ static mbstate_t mb_wcin;
|
||||
#ifndef _LIBCPP_HAS_NO_STDOUT
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cout@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
|
||||
__asm__("?cout@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
|
||||
static mbstate_t mb_cout;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcout@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
|
||||
__asm__("?wcout@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
|
||||
@ -49,14 +53,14 @@ static mbstate_t mb_wcout;
|
||||
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?cerr@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
|
||||
__asm__("?cerr@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
|
||||
static mbstate_t mb_cerr;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wcerr@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
|
||||
__asm__("?wcerr@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
|
||||
@ -64,12 +68,12 @@ static mbstate_t mb_wcerr;
|
||||
|
||||
_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?clog@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
|
||||
__asm__("?clog@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
|
||||
__asm__("?wclog@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
|
||||
__asm__("?wclog@" _LIBCPP_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR "@std@@@12@A")
|
||||
#endif
|
||||
;
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "include/atomic_support.h"
|
||||
#include "__undef_macros"
|
||||
|
||||
// On Linux, wint_t and wchar_t have different signed-ness, and this causes
|
||||
@ -667,7 +668,7 @@ locale::id::__get()
|
||||
void
|
||||
locale::id::__init()
|
||||
{
|
||||
__id_ = __sync_add_and_fetch(&__next_id, 1);
|
||||
__id_ = __libcpp_atomic_add(&__next_id, 1);
|
||||
}
|
||||
|
||||
// template <> class collate_byname<char>
|
||||
|
10
src/new.cpp
10
src/new.cpp
@ -12,9 +12,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "new"
|
||||
#include "include/atomic_support.h"
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
// nothing todo
|
||||
#if defined(_LIBCPP_NO_VCRUNTIME)
|
||||
#include "support/runtime/new_handler_fallback.ipp"
|
||||
#endif
|
||||
#elif defined(LIBCXX_BUILDING_LIBCXXABI)
|
||||
#include <cxxabi.h>
|
||||
#elif defined(LIBCXXRT)
|
||||
@ -53,7 +56,8 @@ __throw_bad_alloc()
|
||||
|
||||
} // std
|
||||
|
||||
#if !defined(__GLIBCXX__) && !defined(_LIBCPP_ABI_MICROSOFT) && \
|
||||
#if !defined(__GLIBCXX__) && \
|
||||
(!defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)) && \
|
||||
!defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
|
||||
|
||||
// Implement all new and delete operators as weak definitions
|
||||
@ -299,4 +303,4 @@ operator delete[] (void* ptr, size_t, std::align_val_t alignment) _NOEXCEPT
|
||||
}
|
||||
|
||||
#endif // !_LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
#endif // !__GLIBCXX__ && !_LIBCPP_ABI_MICROSOFT && !_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
|
||||
#endif // !__GLIBCXX__ && (!_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME) && !_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
|
||||
|
@ -25,7 +25,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_LIBCPP_USING_DEV_RANDOM)
|
||||
#if defined(_LIBCPP_USING_GETENTROPY)
|
||||
#include <sys/random.h>
|
||||
#elif defined(_LIBCPP_USING_DEV_RANDOM)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#elif defined(_LIBCPP_USING_NACL_RANDOM)
|
||||
@ -35,7 +37,30 @@
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(_LIBCPP_USING_ARC4_RANDOM)
|
||||
#if defined(_LIBCPP_USING_GETENTROPY)
|
||||
|
||||
random_device::random_device(const string& __token)
|
||||
{
|
||||
if (__token != "/dev/urandom")
|
||||
__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
|
||||
}
|
||||
|
||||
random_device::~random_device()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned
|
||||
random_device::operator()()
|
||||
{
|
||||
unsigned r;
|
||||
size_t n = sizeof(r);
|
||||
int err = getentropy(&r, n);
|
||||
if (err)
|
||||
__throw_system_error(errno, "random_device getentropy failed");
|
||||
return r;
|
||||
}
|
||||
|
||||
#elif defined(_LIBCPP_USING_ARC4_RANDOM)
|
||||
|
||||
random_device::random_device(const string& __token)
|
||||
{
|
||||
|
@ -186,7 +186,7 @@ strstreambuf::overflow(int_type __c)
|
||||
}
|
||||
setg(buf, buf + ninp, buf + einp);
|
||||
setp(buf + einp, buf + new_size);
|
||||
pbump(static_cast<int>(nout));
|
||||
__pbump(nout);
|
||||
__strmode_ |= __allocated;
|
||||
}
|
||||
*pptr() = static_cast<char>(__c);
|
||||
@ -282,7 +282,7 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod
|
||||
// min(pbase, newpos), newpos, epptr()
|
||||
__off = epptr() - newpos;
|
||||
setp(min(pbase(), newpos), epptr());
|
||||
pbump(static_cast<int>((epptr() - pbase()) - __off));
|
||||
__pbump((epptr() - pbase()) - __off);
|
||||
}
|
||||
__p = newoff;
|
||||
}
|
||||
@ -312,7 +312,7 @@ strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
|
||||
// min(pbase, newpos), newpos, epptr()
|
||||
off_type temp = epptr() - newpos;
|
||||
setp(min(pbase(), newpos), epptr());
|
||||
pbump(static_cast<int>((epptr() - pbase()) - temp));
|
||||
__pbump((epptr() - pbase()) - temp);
|
||||
}
|
||||
__p = newoff;
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ _LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler;
|
||||
unexpected_handler
|
||||
set_unexpected(unexpected_handler func) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__unexpected_handler, func);
|
||||
return __libcpp_atomic_exchange(&__unexpected_handler, func);
|
||||
}
|
||||
|
||||
unexpected_handler
|
||||
get_unexpected() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__unexpected_handler, (unexpected_handler)0);
|
||||
return __libcpp_atomic_load(&__unexpected_handler);
|
||||
|
||||
}
|
||||
|
||||
@ -41,14 +41,13 @@ void unexpected()
|
||||
terminate_handler
|
||||
set_terminate(terminate_handler func) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__terminate_handler, func);
|
||||
return __libcpp_atomic_exchange(&__terminate_handler, func);
|
||||
}
|
||||
|
||||
terminate_handler
|
||||
get_terminate() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__terminate_handler, (terminate_handler)0);
|
||||
|
||||
return __libcpp_atomic_load(&__terminate_handler);
|
||||
}
|
||||
|
||||
#ifndef __EMSCRIPTEN__ // We provide this in JS
|
||||
|
@ -14,12 +14,35 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <eh.h>
|
||||
#include <corecrt_terminate.h>
|
||||
|
||||
#if !defined(_ACRTIMP)
|
||||
#define _ACRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(_VCRTIMP)
|
||||
#define _VCRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(__CRTDECL)
|
||||
#define __CRTDECL __cdecl
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
typedef void (__CRTDECL* terminate_handler)();
|
||||
_ACRTIMP terminate_handler __cdecl set_terminate(
|
||||
terminate_handler _NewTerminateHandler) throw();
|
||||
_ACRTIMP terminate_handler __cdecl _get_terminate();
|
||||
|
||||
typedef void (__CRTDECL* unexpected_handler)();
|
||||
_VCRTIMP unexpected_handler __cdecl set_unexpected(
|
||||
unexpected_handler _NewUnexpectedHandler) throw();
|
||||
_VCRTIMP unexpected_handler __cdecl _get_unexpected();
|
||||
|
||||
_VCRTIMP int __cdecl __uncaught_exceptions();
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
||||
// libcxxrt provides implementations of these functions itself.
|
||||
unexpected_handler
|
||||
set_unexpected(unexpected_handler func) _NOEXCEPT {
|
||||
return ::set_unexpected(func);
|
||||
@ -86,4 +109,82 @@ bad_array_length::what() const _NOEXCEPT
|
||||
return "bad_array_length";
|
||||
}
|
||||
|
||||
bad_cast::bad_cast() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
bad_cast::~bad_cast() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
bad_cast::what() const _NOEXCEPT
|
||||
{
|
||||
return "std::bad_cast";
|
||||
}
|
||||
|
||||
bad_typeid::bad_typeid() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
bad_typeid::~bad_typeid() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
bad_typeid::what() const _NOEXCEPT
|
||||
{
|
||||
return "std::bad_typeid";
|
||||
}
|
||||
|
||||
#if defined(_LIBCPP_NO_VCRUNTIME)
|
||||
exception::~exception() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char* exception::what() const _NOEXCEPT
|
||||
{
|
||||
return "std::exception";
|
||||
}
|
||||
|
||||
|
||||
bad_exception::~bad_exception() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char* bad_exception::what() const _NOEXCEPT
|
||||
{
|
||||
return "std::bad_exception";
|
||||
}
|
||||
|
||||
|
||||
bad_alloc::bad_alloc() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
bad_alloc::~bad_alloc() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char*
|
||||
bad_alloc::what() const _NOEXCEPT
|
||||
{
|
||||
return "std::bad_alloc";
|
||||
}
|
||||
|
||||
bad_array_new_length::bad_array_new_length() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
bad_array_new_length::~bad_array_new_length() _NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
const char*
|
||||
bad_array_new_length::what() const _NOEXCEPT
|
||||
{
|
||||
return "bad_array_new_length";
|
||||
}
|
||||
#endif // _LIBCPP_NO_VCRUNTIME
|
||||
|
||||
} // namespace std
|
||||
|
@ -10,26 +10,32 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <yvals.h> // for _CRTIMP2_PURE
|
||||
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(_Out_ void*,
|
||||
_In_ const void*);
|
||||
#if !defined(_CRTIMP2_PURE)
|
||||
#define _CRTIMP2_PURE __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(__CLRCALL_PURE_OR_CDECL)
|
||||
#define __CLRCALL_PURE_OR_CDECL __cdecl
|
||||
#endif
|
||||
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(void*,
|
||||
const void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrAssign(_Inout_ void*, _In_ const void*);
|
||||
__ExceptionPtrAssign(void*, const void*);
|
||||
_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrCompare(_In_ const void*, _In_ const void*);
|
||||
__ExceptionPtrCompare(const void*, const void*);
|
||||
_CRTIMP2_PURE bool __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrToBool(_In_ const void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrSwap(_Inout_ void*,
|
||||
_Inout_ void*);
|
||||
__ExceptionPtrToBool(const void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrSwap(void*, void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrCurrentException(_Out_ void*);
|
||||
__ExceptionPtrCurrentException(void*);
|
||||
[[noreturn]] _CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrRethrow(_In_ const void*);
|
||||
__ExceptionPtrRethrow(const void*);
|
||||
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL
|
||||
__ExceptionPtrCopyException(_Inout_ void*, _In_ const void*, _In_ const void*);
|
||||
__ExceptionPtrCopyException(void*, const void*, const void*);
|
||||
|
||||
namespace std {
|
||||
|
||||
|
@ -15,13 +15,13 @@ _LIBCPP_SAFE_STATIC static std::new_handler __new_handler;
|
||||
new_handler
|
||||
set_new_handler(new_handler handler) _NOEXCEPT
|
||||
{
|
||||
return __sync_lock_test_and_set(&__new_handler, handler);
|
||||
return __libcpp_atomic_exchange(&__new_handler, handler);
|
||||
}
|
||||
|
||||
new_handler
|
||||
get_new_handler() _NOEXCEPT
|
||||
{
|
||||
return __sync_fetch_and_add(&__new_handler, nullptr);
|
||||
return __libcpp_atomic_load(&__new_handler);
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
@ -18,21 +18,7 @@ using std::__libcpp_locale_guard;
|
||||
// FIXME: base currently unused. Needs manual work to construct the new locale
|
||||
locale_t newlocale( int mask, const char * locale, locale_t /*base*/ )
|
||||
{
|
||||
return _create_locale( mask, locale );
|
||||
}
|
||||
|
||||
locale_t uselocale( locale_t newloc )
|
||||
{
|
||||
locale_t old_locale = _get_current_locale();
|
||||
if ( newloc == NULL )
|
||||
return old_locale;
|
||||
// uselocale sets the thread's locale by definition, so unconditionally use thread-local locale
|
||||
_configthreadlocale( _ENABLE_PER_THREAD_LOCALE );
|
||||
// uselocale sets all categories
|
||||
// disable setting locale on Windows temporarily because the structure is opaque (PR31516)
|
||||
//setlocale( LC_ALL, newloc->locinfo->lc_category[LC_ALL].locale );
|
||||
// uselocale returns the old locale_t
|
||||
return old_locale;
|
||||
return {_create_locale( LC_ALL, locale ), locale};
|
||||
}
|
||||
|
||||
decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
|
||||
|
@ -73,39 +73,59 @@ string do_strerror_r(int ev) {
|
||||
std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
|
||||
return string(buffer);
|
||||
}
|
||||
#elif defined(__linux__) && !defined(_LIBCPP_HAS_MUSL_LIBC) && \
|
||||
(!defined(__ANDROID__) || __ANDROID_API__ >= 23)
|
||||
// GNU Extended version
|
||||
string do_strerror_r(int ev) {
|
||||
char buffer[strerror_buff_size];
|
||||
char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
|
||||
return string(ret);
|
||||
}
|
||||
#else
|
||||
// POSIX version
|
||||
|
||||
// Only one of the two following functions will be used, depending on
|
||||
// the return type of strerror_r:
|
||||
|
||||
// For the GNU variant, a char* return value:
|
||||
__attribute__((unused)) const char *
|
||||
handle_strerror_r_return(char *strerror_return, char *buffer) {
|
||||
// GNU always returns a string pointer in its return value. The
|
||||
// string might point to either the input buffer, or a static
|
||||
// buffer, but we don't care which.
|
||||
return strerror_return;
|
||||
}
|
||||
|
||||
// For the POSIX variant: an int return value.
|
||||
__attribute__((unused)) const char *
|
||||
handle_strerror_r_return(int strerror_return, char *buffer) {
|
||||
// The POSIX variant either:
|
||||
// - fills in the provided buffer and returns 0
|
||||
// - returns a positive error value, or
|
||||
// - returns -1 and fills in errno with an error value.
|
||||
if (strerror_return == 0)
|
||||
return buffer;
|
||||
|
||||
// Only handle EINVAL. Other errors abort.
|
||||
int new_errno = strerror_return == -1 ? errno : strerror_return;
|
||||
if (new_errno == EINVAL)
|
||||
return "";
|
||||
|
||||
_LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerror_r");
|
||||
// FIXME maybe? 'strerror_buff_size' is likely to exceed the
|
||||
// maximum error size so ERANGE shouldn't be returned.
|
||||
std::abort();
|
||||
}
|
||||
|
||||
// This function handles both GNU and POSIX variants, dispatching to
|
||||
// one of the two above functions.
|
||||
string do_strerror_r(int ev) {
|
||||
char buffer[strerror_buff_size];
|
||||
// Preserve errno around the call. (The C++ standard requires that
|
||||
// system_error functions not modify errno).
|
||||
const int old_errno = errno;
|
||||
int ret;
|
||||
if ((ret = ::strerror_r(ev, buffer, strerror_buff_size)) != 0) {
|
||||
// If `ret == -1` then the error is specified using `errno`, otherwise
|
||||
// `ret` represents the error.
|
||||
const int new_errno = ret == -1 ? errno : ret;
|
||||
errno = old_errno;
|
||||
if (new_errno == EINVAL) {
|
||||
std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
|
||||
return string(buffer);
|
||||
} else {
|
||||
_LIBCPP_ASSERT(new_errno == ERANGE, "unexpected error from ::strerr_r");
|
||||
// FIXME maybe? 'strerror_buff_size' is likely to exceed the
|
||||
// maximum error size so ERANGE shouldn't be returned.
|
||||
std::abort();
|
||||
}
|
||||
const char *error_message = handle_strerror_r_return(
|
||||
::strerror_r(ev, buffer, strerror_buff_size), buffer);
|
||||
// If we didn't get any message, print one now.
|
||||
if (!error_message[0]) {
|
||||
std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
|
||||
error_message = buffer;
|
||||
}
|
||||
return string(buffer);
|
||||
errno = old_errno;
|
||||
return string(error_message);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // end namespace
|
||||
#endif
|
||||
|
||||
|
@ -9,11 +9,48 @@
|
||||
|
||||
#include "typeinfo"
|
||||
|
||||
#if defined(_LIBCPP_ABI_MICROSOFT)
|
||||
#include <string.h>
|
||||
|
||||
int std::type_info::__compare(const type_info &__rhs) const _NOEXCEPT {
|
||||
if (&__data == &__rhs.__data)
|
||||
return 0;
|
||||
return strcmp(&__data.__decorated_name[1], &__rhs.__data.__decorated_name[1]);
|
||||
}
|
||||
|
||||
const char *std::type_info::name() const _NOEXCEPT {
|
||||
// TODO(compnerd) cache demangled &__data.__decorated_name[1]
|
||||
return &__data.__decorated_name[1];
|
||||
}
|
||||
|
||||
size_t std::type_info::hash_code() const _NOEXCEPT {
|
||||
#if defined(_WIN64)
|
||||
constexpr size_t fnv_offset_basis = 14695981039346656037ull;
|
||||
constexpr size_t fnv_prime = 10995116282110ull;
|
||||
#else
|
||||
constexpr size_t fnv_offset_basis = 2166136261ull;
|
||||
constexpr size_t fnv_prime = 16777619ull;
|
||||
#endif
|
||||
|
||||
size_t value = fnv_offset_basis;
|
||||
for (const char* c = &__data.__decorated_name[1]; *c; ++c) {
|
||||
value ^= static_cast<size_t>(static_cast<unsigned char>(*c));
|
||||
value *= fnv_prime;
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
value ^= value >> 32;
|
||||
#endif
|
||||
|
||||
return value;
|
||||
}
|
||||
#endif // _LIBCPP_ABI_MICROSOFT
|
||||
|
||||
// FIXME: Remove __APPLE__ default here once buildit is gone.
|
||||
#if (!defined(_LIBCPP_ABI_MICROSOFT) && !defined(LIBCXX_BUILDING_LIBCXXABI) && \
|
||||
!defined(LIBCXXRT) && !defined(__GLIBCXX__) && \
|
||||
!defined(__APPLE__)) || \
|
||||
defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) // FIXME: remove this configuration.
|
||||
// FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration.
|
||||
#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && !defined(LIBCXXRT) && \
|
||||
!defined(__GLIBCXX__) && !defined(__APPLE__)) || \
|
||||
defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
|
||||
std::type_info::~type_info()
|
||||
{
|
||||
}
|
||||
|
@ -49,11 +49,6 @@ set(LIBCXX_EXECUTOR "None" CACHE STRING
|
||||
|
||||
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
||||
@ONLY)
|
||||
|
||||
set(LIBCXX_TEST_DEPS "")
|
||||
|
||||
if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
||||
@ -65,7 +60,12 @@ if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
|
||||
endif()
|
||||
|
||||
if (LIBCXX_INCLUDE_TESTS)
|
||||
include(AddLLVM) # for add_lit_testsuite
|
||||
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
|
||||
|
||||
configure_lit_site_cfg(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
|
||||
|
||||
add_lit_testsuite(check-cxx
|
||||
"Running libcxx tests"
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
|
@ -164,4 +164,4 @@ void test_failing() {
|
||||
int main() {
|
||||
test_passing();
|
||||
test_failing();
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,4 @@ int main()
|
||||
std::list<int> v2(3);
|
||||
v1.insert(v2.begin(), 4);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
@ -54,12 +54,12 @@ test_next_pow2()
|
||||
assert(std::__next_hash_pow2(pow2) == pow2);
|
||||
}
|
||||
|
||||
test_next_pow2_val(3);
|
||||
test_next_pow2_val(7);
|
||||
test_next_pow2_val(9);
|
||||
test_next_pow2_val(15);
|
||||
test_next_pow2_val(127);
|
||||
test_next_pow2_val(129);
|
||||
test_next_pow2_val(3);
|
||||
test_next_pow2_val(7);
|
||||
test_next_pow2_val(9);
|
||||
test_next_pow2_val(15);
|
||||
test_next_pow2_val(127);
|
||||
test_next_pow2_val(129);
|
||||
}
|
||||
|
||||
// Note: this is only really useful when run with -fsanitize=undefined.
|
||||
|
@ -18,4 +18,5 @@
|
||||
int main()
|
||||
{
|
||||
std::complex<double> d;
|
||||
(void)d;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
int main()
|
||||
{
|
||||
std::complex<double> cd;
|
||||
(void)cd;
|
||||
double x = sin(1.0);
|
||||
(void)x; // to placate scan-build
|
||||
}
|
||||
|
@ -24,25 +24,25 @@ int identity(int v) { return v; }
|
||||
int sum(int a, int b) { return a + b; }
|
||||
|
||||
struct Foo {
|
||||
int zero() const { return 0; }
|
||||
int identity(int v) const { return v; }
|
||||
int sum(int a, int b) const { return a + b; }
|
||||
int zero() const { return 0; }
|
||||
int identity(int v) const { return v; }
|
||||
int sum(int a, int b) const { return a + b; }
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::pointer_to_unary_function<int, int> PUF;
|
||||
typedef std::pointer_to_binary_function<int, int, int> PBF;
|
||||
assert((std::ptr_fun<int, int>(identity)(4) == 4));
|
||||
assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
|
||||
typedef std::pointer_to_unary_function<int, int> PUF;
|
||||
typedef std::pointer_to_binary_function<int, int, int> PBF;
|
||||
assert((std::ptr_fun<int, int>(identity)(4) == 4));
|
||||
assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
|
||||
|
||||
Foo f;
|
||||
assert((std::mem_fn(&Foo::identity)(f, 5) == 5));
|
||||
assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11));
|
||||
Foo f;
|
||||
assert((std::mem_fn(&Foo::identity)(f, 5) == 5));
|
||||
assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11));
|
||||
|
||||
typedef std::mem_fun_ref_t<int, Foo> MFR;
|
||||
typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
|
||||
|
||||
assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
|
||||
assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
|
||||
assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
|
||||
assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
|
||||
}
|
||||
|
24
test/libcxx/diagnostics/nodiscard.fail.cpp
Normal file
24
test/libcxx/diagnostics/nodiscard.fail.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
|
||||
// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <__config>
|
||||
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
|
||||
|
||||
int main ()
|
||||
{
|
||||
foo(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
@ -7,19 +8,18 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
|
||||
// #define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||
// <optional>
|
||||
|
||||
// struct nullopt_t{see below};
|
||||
// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
|
||||
#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
|
||||
#include <__config>
|
||||
|
||||
#include <optional>
|
||||
_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }
|
||||
|
||||
using std::optional;
|
||||
using std::nullopt_t;
|
||||
|
||||
int main()
|
||||
int main ()
|
||||
{
|
||||
// I roughly interpret LWG2736 as "it shall not be possible to copy-list-initialize nullopt_t with an
|
||||
// empty braced-init-list."
|
||||
nullopt_t foo = {};
|
||||
foo(); // no error here!
|
||||
}
|
@ -71,4 +71,4 @@ int main() {
|
||||
assert(false);
|
||||
} catch (int) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ int main() {
|
||||
using namespace fs;
|
||||
using RIt = std::reverse_iterator<path::iterator>;
|
||||
|
||||
// expected-error@iterator:* {{static_assert failed "The specified iterator type cannot be used with reverse_iterator; Using stashing iterators with reverse_iterator causes undefined behavior"}}
|
||||
// expected-error-re@iterator:* {{static_assert failed{{.*}} "The specified iterator type cannot be used with reverse_iterator; Using stashing iterators with reverse_iterator causes undefined behavior"}}
|
||||
{
|
||||
RIt r;
|
||||
((void)r);
|
||||
|
38
test/libcxx/fuzzing/nth_element.cpp
Normal file
38
test/libcxx/fuzzing/nth_element.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------- nth_element.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.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// XFAIL
|
||||
|
||||
#include "fuzzing.h"
|
||||
#include <cassert>
|
||||
#include <cstring> // for strlen
|
||||
|
||||
const char * test_cases[] = {
|
||||
"",
|
||||
"s",
|
||||
"bac",
|
||||
"bacasf"
|
||||
"lkajseravea",
|
||||
"adsfkajdsfjkas;lnc441324513,34535r34525234"
|
||||
};
|
||||
|
||||
const size_t k_num_tests = sizeof(test_cases)/sizeof(test_cases[0]);
|
||||
|
||||
|
||||
int main ()
|
||||
{
|
||||
for (size_t i = 0; i < k_num_tests; ++i)
|
||||
{
|
||||
const size_t size = std::strlen(test_cases[i]);
|
||||
const uint8_t *data = (const uint8_t *) test_cases[i];
|
||||
assert(0 == fuzzing::nth_element(data, size));
|
||||
}
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user