Merge to upstream r350972.

Test: ./run_tests.py --bitness 32
Test: ./run_tests.py --bitness 64
Test: ./run_tests.py --bitness 64 --host
Bug: None
Change-Id: I96552544c8305853be519855982caf716930519e
This commit is contained in:
Dan Albert
2019-01-11 14:07:42 -08:00
404 changed files with 8700 additions and 1735 deletions

View File

@@ -283,6 +283,9 @@ endif()
option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE"
${LIBCXX_CONFIGURE_IDE_DEFAULT})
option(LIBCXX_HERMETIC_STATIC_LIBRARY
"Do not export any symbols from the static library." OFF)
#===============================================================================
# Check option configurations
#===============================================================================

View File

@@ -0,0 +1,124 @@
#include <array>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <tuple>
#include <vector>
#include "benchmark/benchmark.h"
#include "CartesianBenchmarks.hpp"
#include "GenerateInput.hpp"
namespace {
template <typename I, typename N>
std::array<I, 10> every_10th_percentile_N(I first, N n) {
N step = n / 10;
std::array<I, 10> res;
for (size_t i = 0; i < 10; ++i) {
res[i] = first;
std::advance(first, step);
}
return res;
}
template <class IntT>
struct TestIntBase {
static std::vector<IntT> generateInput(size_t size) {
std::vector<IntT> Res(size);
std::generate(Res.begin(), Res.end(),
[] { return getRandomInteger<IntT>(); });
return Res;
}
};
struct TestInt32 : TestIntBase<std::int32_t> {
static constexpr const char* Name = "TestInt32";
};
struct TestInt64 : TestIntBase<std::int64_t> {
static constexpr const char* Name = "TestInt64";
};
struct TestUint32 : TestIntBase<std::uint32_t> {
static constexpr const char* Name = "TestUint32";
};
struct TestMediumString {
static constexpr const char* Name = "TestMediumString";
static constexpr size_t StringSize = 32;
static std::vector<std::string> generateInput(size_t size) {
std::vector<std::string> Res(size);
std::generate(Res.begin(), Res.end(), [] { return getRandomString(StringSize); });
return Res;
}
};
using AllTestTypes = std::tuple<TestInt32, TestInt64, TestUint32, TestMediumString>;
struct LowerBoundAlg {
template <class I, class V>
I operator()(I first, I last, const V& value) const {
return std::lower_bound(first, last, value);
}
static constexpr const char* Name = "LowerBoundAlg";
};
struct UpperBoundAlg {
template <class I, class V>
I operator()(I first, I last, const V& value) const {
return std::upper_bound(first, last, value);
}
static constexpr const char* Name = "UpperBoundAlg";
};
struct EqualRangeAlg {
template <class I, class V>
std::pair<I, I> operator()(I first, I last, const V& value) const {
return std::equal_range(first, last, value);
}
static constexpr const char* Name = "EqualRangeAlg";
};
using AllAlgs = std::tuple<LowerBoundAlg, UpperBoundAlg, EqualRangeAlg>;
template <class Alg, class TestType>
struct PartitionPointBench {
size_t Quantity;
std::string name() const {
return std::string("PartitionPointBench_") + Alg::Name + "_" +
TestType::Name + '/' + std::to_string(Quantity);
}
void run(benchmark::State& state) const {
auto Data = TestType::generateInput(Quantity);
std::sort(Data.begin(), Data.end());
auto Every10Percentile = every_10th_percentile_N(Data.begin(), Data.size());
for (auto _ : state) {
for (auto Test : Every10Percentile)
benchmark::DoNotOptimize(Alg{}(Data.begin(), Data.end(), *Test));
}
}
};
} // namespace
int main(int argc, char** argv) {
benchmark::Initialize(&argc, argv);
if (benchmark::ReportUnrecognizedArguments(argc, argv))
return 1;
const std::vector<size_t> Quantities = {1 << 8, 1 << 10, 1 << 20};
makeCartesianProductBenchmark<PartitionPointBench, AllAlgs, AllTestTypes>(
Quantities);
benchmark::RunSpecifiedBenchmarks();
}

View File

@@ -222,6 +222,15 @@ libc++ specific options
Define libc++ destination prefix.
.. option:: LIBCXX_HERMETIC_STATIC_LIBRARY:BOOL
**Default**: ``OFF``
Do not export any symbols from the static libc++ library. This is useful when
This is useful when the static libc++ library is being linked into shared
libraries that may be used in with other shared libraries that use different
C++ library. We want to avoid avoid exporting any libc++ symbols in that case.
.. _libc++experimental options:
libc++experimental Specific Options

View File

@@ -55,7 +55,7 @@ or on a particular symbol:
Testing
=======
Some parameters can be passed to lit to run the test-suite and exercising the
Some parameters can be passed to lit to run the test-suite and exercise the
availability.
* The `platform` parameter controls the deployment target. For example lit can
@@ -69,8 +69,7 @@ availability.
Tests can be marked as XFAIL based on multiple features made available by lit:
* if `use_system_cxx_lib` is passed to lit, assuming `--param=platform=macosx10.8`
is passed as well the following features will be available:
* if `--param=platform=macosx10.8` is passed, the following features will be available:
- availability
- availability=x86_64
@@ -82,8 +81,8 @@ Tests can be marked as XFAIL based on multiple features made available by lit:
This feature is used to XFAIL a test that *is* using a class or a method marked
as unavailable *and* that is expected to *fail* if deployed on an older system.
* if `use_system_cxx_lib` is passed to lit, the following features will also
be available:
* if `use_system_cxx_lib` and `--param=platform=macosx10.8` are passed to lit,
the following features will also be available:
- with_system_cxx_lib
- with_system_cxx_lib=x86_64
@@ -94,19 +93,7 @@ Tests can be marked as XFAIL based on multiple features made available by lit:
This feature is used to XFAIL a test that is *not* using a class or a method
marked as unavailable *but* that is expected to fail if deployed on an older
system. For example if we know that it exhibits a bug in the libc on a
particular system version.
* if `with_availability` is passed to lit, the following features will also
be available:
- availability_markup
- availability_markup=x86_64
- availability_markup=macosx
- availability_markup=x86_64-macosx
- availability_markup=x86_64-apple-macosx10.8
- availability_markup=macosx10.8
This feature is used to XFAIL a test that *is* using a class or a method
marked as unavailable *but* that is expected to *pass* if deployed on an older
system. For example if it is using a symbol in a statically evaluated context.
system. For example, if the test exhibits a bug in the libc on a particular
system version, or if the test uses a symbol that is not available on an
older version of the dylib (but for which there is no availability markup,
otherwise the XFAIL should use `availability` above).

View File

@@ -138,8 +138,7 @@ configuration. Passing the option on the command line will override the default.
Specify the directory of the libc++ library to use at runtime. This directory
is not added to the linkers search path. This can be used to compile tests
against one version of libc++ and run them using another. The default value
for this option is `cxx_library_root`. This option cannot be used
when use_system_cxx_lib is provided.
for this option is `cxx_library_root`.
.. option:: use_system_cxx_lib=<bool>
@@ -155,14 +154,6 @@ configuration. Passing the option on the command line will override the default.
the default value. Otherwise the default value is True on Windows and False
on every other platform.
.. option:: no_default_flags=<bool>
**Default**: False
Disable all default compile and link flags from being added. When this
option is used only flags specified using the compile_flags and link_flags
will be used.
.. option:: compile_flags="<list-of-args>"
Specify additional compile flags as a space delimited string.

View File

@@ -203,8 +203,10 @@ thread safety annotations.
This macro disables the additional diagnostics generated by libc++ using the
`diagnose_if` attribute. These additional diagnostics include checks for:
* Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
const callable.
* Giving `set`, `map`, `multiset`, `multimap` and their `unordered_`
counterparts a comparator which is not const callable.
* Giving an unordered associative container a hasher that is not const
callable.
**_LIBCPP_NO_VCRUNTIME**:
Microsoft's C and C++ headers are fairly entangled, and some of their C++

View File

@@ -95,6 +95,8 @@
// 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
// Unstable attempt to provide a more optimized std::function
# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
#elif _LIBCPP_ABI_VERSION == 1
# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
// Enable compiling copies of now inline methods into the dylib to support
@@ -713,7 +715,11 @@ typedef __char32_t char32_t;
#endif
#ifndef _LIBCPP_EXPORTED_FROM_ABI
# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default")))
# else
# define _LIBCPP_EXPORTED_FROM_ABI
# endif
#endif
#ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
@@ -971,14 +977,14 @@ template <unsigned> struct __static_assert_check {};
// If we are getting operator new from the MSVC CRT, then allocation overloads
// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
#define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
#elif defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
#define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
#if !defined(__cpp_aligned_new)
// We're defering to Microsoft's STL to provide aligned new et al. We don't
// have it unless the language feature test macro is defined.
#define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
#endif
# define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
# if !defined(__cpp_aligned_new)
// We're defering to Microsoft's STL to provide aligned new et al. We don't
// have it unless the language feature test macro is defined.
# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
# endif
#endif
#if defined(__APPLE__)
@@ -1002,6 +1008,10 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_WCTYPE_IS_MASK
#endif
#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
#define _LIBCPP_NO_HAS_CHAR8_T
#endif
// Deprecation macros.
// Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined.
#if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS)
@@ -1359,16 +1369,19 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
#endif
// Availability of stream API in the dylib got dropped and re-added. The
// extern template should effectively be available at:
// availability(macosx,introduced=10.9)
// availability(ios,introduced=7.0)
#if defined(_LIBCPP_USE_AVAILABILITY_APPLE) && \
// The stream API was dropped and re-added in the dylib shipped on macOS
// and iOS. We can only assume the dylib to provide these definitions for
// macosx >= 10.9 and ios >= 7.0. Otherwise, the definitions are available
// from the headers, but not from the dylib. Explicit instantiation
// declarations for streams exist conditionally to this; if we provide
// an explicit instantiation declaration and we try to deploy to a dylib
// that does not provide those symbols, we'll get a load-time error.
#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1090) || \
(defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 70000))
#define _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
# define _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
#endif
#if defined(_LIBCPP_COMPILER_IBM)

View File

@@ -35,15 +35,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Tp>
struct __hash_value_type;
template <class _Key, class _Cp, class _Hash,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
class __unordered_map_hasher;
template <class _Key, class _Cp, class _Pred,
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
>
class __unordered_map_equal;
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp>
struct __is_hash_value_type_imp : false_type {};
@@ -418,7 +409,7 @@ public:
_LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this));
}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_INLINE_VISIBILITY
__hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT
: __node_(__x.__node_)
{
@@ -871,35 +862,32 @@ struct __generic_container_node_destructor<__hash_node<_Tp, _VoidPtr>, _Alloc>
};
#endif
template <class _Key, class _Hash, class _Equal>
struct __enforce_unordered_container_requirements {
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Hash, class _Equal, class _Alloc>
struct __diagnose_hash_table_helper {
static constexpr bool __trigger_diagnostics()
_LIBCPP_DIAGNOSE_WARNING(__check_hash_requirements<_Key, _Hash>::value
&& !__invokable<_Hash const&, _Key const&>::value,
"the specified hash functor does not provide a const call operator")
_LIBCPP_DIAGNOSE_WARNING(is_copy_constructible<_Equal>::value
&& !__invokable<_Equal const&, _Key const&, _Key const&>::value,
"the specified comparator type does not provide a const call operator")
{
static_assert(__check_hash_requirements<_Key, _Hash>::value,
"the specified hash does not meet the Hash requirements");
"the specified hash does not meet the Hash requirements");
static_assert(is_copy_constructible<_Equal>::value,
"the specified comparator is required to be copy constructible");
return true;
}
"the specified comparator is required to be copy constructible");
#endif
typedef int type;
};
template <class _Key, class _Value, class _Hash, class _Equal, class _Alloc>
struct __diagnose_hash_table_helper<
__hash_value_type<_Key, _Value>,
__unordered_map_hasher<_Key, __hash_value_type<_Key, _Value>, _Hash>,
__unordered_map_equal<_Key, __hash_value_type<_Key, _Value>, _Equal>,
_Alloc>
: __diagnose_hash_table_helper<_Key, _Hash, _Equal, _Alloc>
{
};
#endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Hash, class _Equal>
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
"the specified comparator type does not provide a const call operator")
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
"the specified hash functor does not provide a const call operator")
#endif
typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
__diagnose_unordered_container_requirements(int);
// This dummy overload is used so that the compiler won't emit a spurious
// "no matching function for call to __diagnose_unordered_xxx" diagnostic
// when the overload above causes a hard error.
template <class _Key, class _Hash, class _Equal>
int __diagnose_unordered_container_requirements(void*);
template <class _Tp, class _Hash, class _Equal, class _Alloc>
class __hash_table
@@ -963,10 +951,6 @@ private:
typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits;
typedef typename __bucket_list_deleter::pointer __node_pointer_pointer;
#ifndef _LIBCPP_CXX03_LANG
static_assert(__diagnose_hash_table_helper<_Tp, _Hash, _Equal, _Alloc>::__trigger_diagnostics(), "");
#endif
// --- Member data begin ---
__bucket_list __bucket_list_;
__compressed_pair<__first_node, __node_allocator> __p1_;

View File

@@ -47,6 +47,7 @@ struct char_traits
template <> struct char_traits<char>;
template <> struct char_traits<wchar_t>;
template <> struct char_traits<char8_t>; // c++20
} // std
@@ -389,6 +390,102 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __
}
#ifndef _LIBCPP_NO_HAS_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
{
typedef char8_t char_type;
typedef unsigned int int_type;
typedef streamoff off_type;
typedef u8streampos pos_type;
typedef mbstate_t state_type;
static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept
{__c1 = __c2;}
static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept
{return __c1 == __c2;}
static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept
{return __c1 < __c2;}
static constexpr
int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
static constexpr
size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY static constexpr
const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
}
static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
static inline constexpr int_type not_eof(int_type __c) noexcept
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
static inline constexpr char_type to_char_type(int_type __c) noexcept
{return char_type(__c);}
static inline constexpr int_type to_int_type(char_type __c) noexcept
{return int_type(__c);}
static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept
{return __c1 == __c2;}
static inline constexpr int_type eof() noexcept
{return int_type(EOF);}
};
// TODO use '__builtin_strlen' if it ever supports char8_t ??
inline constexpr
size_t
char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
++__len;
return __len;
}
inline constexpr
int
char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
#if __has_feature(cxx_constexpr_string_builtins)
return __builtin_memcmp(__s1, __s2, __n);
#else
for (; __n; --__n, ++__s1, ++__s2)
{
if (lt(*__s1, *__s2))
return -1;
if (lt(*__s2, *__s1))
return 1;
}
return 0;
#endif
}
// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
inline constexpr
const char8_t*
char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
for (; __n; --__n)
{
if (eq(*__s, __a))
return __s;
++__s;
}
return 0;
}
#endif // #_LIBCPP_NO_HAS_CHAR8_T
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <>

View File

@@ -40,10 +40,6 @@ template <class _Tp, class _VoidPtr> class __tree_node;
template <class _Key, class _Value>
struct __value_type;
template <class _Key, class _CP, class _Compare,
bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
class __map_value_compare;
template <class _Allocator> class __map_node_destructor;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_iterator;
template <class _TreeIterator> class _LIBCPP_TEMPLATE_VIS __map_const_iterator;
@@ -966,24 +962,12 @@ private:
};
template<class _Tp, class _Compare>
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Compare, class _Allocator>
struct __diagnose_tree_helper {
static constexpr bool __trigger_diagnostics()
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
"the specified comparator type does not provide a const call operator")
{ return true; }
};
template <class _Key, class _Value, class _KeyComp, class _Alloc>
struct __diagnose_tree_helper<
__value_type<_Key, _Value>,
__map_value_compare<_Key, __value_type<_Key, _Value>, _KeyComp>,
_Alloc
> : __diagnose_tree_helper<_Key, _KeyComp, _Alloc>
{
};
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
"the specified comparator type does not provide a const call operator")
#endif
int __diagnose_non_const_comparator();
template <class _Tp, class _Compare, class _Allocator>
class __tree
@@ -1855,10 +1839,6 @@ __tree<_Tp, _Compare, _Allocator>::~__tree()
{
static_assert((is_copy_constructible<value_compare>::value),
"Comparator must be copy-constructible.");
#ifndef _LIBCPP_CXX03_LANG
static_assert((__diagnose_tree_helper<_Tp, _Compare, _Allocator>::
__trigger_diagnostics()), "");
#endif
destroy(__root());
}

View File

@@ -22,36 +22,36 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size;
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size;
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Tp, class...>
using __enable_if_tuple_size_imp = _Tp;
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
const _Tp,
typename enable_if<!is_volatile<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
volatile _Tp,
typename enable_if<!is_const<_Tp>::value>::type,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
template <class _Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp<
const volatile _Tp,
integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
: public integral_constant<size_t, tuple_size<_Tp>::value> {};
#else
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
template <class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
#endif
template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
@@ -165,7 +165,7 @@ template <class ..._Tp> class _LIBCPP_TEMPLATE_VIS tuple;
template <class... _Tp> struct __tuple_like<tuple<_Tp...> > : true_type {};
template <class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
@@ -291,7 +291,7 @@ public:
template <class ..._Tp>
class _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> >
: public integral_constant<size_t, sizeof...(_Tp)>
{
};

View File

@@ -750,6 +750,32 @@ public:
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
};
// Perform division by two quickly for positive integers (llvm.org/PR39129)
template <typename _Integral>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
is_integral<_Integral>::value,
_Integral
>::type
__half_positive(_Integral __value)
{
return static_cast<_Integral>(static_cast<typename make_unsigned<_Integral>::type>(__value) / 2);
}
template <typename _Tp>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
typename enable_if
<
!is_integral<_Tp>::value,
_Tp
>::type
__half_positive(_Tp __value)
{
return __value / 2;
}
#ifdef _LIBCPP_DEBUG
template <class _Compare>
@@ -3202,7 +3228,7 @@ partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __
difference_type __len = _VSTD::distance(__first, __last);
while (__len != 0)
{
difference_type __l2 = __len / 2;
difference_type __l2 = _VSTD::__half_positive(__len);
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__pred(*__m))
@@ -4070,7 +4096,7 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __len = _VSTD::distance(__first, __last);
while (__len != 0)
{
difference_type __l2 = __len / 2;
difference_type __l2 = _VSTD::__half_positive(__len);
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(*__m, __value_))
@@ -4112,7 +4138,7 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __len = _VSTD::distance(__first, __last);
while (__len != 0)
{
difference_type __l2 = __len / 2;
difference_type __l2 = _VSTD::__half_positive(__len);
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(__value_, *__m))
@@ -4154,7 +4180,7 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
difference_type __len = _VSTD::distance(__first, __last);
while (__len != 0)
{
difference_type __l2 = __len / 2;
difference_type __l2 = _VSTD::__half_positive(__len);
_ForwardIterator __m = __first;
_VSTD::advance(__m, __l2);
if (__comp(*__m, __value_))

View File

@@ -91,7 +91,7 @@ template <class T, size_t N>
template <class T, size_t N >
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
template <class T> class tuple_size;
template <class T> struct tuple_size;
template <size_t I, class T> class tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
@@ -430,7 +430,7 @@ swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
}
template <class _Tp, size_t _Size>
class _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size>

View File

@@ -991,7 +991,7 @@ inline
size_t
bitset<_Size>::count() const _NOEXCEPT
{
return static_cast<size_t>(_VSTD::count(base::__make_iter(0), base::__make_iter(_Size), true));
return static_cast<size_t>(__count_bool_true(base::__make_iter(0), _Size));
}
template <size_t _Size>

View File

@@ -808,6 +808,11 @@ constexpr chrono::year operator ""y(unsigned lo
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
struct _FilesystemClock;
_LIBCPP_END_NAMESPACE_FILESYSTEM
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -1581,10 +1586,27 @@ typedef system_clock high_resolution_clock;
#endif
#if _LIBCPP_STD_VER > 17
// [time.clock.file], type file_clock
using file_clock = _VSTD_FS::_FilesystemClock;
template<class _Duration>
using file_time = time_point<file_clock, _Duration>;
template <class _Duration>
using sys_time = time_point<system_clock, _Duration>;
using sys_seconds = sys_time<seconds>;
using sys_days = sys_time<days>;
struct local_t {};
template<class Duration>
using local_time = time_point<local_t, Duration>;
using local_seconds = local_time<seconds>;
using local_days = local_time<days>;
struct _LIBCPP_TYPE_VIS last_spec { explicit last_spec() = default; };
class _LIBCPP_TYPE_VIS day {
private:
unsigned char __d;
@@ -1803,21 +1825,36 @@ private:
unsigned char __wd;
public:
weekday() = default;
explicit inline constexpr weekday(unsigned __val) noexcept: __wd(static_cast<unsigned char>(__val)) {}
// inline constexpr weekday(const sys_days& dp) noexcept;
// explicit constexpr weekday(const local_days& dp) noexcept;
inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val)) {}
inline constexpr weekday(const sys_days& __sysd) noexcept
: __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {}
inline explicit constexpr weekday(const local_days& __locd) noexcept
: __wd(__weekday_from_days(__locd.time_since_epoch().count())) {}
inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; }
inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; }
inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; }
inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; }
constexpr weekday& operator+=(const days& __dd) noexcept;
constexpr weekday& operator-=(const days& __dd) noexcept;
explicit inline constexpr operator unsigned() const noexcept { return __wd; }
inline explicit constexpr operator unsigned() const noexcept { return __wd; }
inline constexpr bool ok() const noexcept { return __wd <= 6; }
constexpr weekday_indexed operator[](unsigned __index) const noexcept;
constexpr weekday_last operator[](last_spec) const noexcept;
constexpr weekday_indexed operator[](unsigned __index) const noexcept;
constexpr weekday_last operator[](last_spec) const noexcept;
static constexpr unsigned char __weekday_from_days(int __days) noexcept;
};
// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
inline constexpr
unsigned char weekday::__weekday_from_days(int __days) noexcept
{
return static_cast<unsigned char>(
static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6)
);
}
inline constexpr
bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept
{ return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); }
@@ -2212,6 +2249,7 @@ constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noe
constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept
{ return __lhs + -__rhs; }
class year_month_day_last;
class _LIBCPP_TYPE_VIS year_month_day {
private:
@@ -2223,24 +2261,66 @@ public:
inline constexpr year_month_day(
const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
: __y{__yval}, __m{__mval}, __d{__dval} {}
// inline constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
// inline constexpr year_month_day(const sys_days& dp) noexcept;
// inline explicit constexpr year_month_day(const local_days& dp) noexcept;
constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
inline constexpr year_month_day(const sys_days& __sysd) noexcept
: year_month_day(__from_days(__sysd.time_since_epoch())) {}
inline explicit constexpr year_month_day(const local_days& __locd) noexcept
: year_month_day(__from_days(__locd.time_since_epoch())) {}
constexpr year_month_day& operator+=(const months& __dm) noexcept;
constexpr year_month_day& operator-=(const months& __dm) noexcept;
constexpr year_month_day& operator+=(const years& __dy) noexcept;
constexpr year_month_day& operator-=(const years& __dy) noexcept;
inline constexpr chrono::year year() const noexcept { return __y; }
inline constexpr chrono::month month() const noexcept { return __m; }
inline constexpr chrono::day day() const noexcept { return __d; }
// inline constexpr operator sys_days() const noexcept;
// inline explicit constexpr operator local_days() const noexcept;
// TODO: This is not quite correct; requires the calendar bits to do right
// d_ is in the range [1d, (y_/m_/last).day()],
inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __d.ok(); }
inline constexpr chrono::year year() const noexcept { return __y; }
inline constexpr chrono::month month() const noexcept { return __m; }
inline constexpr chrono::day day() const noexcept { return __d; }
inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
constexpr bool ok() const noexcept;
static constexpr year_month_day __from_days(days __d) noexcept;
constexpr days __to_days() const noexcept;
};
// https://howardhinnant.github.io/date_algorithms.html#civil_from_days
inline constexpr
year_month_day
year_month_day::__from_days(days __d) noexcept
{
static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
static_assert(std::numeric_limits<int>::digits >= 20 , "");
const int __z = __d.count() + 719468;
const int __era = (__z >= 0 ? __z : __z - 146096) / 146097;
const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096]
const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399]
const int __yr = static_cast<int>(__yoe) + __era * 400;
const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365]
const unsigned __mp = (5 * __doy + 2)/153; // [0, 11]
const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31]
const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12]
return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}};
}
// https://howardhinnant.github.io/date_algorithms.html#days_from_civil
inline constexpr days year_month_day::__to_days() const noexcept
{
static_assert(std::numeric_limits<unsigned>::digits >= 18, "");
static_assert(std::numeric_limits<int>::digits >= 20 , "");
const int __yr = static_cast<int>(__y) - (__m <= February);
const unsigned __mth = static_cast<unsigned>(__m);
const unsigned __dy = static_cast<unsigned>(__d);
const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400;
const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399]
const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365]
const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096]
return days{__era * 146097 + static_cast<int>(__doe) - 719468};
}
inline constexpr
bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); }
@@ -2338,15 +2418,29 @@ public:
constexpr year_month_day_last& operator+=(const years& __y) noexcept;
constexpr year_month_day_last& operator-=(const years& __y) noexcept;
constexpr chrono::year year() const noexcept { return __y; }
constexpr chrono::month month() const noexcept { return __mdl.month(); }
constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
// constexpr chrono::day day() const noexcept;
// constexpr operator sys_days() const noexcept;
// explicit constexpr operator local_days() const noexcept;
constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
inline constexpr chrono::year year() const noexcept { return __y; }
inline constexpr chrono::month month() const noexcept { return __mdl.month(); }
inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; }
constexpr chrono::day day() const noexcept;
inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; }
inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); }
};
inline constexpr
chrono::day year_month_day_last::day() const noexcept
{
constexpr chrono::day __d[] =
{
chrono::day(31), chrono::day(28), chrono::day(31),
chrono::day(30), chrono::day(31), chrono::day(30),
chrono::day(31), chrono::day(31), chrono::day(30),
chrono::day(31), chrono::day(30), chrono::day(31)
};
return month() != February || !__y.is_leap() ?
__d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
}
inline constexpr
bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); }
@@ -2420,6 +2514,15 @@ inline constexpr year_month_day_last& year_month_day_last::operator-=(const mont
inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
: __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
inline constexpr bool year_month_day::ok() const noexcept
{
if (!__y.ok() || !__m.ok()) return false;
return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
}
class _LIBCPP_TYPE_VIS year_month_weekday {
chrono::year __y;
chrono::month __m;
@@ -2429,8 +2532,10 @@ public:
constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval,
const chrono::weekday_indexed& __wdival) noexcept
: __y{__yval}, __m{__mval}, __wdi{__wdival} {}
// constexpr year_month_weekday(const sys_days& dp) noexcept;
// explicit constexpr year_month_weekday(const local_days& dp) noexcept;
constexpr year_month_weekday(const sys_days& __sysd) noexcept
: year_month_weekday(__from_days(__sysd.time_since_epoch())) {}
inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept
: year_month_weekday(__from_days(__locd.time_since_epoch())) {}
constexpr year_month_weekday& operator+=(const months& m) noexcept;
constexpr year_month_weekday& operator-=(const months& m) noexcept;
constexpr year_month_weekday& operator+=(const years& y) noexcept;
@@ -2442,16 +2547,37 @@ public:
inline constexpr unsigned index() const noexcept { return __wdi.index(); }
inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; }
// constexpr operator sys_days() const noexcept;
// explicit constexpr operator local_days() const noexcept;
inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
inline constexpr bool ok() const noexcept
{
if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false;
// TODO: make sure it's a valid date
return true;
}
static constexpr year_month_weekday __from_days(days __d) noexcept;
constexpr days __to_days() const noexcept;
};
inline constexpr
year_month_weekday year_month_weekday::__from_days(days __d) noexcept
{
const sys_days __sysd{__d};
const chrono::weekday __wd = chrono::weekday(__sysd);
const year_month_day __ymd = year_month_day(__sysd);
return year_month_weekday{__ymd.year(), __ymd.month(),
__wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
}
inline constexpr
days year_month_weekday::__to_days() const noexcept
{
const sys_days __sysd = sys_days(__y/__m/1);
return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7}))
.time_since_epoch();
}
inline constexpr
bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); }
@@ -2529,11 +2655,22 @@ public:
inline constexpr chrono::month month() const noexcept { return __m; }
inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); }
inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; }
// constexpr operator sys_days() const noexcept;
// explicit constexpr operator local_days() const noexcept;
inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
constexpr days __to_days() const noexcept;
};
inline constexpr
days year_month_weekday_last::__to_days() const noexcept
{
const sys_days __last = sys_days{__y/__m/last};
return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch();
}
inline constexpr
bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept
{ return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); }
@@ -2689,6 +2826,40 @@ namespace chrono { // hoist the literals into namespace std::chrono
_LIBCPP_END_NAMESPACE_STD
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
struct _FilesystemClock {
#if !defined(_LIBCPP_HAS_NO_INT128)
typedef __int128_t rep;
typedef nano period;
#else
typedef long long rep;
typedef nano period;
#endif
typedef chrono::duration<rep, period> duration;
typedef chrono::time_point<_FilesystemClock> time_point;
static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
_LIBCPP_FUNC_VIS static time_point now() noexcept;
_LIBCPP_INLINE_VISIBILITY
static time_t to_time_t(const time_point& __t) noexcept {
typedef chrono::duration<rep> __secs;
return time_t(
chrono::duration_cast<__secs>(__t.time_since_epoch()).count());
}
_LIBCPP_INLINE_VISIBILITY
static time_point from_time_t(time_t __t) noexcept {
typedef chrono::duration<rep> __secs;
return time_point(__secs(__t));
}
};
_LIBCPP_END_NAMESPACE_FILESYSTEM
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_POP_MACROS
#endif // _LIBCPP_CHRONO

View File

@@ -150,6 +150,11 @@ template <class T, class Allocator>
void swap(deque<T,Allocator>& x, deque<T,Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class T, class Allocator, class U>
void erase(deque<T, Allocator>& c, const U& value); // C++20
template <class T, class Allocator, class Predicate>
void erase_if(deque<T, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -987,7 +992,7 @@ public:
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
protected:
@@ -1156,7 +1161,7 @@ __deque_base<_Tp, _Allocator>::swap(__deque_base& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
@@ -2342,7 +2347,7 @@ deque<_Tp, _Allocator>::__add_front_capacity()
_Dp(__a, __base::__block_size));
__buf.push_back(__hold.get());
__hold.release();
for (typename __base::__map_pointer __i = __base::__map_.begin();
__i != __base::__map_.end(); ++__i)
__buf.push_back(*__i);
@@ -2604,6 +2609,7 @@ template <class _Tp, class _Allocator>
void
deque<_Tp, _Allocator>::pop_back()
{
_LIBCPP_ASSERT(!empty(), "deque::pop_back called for empty deque");
allocator_type& __a = __base::__alloc();
size_type __p = __base::size() + __base::__start_ - 1;
__alloc_traits::destroy(__a, __to_raw_pointer(*(__base::__map_.begin() +
@@ -2854,7 +2860,7 @@ deque<_Tp, _Allocator>::swap(deque& __c)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
@@ -2927,6 +2933,19 @@ swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(deque<_Tp, _Allocator>& __c, const _Up& __v)
{ __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); }
template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred)
{ __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); }
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ any -----------------------------------===//
//===------------------------------- any ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_ANY
#define _LIBCPP_EXPERIMENTAL_ANY
#error "<experimental/any> has been removed. Use <any> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/any> has been removed. Use <any> instead.")
#else
# warning "<experimental/any> has been removed. Use <any> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_ANY

View File

@@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ chrono ---------------------------------===//
//===---------------------------- chrono ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
#define _LIBCPP_EXPERIMENTAL_CHRONO
#error "<experimental/chrono> has been removed. Use <chrono> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/chrono> has been removed. Use <chrono> instead.")
#else
# warning "<experimental/chrono> has been removed. Use <chrono> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_CHRONO

View File

@@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
#define _LIBCPP_EXPERIMENTAL_NUMERIC
#error "<experimental/numeric> has been removed. Use <numeric> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/numeric> has been removed. Use <numeric> instead.")
#else
# warning "<experimental/numeric> has been removed. Use <numeric> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_NUMERIC

View File

@@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
#define _LIBCPP_EXPERIMENTAL_OPTIONAL
#error "<experimental/optional> has been removed. Use <optional> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/optional> has been removed. Use <optional> instead.")
#else
# warning "<experimental/optional> has been removed. Use <optional> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL

View File

@@ -1,11 +1,21 @@
// -*- C++ -*-
//===------------------------------ ratio ---------------------------------===//
//===----------------------------- ratio ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_RATIO
#define _LIBCPP_EXPERIMENTAL_RATIO
#error "<experimental/ratio> has been removed. Use <ratio> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/ratio> has been removed. Use <ratio> instead.")
#else
# warning "<experimental/ratio> has been removed. Use <ratio> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_RATIO

View File

@@ -3,9 +3,19 @@
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_STRING_VIEW
#define _LIBCPP_EXPERIMENTAL_STRING_VIEW
#error "<experimental/string_view> has been removed. Use <string_view> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/string_view> has been removed. Use <string_view> instead.")
#else
# warning "<experimental/string_view> has been removed. Use <string_view> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_STRING_VIEW

View File

@@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
#error "<experimental/system_error> has been removed. Use <system_error> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/system_error> has been removed. Use <system_error> instead.")
#else
# warning "<experimental/system_error> has been removed. Use <system_error> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR

View File

@@ -7,5 +7,15 @@
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
#define _LIBCPP_EXPERIMENTAL_TUPLE
#error "<experimental/tuple> has been removed. Use <tuple> instead."
#include <__config>
#ifdef _LIBCPP_WARNING
_LIBCPP_WARNING("<experimental/tuple> has been removed. Use <tuple> instead.")
#else
# warning "<experimental/tuple> has been removed. Use <tuple> instead."
#endif
#endif // _LIBCPP_EXPERIMENTAL_TUPLE

View File

@@ -259,36 +259,6 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
struct _FilesystemClock {
#if !defined(_LIBCPP_HAS_NO_INT128)
typedef __int128_t rep;
typedef nano period;
#else
typedef long long rep;
typedef nano period;
#endif
typedef chrono::duration<rep, period> duration;
typedef chrono::time_point<_FilesystemClock> time_point;
static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
_LIBCPP_FUNC_VIS static time_point now() noexcept;
_LIBCPP_INLINE_VISIBILITY
static time_t to_time_t(const time_point& __t) noexcept {
typedef chrono::duration<rep> __secs;
return time_t(
chrono::duration_cast<__secs>(__t.time_since_epoch()).count());
}
_LIBCPP_INLINE_VISIBILITY
static time_point from_time_t(time_t __t) noexcept {
typedef chrono::duration<rep> __secs;
return time_point(__secs(__t));
}
};
typedef chrono::time_point<_FilesystemClock> file_time_type;
struct _LIBCPP_TYPE_VIS space_info {
@@ -1181,6 +1151,31 @@ public:
return __is;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) == 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) != 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) < 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) <= 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) > 0;
}
friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
return __lhs.compare(__rhs) >= 0;
}
friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
const path& __rhs) {
path __result(__lhs);
__result /= __rhs;
return __result;
}
private:
inline _LIBCPP_INLINE_VISIBILITY path&
__assign_view(__string_view const& __s) noexcept {
@@ -1197,43 +1192,6 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
_LIBCPP_FUNC_VIS
size_t hash_value(const path& __p) noexcept;
inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) == 0;
}
inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) != 0;
}
inline _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) < 0;
}
inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) <= 0;
}
inline _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) > 0;
}
inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs,
const path& __rhs) noexcept {
return __lhs.compare(__rhs) >= 0;
}
inline _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
const path& __rhs) {
path __result(__lhs);
__result /= __rhs;
return __result;
}
template <class _Source>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_pathable<_Source>::value, path>::type

View File

@@ -167,6 +167,11 @@ template <class T, class Allocator>
void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class T, class Allocator, class U>
void erase(forward_list<T, Allocator>& c, const U& value); // C++20
template <class T, class Allocator, class Predicate>
void erase_if(forward_list<T, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -1744,6 +1749,18 @@ swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred)
{ __c.remove_if(__pred); }
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v)
{ _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); }
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -702,6 +702,7 @@ basic_filebuf<_CharT, _Traits>::close()
__file_ = 0;
else
__rt = 0;
setbuf(0, 0);
}
return __rt;
}

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,12 @@ namespace std
{
template<class charT> struct char_traits;
template<> struct char_traits<char>;
template<> struct char_traits<char8_t>; // C++20
template<> struct char_traits<char16_t>;
template<> struct char_traits<char32_t>;
template<> struct char_traits<wchar_t>;
template<class T> class allocator;
class ios_base;
@@ -98,6 +104,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class _LIBCPP_TYPE_VIS ios_base;
template<class _CharT> struct _LIBCPP_TEMPLATE_VIS char_traits;
template<> struct char_traits<char>;
#ifndef _LIBCPP_NO_HAS_CHAR8_T
template<> struct char_traits<char8_t>;
#endif
template<> struct char_traits<char16_t>;
template<> struct char_traits<char32_t>;
template<> struct char_traits<wchar_t>;
template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator;
template <class _CharT, class _Traits = char_traits<_CharT> >
@@ -175,6 +189,9 @@ typedef basic_fstream<wchar_t> wfstream;
template <class _State> class _LIBCPP_TEMPLATE_VIS fpos;
typedef fpos<mbstate_t> streampos;
typedef fpos<mbstate_t> wstreampos;
#ifndef _LIBCPP_NO_HAS_CHAR8_T
typedef fpos<mbstate_t> u8streampos;
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef fpos<mbstate_t> u16streampos;
typedef fpos<mbstate_t> u32streampos;

View File

@@ -160,6 +160,7 @@ template <class charT, class traits, class T>
*/
#include <__config>
#include <version>
#include <ostream>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -1504,7 +1505,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
return __is;
}
#ifndef _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>)

View File

@@ -119,6 +119,7 @@ template<> class numeric_limits<cv long double>;
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
#include <version>
_LIBCPP_BEGIN_NAMESPACE_STD

View File

@@ -169,6 +169,11 @@ template <class T, class Alloc>
void swap(list<T,Alloc>& x, list<T,Alloc>& y)
noexcept(noexcept(x.swap(y)));
template <class T, class Allocator, class U>
void erase(list<T, Allocator>& c, const U& value); // C++20
template <class T, class Allocator, class Predicate>
void erase_if(list<T, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -2450,6 +2455,18 @@ swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred)
{ __c.remove_if(__pred); }
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(list<_Tp, _Allocator>& __c, const _Up& __v)
{ _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); }
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -187,6 +187,7 @@ template <class charT> class messages_byname;
#include <streambuf>
#include <iterator>
#include <limits>
#include <version>
#ifndef __APPLE__
#include <cstdarg>
#endif

View File

@@ -254,6 +254,10 @@ void
swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class T, class Compare, class Allocator, class Predicate>
void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
template <class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key, T>>>
class multimap
@@ -465,6 +469,9 @@ swap(multimap<Key, T, Compare, Allocator>& x,
multimap<Key, T, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class T, class Compare, class Allocator, class Predicate>
void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -486,7 +493,8 @@ swap(multimap<Key, T, Compare, Allocator>& x,
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _CP, class _Compare, bool _IsSmall>
template <class _Key, class _CP, class _Compare,
bool = is_empty<_Compare>::value && !__libcpp_is_final<_Compare>::value>
class __map_value_compare
: private _Compare
{
@@ -900,6 +908,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -1612,6 +1621,14 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Key, class _Tp, class _Compare = less<_Key>,
class _Allocator = allocator<pair<const _Key, _Tp> > >
class _LIBCPP_TEMPLATE_VIS multimap
@@ -1626,6 +1643,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -2148,6 +2166,13 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_MAP

View File

@@ -1460,29 +1460,21 @@ struct __has_select_on_container_copy_construction
#else // _LIBCPP_CXX03_LANG
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _Alloc, class _Pointer, class _Tp, class = void>
struct __has_construct : std::false_type {};
template <class _Alloc, class _Pointer, class ..._Args>
struct __has_construct
: false_type
{
};
template <class _Alloc, class _Pointer, class _Tp>
struct __has_construct<_Alloc, _Pointer, _Tp, typename __void_t<
decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Pointer>(), _VSTD::declval<_Tp>()))
>::type> : std::true_type {};
#else // _LIBCPP_HAS_NO_VARIADICS
template <class _Alloc, class _Pointer, class _Args>
struct __has_construct
: false_type
{
};
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Alloc, class _Pointer, class = void>
struct __has_destroy : false_type {};
template <class _Alloc, class _Pointer>
struct __has_destroy
: false_type
{
};
struct __has_destroy<_Alloc, _Pointer, typename __void_t<
decltype(_VSTD::declval<_Alloc>().destroy(_VSTD::declval<_Pointer>()))
>::type> : std::true_type {};
template <class _Alloc>
struct __has_max_size
@@ -1510,6 +1502,12 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
typedef typename _Alloc::difference_type type;
};
template <class _Tp>
struct __is_default_allocator : false_type {};
template <class _Tp>
struct __is_default_allocator<_VSTD::allocator<_Tp> > : true_type {};
template <class _Alloc>
struct _LIBCPP_TEMPLATE_VIS allocator_traits
{
@@ -1571,9 +1569,10 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
}
template <class _Tp, class _A0>
_LIBCPP_INLINE_VISIBILITY
static void construct(allocator_type&, _Tp* __p, const _A0& __a0)
static void construct(allocator_type& __a, _Tp* __p, const _A0& __a0)
{
::new ((void*)__p) _Tp(__a0);
__construct(__has_construct<allocator_type, _Tp*, const _A0&>(),
__a, __p, __a0);
}
template <class _Tp, class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
@@ -1613,7 +1612,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
void
__construct_forward(allocator_type& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2)
{
for (; __begin1 != __end1; ++__begin1, ++__begin2)
for (; __begin1 != __end1; ++__begin1, (void) ++__begin2)
construct(__a, _VSTD::__to_raw_pointer(__begin2), _VSTD::move_if_noexcept(*__begin1));
}
@@ -1622,7 +1621,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
(__is_default_allocator<allocator_type>::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
@@ -1647,23 +1646,25 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
construct(__a, _VSTD::__to_raw_pointer(__begin2), *__begin1);
}
template <class _Tp>
template <class _SourceTp, class _DestTp,
class _RawSourceTp = typename remove_const<_SourceTp>::type,
class _RawDestTp = typename remove_const<_DestTp>::type>
_LIBCPP_INLINE_VISIBILITY
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
is_trivially_move_constructible<_DestTp>::value &&
is_same<_RawSourceTp, _RawDestTp>::value &&
(__is_default_allocator<allocator_type>::value ||
!__has_construct<allocator_type, _DestTp*, _SourceTp&>::value),
void
>::type
__construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2)
__construct_range_forward(allocator_type&, _SourceTp* __begin1, _SourceTp* __end1, _DestTp*& __begin2)
{
typedef typename remove_const<_Tp>::type _Vp;
ptrdiff_t _Np = __end1 - __begin1;
if (_Np > 0)
{
_VSTD::memcpy(const_cast<_Vp*>(__begin2), __begin1, _Np * sizeof(_Tp));
_VSTD::memcpy(const_cast<_RawDestTp*>(__begin2), __begin1, _Np * sizeof(_DestTp));
__begin2 += _Np;
}
}
@@ -1686,7 +1687,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
static
typename enable_if
<
(is_same<allocator_type, allocator<_Tp> >::value
(__is_default_allocator<allocator_type>::value
|| !__has_construct<allocator_type, _Tp*, _Tp>::value) &&
is_trivially_move_constructible<_Tp>::value,
void
@@ -1721,6 +1722,19 @@ private:
{
::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...);
}
#else // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp, class _A0>
_LIBCPP_INLINE_VISIBILITY
static void __construct(true_type, allocator_type& __a, _Tp* __p,
const _A0& __a0)
{__a.construct(__p, __a0);}
template <class _Tp, class _A0>
_LIBCPP_INLINE_VISIBILITY
static void __construct(false_type, allocator_type&, _Tp* __p,
const _A0& __a0)
{
::new ((void*)__p) _Tp(__a0);
}
#endif // _LIBCPP_HAS_NO_VARIADICS
template <class _Tp>

View File

@@ -105,8 +105,8 @@ namespace std {
// 23.6.3.3, assignment
optional &operator=(nullopt_t) noexcept;
optional &operator=(const optional &);
optional &operator=(optional &&) noexcept(see below );
optional &operator=(const optional &); // constexpr in C++20
optional &operator=(optional &&) noexcept(see below); // constexpr in C++20
template <class U = T> optional &operator=(U &&);
template <class U> optional &operator=(const optional<U> &);
template <class U> optional &operator=(optional<U> &&);

View File

@@ -140,6 +140,7 @@ template <class charT, class traits, class T>
#include <locale>
#include <iterator>
#include <bitset>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -1092,7 +1093,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
#ifndef _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
#endif

View File

@@ -996,6 +996,10 @@ public:
static const char_class_type __regex_word = 0x8000;
#elif defined(__mips__) && defined(__GLIBC__)
static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15));
#elif defined(__NetBSD__)
// NetBSD defines classes up to 0x2000
// see sys/ctype_bits.h, _CTYPE_Q
static const char_class_type __regex_word = 0x8000;
#else
static const char_class_type __regex_word = 0x80;
#endif

View File

@@ -216,6 +216,9 @@ void
swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class Compare, class Allocator, class Predicate>
void erase_if(set<Key, Compare, Allocator>& c, Predicate pred); // C++20
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
class multiset
@@ -412,6 +415,9 @@ void
swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class Key, class Compare, class Allocator, class Predicate>
void erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -445,6 +451,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -911,6 +918,13 @@ swap(set<_Key, _Compare, _Allocator>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key> >
class _LIBCPP_TEMPLATE_VIS multiset
@@ -925,6 +939,7 @@ public:
typedef value_type& reference;
typedef const value_type& const_reference;
static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -1390,6 +1405,13 @@ swap(multiset<_Key, _Compare, _Allocator>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Compare, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_SET

View File

@@ -486,7 +486,7 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
return traits_type::eof();
}
#ifndef _LIBCPP_AVAILABILITY_NO_STREAMS_EXTERN_TEMPLATE
#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>)
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>)

View File

@@ -437,6 +437,11 @@ template<class charT, class traits, class Allocator>
basic_istream<charT, traits>&
getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
template<class charT, class traits, class Allocator, class U>
void erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20
template<class charT, class traits, class Allocator, class Predicate>
void erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20
typedef basic_string<char> string;
typedef basic_string<wchar_t> wstring;
typedef basic_string<char16_t> u16string;
@@ -4170,11 +4175,13 @@ swap(basic_string<_CharT, _Traits, _Allocator>& __lhs,
__lhs.swap(__rhs);
}
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
#ifndef _LIBCPP_NO_HAS_CHAR8_T
typedef basic_string<char8_t> u8string;
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef basic_string<char16_t> u16string;
typedef basic_string<char32_t> u32string;
#endif // _LIBCPP_HAS_NO_UNICODE_CHARS
_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10);
@@ -4274,6 +4281,18 @@ getline(basic_istream<_CharT, _Traits>&& __is,
#endif // _LIBCPP_CXX03_LANG
#if _LIBCPP_STD_VER > 17
template<class _CharT, class _Traits, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v)
{ __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); }
template<class _CharT, class _Traits, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred)
{ __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); }
#endif
#if _LIBCPP_DEBUG_LEVEL >= 2
template<class _CharT, class _Traits, class _Allocator>
@@ -4331,6 +4350,14 @@ inline namespace literals
return basic_string<wchar_t> (__str, __len);
}
#ifndef _LIBCPP_NO_HAS_CHAR8_T
inline _LIBCPP_INLINE_VISIBILITY
basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT
{
return basic_string<char8_t> (__str, __len);
}
#endif
inline _LIBCPP_INLINE_VISIBILITY
basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
{

View File

@@ -769,6 +769,9 @@ bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type
}
typedef basic_string_view<char> string_view;
#ifndef _LIBCPP_NO_HAS_CHAR8_T
typedef basic_string_view<char8_t> u8string_view;
#endif
typedef basic_string_view<char16_t> u16string_view;
typedef basic_string_view<char32_t> u32string_view;
typedef basic_string_view<wchar_t> wstring_view;
@@ -802,6 +805,14 @@ inline namespace literals
return basic_string_view<wchar_t> (__str, __len);
}
#ifndef _LIBCPP_NO_HAS_CHAR8_T
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
basic_string_view<char8_t> operator "" sv(const char8_t *__str, size_t __len) _NOEXCEPT
{
return basic_string_view<char8_t> (__str, __len);
}
#endif
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
{

View File

@@ -84,8 +84,8 @@ template <class T, class Tuple>
constexpr T make_from_tuple(Tuple&& t); // C++17
// 20.4.1.4, tuple helper classes:
template <class T> class tuple_size; // undefined
template <class... T> class tuple_size<tuple<T...>>;
template <class T> struct tuple_size; // undefined
template <class... T> struct tuple_size<tuple<T...>>;
template <class T>
inline constexpr size_t tuple_size_v = tuple_size<T>::value; // C++17
template <size_t I, class T> class tuple_element; // undefined

View File

@@ -709,7 +709,7 @@ template <> struct __libcpp_is_integral<char> : public tr
template <> struct __libcpp_is_integral<signed char> : public true_type {};
template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
#if _LIBCPP_STD_VER > 17 && defined(__cpp_char8_t)
#ifndef _LIBCPP_NO_HAS_CHAR8_T
template <> struct __libcpp_is_integral<char8_t> : public true_type {};
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS

View File

@@ -73,12 +73,8 @@ public:
#include <vcruntime_typeinfo.h>
#else
#if !defined(_LIBCPP_ABI_MICROSOFT)
#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT)
#define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
#else
#define _LIBCPP_HAS_UNIQUE_TYPEINFO
#endif
#if defined(_LIBCPP_NONUNIQUE_RTTI_BIT) && !defined(_LIBCPP_ABI_MICROSOFT)
# define _LIBCPP_HAS_NONUNIQUE_TYPEINFO
#endif
namespace std // purposefully not using versioning namespace

View File

@@ -384,6 +384,12 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template <class K, class T, class H, class P, class A, class Predicate>
void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20
template <class K, class T, class H, class P, class A, class Predicate>
void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20
template <class Key, class T, class Hash, class Pred, class Alloc>
bool
operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
@@ -414,7 +420,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Cp, class _Hash, bool _IsEmpty>
template <class _Key, class _Cp, class _Hash,
bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value>
class __unordered_map_hasher
: private _Hash
{
@@ -482,7 +489,8 @@ swap(__unordered_map_hasher<_Key, _Cp, _Hash, __b>& __x,
__x.swap(__y);
}
template <class _Key, class _Cp, class _Pred, bool _IsEmpty>
template <class _Key, class _Cp, class _Pred,
bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value>
class __unordered_map_equal
: private _Pred
{
@@ -845,6 +853,7 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
@@ -1623,6 +1632,13 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
@@ -1667,6 +1683,7 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
static_assert(sizeof(__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), "");
private:
typedef __hash_value_type<key_type, mapped_type> __value_type;
@@ -2239,6 +2256,13 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,

View File

@@ -339,6 +339,13 @@ template <class Value, class Hash, class Pred, class Alloc>
unordered_multiset<Value, Hash, Pred, Alloc>& y)
noexcept(noexcept(x.swap(y)));
template <class K, class T, class H, class P, class A, class Predicate>
void erase_if(unordered_set<K, T, H, P, A>& c, Predicate pred); // C++20
template <class K, class T, class H, class P, class A, class Predicate>
void erase_if(unordered_multiset<K, T, H, P, A>& c, Predicate pred); // C++20
template <class Value, class Hash, class Pred, class Alloc>
bool
operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
@@ -384,6 +391,7 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
@@ -933,6 +941,13 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
@@ -976,6 +991,7 @@ public:
typedef const value_type& const_reference;
static_assert((is_same<value_type, typename allocator_type::value_type>::value),
"Invalid allocator::value_type");
static_assert(sizeof(__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
@@ -1495,6 +1511,13 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred)
{ __libcpp_erase_if_container(__c, __pred); }
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,

View File

@@ -103,7 +103,7 @@ swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y)));
struct piecewise_construct_t { };
inline constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
template <class T> class tuple_size;
template <class T> struct tuple_size;
template <size_t I, class T> class tuple_element;
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
@@ -409,13 +409,17 @@ struct _LIBCPP_TEMPLATE_VIS pair
_CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
pair() : first(), second() {}
pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
is_nothrow_default_constructible<second_type>::value)
: first(), second() {}
template <bool _Dummy = true, _EnableB<
_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_T1 const& __t1, _T2 const& __t2)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
is_nothrow_copy_constructible<second_type>::value)
: first(__t1), second(__t2) {}
template<bool _Dummy = true, _EnableB<
@@ -423,6 +427,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_T1 const& __t1, _T2 const& __t2)
_NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
is_nothrow_copy_constructible<second_type>::value)
: first(__t1), second(__t2) {}
template<class _U1, class _U2, _EnableB<
@@ -430,6 +436,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(_U1&& __u1, _U2&& __u2)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
is_nothrow_constructible<second_type, _U2>::value))
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
@@ -437,6 +445,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(_U1&& __u1, _U2&& __u2)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
is_nothrow_constructible<second_type, _U2>::value))
: first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
template<class _U1, class _U2, _EnableB<
@@ -444,6 +454,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2> const& __p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
is_nothrow_constructible<second_type, _U2 const&>::value))
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
@@ -451,6 +463,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2> const& __p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
is_nothrow_constructible<second_type, _U2 const&>::value))
: first(__p.first), second(__p.second) {}
template<class _U1, class _U2, _EnableB<
@@ -458,6 +472,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
explicit pair(pair<_U1, _U2>&&__p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
is_nothrow_constructible<second_type, _U2&&>::value))
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _U1, class _U2, _EnableB<
@@ -465,6 +481,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
> = false>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair(pair<_U1, _U2>&& __p)
_NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
is_nothrow_constructible<second_type, _U2&&>::value))
: first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
template<class _Tuple, _EnableB<
@@ -487,6 +505,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
_LIBCPP_INLINE_VISIBILITY
pair(piecewise_construct_t __pc,
tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
_NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
is_nothrow_constructible<second_type, _Args2...>::value))
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
@@ -663,7 +683,7 @@ make_pair(_T1 __x, _T2 __y)
#endif // _LIBCPP_CXX03_LANG
template <class _T1, class _T2>
class _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> >
: public integral_constant<size_t, 2> {};
template <size_t _Ip, class _T1, class _T2>

View File

@@ -23,8 +23,8 @@ namespace std {
// 20.7.2.1, constructors
constexpr variant() noexcept(see below);
variant(const variant&);
variant(variant&&) noexcept(see below);
variant(const variant&); // constexpr in C++20
variant(variant&&) noexcept(see below); // constexpr in C++20
template <class T> constexpr variant(T&&) noexcept(see below);
@@ -46,8 +46,8 @@ namespace std {
~variant();
// 20.7.2.3, assignment
variant& operator=(const variant&);
variant& operator=(variant&&) noexcept(see below);
variant& operator=(const variant&); // constexpr in C++20
variant& operator=(variant&&) noexcept(see below); // constexpr in C++20
template <class T> variant& operator=(T&&) noexcept(see below);
@@ -1066,7 +1066,7 @@ public:
#ifndef _LIBCPP_NO_EXCEPTIONS
// EXTENSION: When the move construction of `__lhs` into `__rhs` throws
// and `__tmp` is nothrow move constructible then we move `__tmp` back
// into `__rhs` and provide the strong exception safety guarentee.
// into `__rhs` and provide the strong exception safety guarantee.
try {
this->__generic_construct(*__rhs, _VSTD::move(*__lhs));
} catch (...) {

View File

@@ -261,6 +261,11 @@ template <class T, class Allocator>
void swap(vector<T,Allocator>& x, vector<T,Allocator>& y)
noexcept(noexcept(x.swap(y)));
template <class T, class Allocator, class U>
void erase(vector<T, Allocator>& c, const U& value); // C++20
template <class T, class Allocator, class Predicate>
void erase_if(vector<T, Allocator>& c, Predicate pred); // C++20
} // std
*/
@@ -3408,6 +3413,18 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
__x.swap(__y);
}
#if _LIBCPP_STD_VER > 17
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_INLINE_VISIBILITY
void erase(vector<_Tp, _Allocator>& __c, const _Up& __v)
{ __c.erase(_VSTD::remove(__c.begin(), __c.end(), __v), __c.end()); }
template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_INLINE_VISIBILITY
void erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred)
{ __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); }
#endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@@ -30,6 +30,8 @@ __cpp_lib_bit_cast 201806L <bit>
__cpp_lib_bool_constant 201505L <type_traits>
__cpp_lib_boyer_moore_searcher 201603L <functional>
__cpp_lib_byte 201603L <cstddef>
__cpp_lib_char8_t 201811L <atomic> <filesystem> <istream> <limits>
<locale> <ostream> <string> <string_view>
__cpp_lib_chrono 201611L <chrono>
__cpp_lib_chrono_udls 201304L <chrono>
__cpp_lib_clamp 201603L <algorithm>
@@ -37,6 +39,9 @@ __cpp_lib_complex_udls 201309L <complex>
__cpp_lib_concepts 201806L <concepts>
__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
__cpp_lib_enable_shared_from_this 201603L <memory>
__cpp_lib_erase_if 201811L <string> <deque> <forward_list> <list>
<vector> <map> <set> <unordered_map>
<unordered_set>
__cpp_lib_exchange_function 201304L <utility>
__cpp_lib_execution 201603L <execution>
__cpp_lib_filesystem 201703L <filesystem>
@@ -114,6 +119,10 @@ __cpp_lib_void_t 201411L <type_traits>
#endif
#if _LIBCPP_STD_VER > 17
#ifndef _LIBCPP_NO_HAS_CHAR8_T
# define __cpp_lib_char8_t 201811L
#endif
#define __cpp_lib_erase_if 201811L
#endif
#endif // _LIBCPP_VERSIONH

View File

@@ -175,42 +175,69 @@ endif()
split_list(LIBCXX_COMPILE_FLAGS)
split_list(LIBCXX_LINK_FLAGS)
# Add an object library that contains the compiled source files.
add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
if(LIBCXX_CXX_ABI_HEADER_TARGET)
add_dependencies(cxx_objects ${LIBCXX_CXX_ABI_HEADER_TARGET})
endif()
if(WIN32 AND NOT MINGW)
target_compile_definitions(cxx_objects
PRIVATE
# Ignore the -MSC_VER mismatch, as we may build
# with a different compatibility version.
_ALLOW_MSC_VER_MISMATCH
# Don't check the msvcprt iterator debug levels
# as we will define the iterator types; libc++
# uses a different macro to identify the debug
# level.
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
# We are building the c++ runtime, don't pull in
# msvcprt.
_CRTBLD
# Don't warn on the use of "deprecated"
# "insecure" functions which are standards
# specified.
_CRT_SECURE_NO_WARNINGS
# Use the ISO conforming behaviour for conversion
# in printf, scanf.
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
endif()
macro(cxx_object_library name)
cmake_parse_arguments(ARGS "" "" "DEFINES;FLAGS" ${ARGN})
set_target_properties(cxx_objects
PROPERTIES
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
)
# Add an object library that contains the compiled source files.
add_library(${name} OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
if(LIBCXX_CXX_ABI_HEADER_TARGET)
add_dependencies(${name} ${LIBCXX_CXX_ABI_HEADER_TARGET})
endif()
if(WIN32 AND NOT MINGW)
target_compile_definitions(${name}
PRIVATE
# Ignore the -MSC_VER mismatch, as we may build
# with a different compatibility version.
_ALLOW_MSC_VER_MISMATCH
# Don't check the msvcprt iterator debug levels
# as we will define the iterator types; libc++
# uses a different macro to identify the debug
# level.
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
# We are building the c++ runtime, don't pull in
# msvcprt.
_CRTBLD
# Don't warn on the use of "deprecated"
# "insecure" functions which are standards
# specified.
_CRT_SECURE_NO_WARNINGS
# Use the ISO conforming behaviour for conversion
# in printf, scanf.
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
endif()
if(ARGS_DEFINES)
target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
endif()
set_target_properties(${name}
PROPERTIES
COMPILE_FLAGS ${LIBCXX_COMPILE_FLAGS}
)
if(ARGS_FLAGS)
target_compile_options(${name} PRIVATE ${ARGS_FLAGS})
endif()
endmacro()
if(LIBCXX_HERMETIC_STATIC_LIBRARY)
append_flags_if_supported(CXX_STATIC_OBJECTS_FLAGS -fvisibility=hidden)
append_flags_if_supported(CXX_STATIC_OBJECTS_FLAGS -fvisibility-global-new-delete-hidden)
cxx_object_library(cxx_static_objects
DEFINES _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
FLAGS ${CXX_STATIC_OBJECTS_FLAGS})
cxx_object_library(cxx_shared_objects)
set(cxx_static_sources $<TARGET_OBJECTS:cxx_static_objects>)
set(cxx_shared_sources $<TARGET_OBJECTS:cxx_shared_objects>)
else()
cxx_object_library(cxx_objects)
set(cxx_static_sources $<TARGET_OBJECTS:cxx_objects>)
set(cxx_shared_sources $<TARGET_OBJECTS:cxx_objects>)
endif()
# Build the shared library.
if (LIBCXX_ENABLE_SHARED)
add_library(cxx_shared SHARED $<TARGET_OBJECTS:cxx_objects>)
add_library(cxx_shared SHARED ${cxx_shared_sources})
if(COMMAND llvm_setup_rpath)
llvm_setup_rpath(cxx_shared)
endif()
@@ -237,7 +264,7 @@ endif()
# Build the static library.
if (LIBCXX_ENABLE_STATIC)
add_library(cxx_static STATIC $<TARGET_OBJECTS:cxx_objects>)
add_library(cxx_static STATIC ${cxx_static_sources})
target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
set_target_properties(cxx_static

View File

@@ -206,8 +206,20 @@ public:
return *this;
}
bool atEnd() const noexcept {
return State == PS_AtEnd;
}
bool inRootDir() const noexcept {
return State == PS_InRootDir;
}
bool inRootName() const noexcept {
return State == PS_InRootName;
}
bool inRootPath() const noexcept {
return State == PS_InRootDir || State == PS_InRootName;
return inRootName() || inRootDir();
}
private:
@@ -1294,7 +1306,19 @@ string_view_t path::__root_path_raw() const {
return {};
}
static bool ConsumeRootName(PathParser *PP) {
static_assert(PathParser::PS_BeforeBegin == 1 &&
PathParser::PS_InRootName == 2,
"Values for enums are incorrect");
while (PP->State <= PathParser::PS_InRootName)
++(*PP);
return PP->State == PathParser::PS_AtEnd;
}
static bool ConsumeRootDir(PathParser* PP) {
static_assert(PathParser::PS_BeforeBegin == 1 &&
PathParser::PS_InRootName == 2 &&
PathParser::PS_InRootDir == 3, "Values for enums are incorrect");
while (PP->State <= PathParser::PS_InRootDir)
++(*PP);
return PP->State == PathParser::PS_AtEnd;
@@ -1454,7 +1478,7 @@ static int DetermineLexicalElementCount(PathParser PP) {
auto Elem = *PP;
if (Elem == "..")
--Count;
else if (Elem != ".")
else if (Elem != "." && Elem != "")
++Count;
}
return Count;
@@ -1468,8 +1492,7 @@ path path::lexically_relative(const path& base) const {
return PP.State != PPBase.State &&
(PP.inRootPath() || PPBase.inRootPath());
};
if (PP.State == PathParser::PS_InRootName &&
PPBase.State == PathParser::PS_InRootName) {
if (PP.inRootName() && PPBase.inRootName()) {
if (*PP != *PPBase)
return {};
} else if (CheckIterMismatchAtBase())
@@ -1501,6 +1524,10 @@ path path::lexically_relative(const path& base) const {
if (ElemCount < 0)
return {};
// if n == 0 and (a == end() || a->empty()), returns path("."); otherwise
if (ElemCount == 0 && (PP.atEnd() || *PP == ""))
return ".";
// return a path constructed with 'n' dot-dot elements, followed by the the
// elements of '*this' after the mismatch.
path Result;
@@ -1514,21 +1541,68 @@ path path::lexically_relative(const path& base) const {
////////////////////////////////////////////////////////////////////////////
// path.comparisons
int path::__compare(string_view_t __s) const {
auto PP = PathParser::CreateBegin(__pn_);
auto PP2 = PathParser::CreateBegin(__s);
while (PP && PP2) {
int res = (*PP).compare(*PP2);
if (res != 0)
return res;
++PP;
++PP2;
}
if (PP.State == PP2.State && !PP)
static int CompareRootName(PathParser *LHS, PathParser *RHS) {
if (!LHS->inRootName() && !RHS->inRootName())
return 0;
if (!PP)
auto GetRootName = [](PathParser *Parser) -> string_view_t {
return Parser->inRootName() ? **Parser : "";
};
int res = GetRootName(LHS).compare(GetRootName(RHS));
ConsumeRootName(LHS);
ConsumeRootName(RHS);
return res;
}
static int CompareRootDir(PathParser *LHS, PathParser *RHS) {
if (!LHS->inRootDir() && RHS->inRootDir())
return -1;
return 1;
else if (LHS->inRootDir() && !RHS->inRootDir())
return 1;
else {
ConsumeRootDir(LHS);
ConsumeRootDir(RHS);
return 0;
}
}
static int CompareRelative(PathParser *LHSPtr, PathParser *RHSPtr) {
auto &LHS = *LHSPtr;
auto &RHS = *RHSPtr;
int res;
while (LHS && RHS) {
if ((res = (*LHS).compare(*RHS)) != 0)
return res;
++LHS;
++RHS;
}
return 0;
}
static int CompareEndState(PathParser *LHS, PathParser *RHS) {
if (LHS->atEnd() && !RHS->atEnd())
return -1;
else if (!LHS->atEnd() && RHS->atEnd())
return 1;
return 0;
}
int path::__compare(string_view_t __s) const {
auto LHS = PathParser::CreateBegin(__pn_);
auto RHS = PathParser::CreateBegin(__s);
int res;
if ((res = CompareRootName(&LHS, &RHS)) != 0)
return res;
if ((res = CompareRootDir(&LHS, &RHS)) != 0)
return res;
if ((res = CompareRelative(&LHS, &RHS)) != 0)
return res;
return CompareEndState(&LHS, &RHS);
}
////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,56 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <algorithm>
// __half_positive divides an integer number by 2 as unsigned number for known types.
// It can be an important optimization for lower bound, for example.
#include <algorithm>
#include <cassert>
#include <limits>
#include <type_traits>
#include "test_macros.h"
#include "user_defined_integral.hpp"
namespace {
template <class IntType, class UnderlyingType = IntType>
TEST_CONSTEXPR bool test(IntType max_v = IntType(std::numeric_limits<UnderlyingType>::max())) {
return std::__half_positive(max_v) == max_v / 2;
}
} // namespace
int main()
{
{
assert(test<char>());
assert(test<int>());
assert(test<long>());
assert((test<UserDefinedIntegral<int>, int>()));
assert(test<size_t>());
#if !defined(_LIBCPP_HAS_NO_INT128)
assert(test<__int128_t>());
#endif // !defined(_LIBCPP_HAS_NO_INT128)
}
#if TEST_STD_VER >= 11
{
static_assert(test<char>(), "");
static_assert(test<int>(), "");
static_assert(test<long>(), "");
static_assert(test<size_t>(), "");
#if !defined(_LIBCPP_HAS_NO_INT128)
static_assert(test<__int128_t>(), "");
#endif // !defined(_LIBCPP_HAS_NO_INT128)
}
#endif // TEST_STD_VER >= 11
}

View File

@@ -27,7 +27,8 @@ int main() {
static_assert(!std::__invokable<BadCompare const&, int const&, int const&>::value, "");
static_assert(std::__invokable<BadCompare&, int const&, int const&>::value, "");
// expected-warning@__tree:* 4 {{the specified comparator type does not provide a const call operator}}
// expected-warning@set:* 2 {{the specified comparator type does not provide a const call operator}}
// expected-warning@map:* 2 {{the specified comparator type does not provide a const call operator}}
{
using C = std::set<int, BadCompare>;
C s;

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <deque>
// pop_back() more than the number of elements in a deque
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <cstdlib>
#include <deque>
int main() {
std::deque<int> q;
q.push_back(0);
q.pop_back();
q.pop_back();
std::exit(1);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <vector>
// pop_back() more than the number of elements in a vector
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
#include <cstdlib>
#include <vector>
int main() {
std::vector<int> v;
v.push_back(0);
v.pop_back();
v.pop_back();
std::exit(1);
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <vector>
// template <class InputIter> vector(InputIter first, InputIter last);
#include <vector>
#include <cassert>
#include "min_allocator.h"
void test_ctor_under_alloc() {
int arr1[] = {42};
int arr2[] = {1, 101, 42};
{
typedef std::vector<int, cpp03_allocator<int> > C;
typedef C::allocator_type Alloc;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3);
assert(Alloc::construct_called);
}
}
{
typedef std::vector<int, cpp03_overload_allocator<int> > C;
typedef C::allocator_type Alloc;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3);
assert(Alloc::construct_called);
}
}
}
int main() {
test_ctor_under_alloc();
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <vector>
// template <class InputIter> vector(InputIter first, InputIter last,
// const allocator_type& a);
#include <vector>
#include <cassert>
#include "min_allocator.h"
void test_ctor_under_alloc() {
int arr1[] = {42};
int arr2[] = {1, 101, 42};
{
typedef std::vector<int, cpp03_allocator<int> > C;
typedef C::allocator_type Alloc;
Alloc a;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1, a);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3, a);
assert(Alloc::construct_called);
}
}
{
typedef std::vector<int, cpp03_overload_allocator<int> > C;
typedef C::allocator_type Alloc;
Alloc a;
{
Alloc::construct_called = false;
C v(arr1, arr1 + 1, a);
assert(Alloc::construct_called);
}
{
Alloc::construct_called = false;
C v(arr2, arr2 + 3, a);
assert(Alloc::construct_called);
}
}
}
int main() {
test_ctor_under_alloc();
}

View File

@@ -11,7 +11,7 @@
// REQUIRES: diagnose-if-support, verify-support
// Test that libc++ generates a warning diagnostic when the container is
// provided a non-const callable comparator.
// provided a non-const callable comparator or a non-const hasher.
#include <unordered_set>
#include <unordered_map>
@@ -34,8 +34,10 @@ int main() {
static_assert(!std::__invokable<BadEqual const&, int const&, int const&>::value, "");
static_assert(std::__invokable<BadEqual&, int const&, int const&>::value, "");
// expected-warning@__hash_table:* 4 {{the specified comparator type does not provide a const call operator}}
// expected-warning@__hash_table:* 4 {{the specified hash functor does not provide a const call operator}}
// expected-warning@unordered_set:* 2 {{the specified comparator type does not provide a const call operator}}
// expected-warning@unordered_map:* 2 {{the specified comparator type does not provide a const call operator}}
// expected-warning@unordered_set:* 2 {{the specified hash functor does not provide a const call operator}}
// expected-warning@unordered_map:* 2 {{the specified hash functor does not provide a const call operator}}
{
using C = std::unordered_set<int, BadHash, BadEqual>;

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/system_error>
#include <experimental/system_error>
// expected-error@experimental/system_error:* {{"<experimental/system_error> has been removed. Use <system_error> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/system_error>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/system_error>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/numeric>
#include <experimental/numeric>
// expected-error@experimental/numeric:* {{"<experimental/numeric> has been removed. Use <numeric> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/numeric>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/numeric>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/string_view>
#include <experimental/string_view>
// expected-error@experimental/string_view:* {{"<experimental/string_view> has been removed. Use <string_view> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/string_view>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/string_view>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/any>
#include <experimental/any>
// expected-error@experimental/any:* {{"<experimental/any> has been removed. Use <any> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/any>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/any>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/optional>
#include <experimental/optional>
// expected-error@experimental/optional:* {{"<experimental/optional> has been removed. Use <optional> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/optional>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/optional>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/ratio>
#include <experimental/ratio>
// expected-error@experimental/ratio:* {{"<experimental/ratio> has been removed. Use <ratio> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/ratio>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/ratio>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/chrono>
#include <experimental/chrono>
// expected-error@experimental/chrono:* {{"<experimental/chrono> has been removed. Use <chrono> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/chrono>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/chrono>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,18 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// REQUIRES: verify-support
// <experimental/tuple>
#include <experimental/tuple>
// expected-error@experimental/tuple:* {{"<experimental/tuple> has been removed. Use <tuple> instead."}}
int main() {}

View File

@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <experimental/tuple>
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-W#warnings"
#endif
#include <experimental/tuple>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main() {}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
// <fstream>
// template <class charT, class traits = char_traits<charT> >
// class basic_fstream
// close();
// Inspired by PR#38052 - std::fstream still good after closing and updating content
#include <fstream>
#include <cassert>
#include "platform_support.h"
int main()
{
std::string temp = get_temp_file_name();
std::fstream ofs(temp, std::ios::out | std::ios::trunc);
ofs << "Hello, World!\n";
assert( ofs.good());
ofs.close();
assert( ofs.good());
ofs << "Hello, World!\n";
assert(!ofs.good());
std::remove(temp.c_str());
}

View File

@@ -12,6 +12,7 @@
// Test exporting the symbol: "__cxa_deleted_virtual" in macosx
// But don't expect the symbol to be exported in previous versions.
//
// XFAIL: with_system_cxx_lib=macosx10.14
// XFAIL: with_system_cxx_lib=macosx10.13
// XFAIL: with_system_cxx_lib=macosx10.12
// XFAIL: with_system_cxx_lib=macosx10.11

View File

@@ -14,10 +14,6 @@
// definitions, which does not yet provide aligned allocation
// XFAIL: LIBCXX-WINDOWS-FIXME
// Clang 10 (and older) will trigger an availability error when the deployment
// target does not support aligned allocation, even if we pass `-faligned-allocation`.
// XFAIL: apple-clang-10 && availability=macosx10.12
// The dylibs shipped before macosx10.14 do not contain the aligned allocation
// functions, so trying to force using those with -faligned-allocation results
// in a link error.

View File

@@ -9,13 +9,17 @@
// UNSUPPORTED: c++98, c++03, c++11, c++14
// aligned allocation functions are not provided prior to macosx10.13
// UNSUPPORTED: macosx10.12
// UNSUPPORTED: macosx10.11
// UNSUPPORTED: macosx10.10
// UNSUPPORTED: macosx10.9
// UNSUPPORTED: macosx10.8
// UNSUPPORTED: macosx10.7
// AppleClang <= 10 enables aligned allocation regardless of the deployment
// target, so this test would fail.
// UNSUPPORTED: apple-clang-9, apple-clang-10
// XFAIL: availability=macosx10.13
// XFAIL: availability=macosx10.12
// XFAIL: availability=macosx10.11
// XFAIL: availability=macosx10.10
// XFAIL: availability=macosx10.9
// XFAIL: availability=macosx10.8
// XFAIL: availability=macosx10.7
#include <new>

View File

@@ -8,8 +8,18 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
// <optional>
// This test asserts the triviality of special member functions of optional<T>
// whenever T has these special member functions trivial. The goal of this test
// is to make sure that we do not change the triviality of those, since that
// constitues an ABI break (small enough optionals would be passed by registers).
//
// constexpr optional(const optional& rhs);
// constexpr optional(optional&& rhs) noexcept(see below);
// constexpr optional<T>& operator=(const optional& rhs);
// constexpr optional<T>& operator=(optional&& rhs) noexcept(see below);
#include <optional>
#include <type_traits>
@@ -21,41 +31,27 @@ template <class T>
struct SpecialMemberTest {
using O = std::optional<T>;
static_assert(std::is_default_constructible_v<O>,
"optional is always default constructible.");
static_assert(std::is_copy_constructible_v<O> == std::is_copy_constructible_v<T>,
"optional<T> is copy constructible if and only if T is copy constructible.");
static_assert(std::is_move_constructible_v<O> ==
(std::is_copy_constructible_v<T> || std::is_move_constructible_v<T>),
"optional<T> is move constructible if and only if T is copy or move constructible.");
static_assert(std::is_copy_assignable_v<O> ==
(std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>),
"optional<T> is copy assignable if and only if T is both copy "
"constructible and copy assignable.");
static_assert(std::is_move_assignable_v<O> ==
((std::is_move_constructible_v<T> && std::is_move_assignable_v<T>) ||
(std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>)),
"optional<T> is move assignable if and only if T is both move constructible and "
"move assignable, or both copy constructible and copy assignable.");
// The following tests are for not-yet-standardized behavior (P0602):
static_assert(std::is_trivially_destructible_v<O> ==
std::is_trivially_destructible_v<T>,
"optional<T> is trivially destructible if and only if T is.");
static_assert(std::is_trivially_copy_constructible_v<O> ==
std::is_trivially_copy_constructible_v<T>,
"optional<T> is trivially copy constructible if and only if T is.");
static_assert(std::is_trivially_move_constructible_v<O> ==
std::is_trivially_move_constructible_v<T> ||
(!std::is_move_constructible_v<T> && std::is_trivially_copy_constructible_v<T>),
"optional<T> is trivially move constructible if T is trivially move constructible, "
"or if T is trivially copy constructible and is not move constructible.");
static_assert(std::is_trivially_copy_assignable_v<O> ==
(std::is_trivially_destructible_v<T> &&
std::is_trivially_copy_constructible_v<T> &&
std::is_trivially_copy_assignable_v<T>),
"optional<T> is trivially copy assignable if and only if T is trivially destructible, "
"trivially copy constructible, and trivially copy assignable.");
static_assert(std::is_trivially_move_assignable_v<O> ==
(std::is_trivially_destructible_v<T> &&
((std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T>) ||

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// template<class U, class V> pair(U&& x, V&& y);
#include <utility>
struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
int value;
};
struct ImplicitT {
constexpr ImplicitT(int x) : value(x) {}
int value;
};
struct ExplicitNothrowT {
explicit ExplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
struct ImplicitNothrowT {
ImplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
int main() {
{ // explicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>, int, int>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>, int, int>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>, int, int>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>, int, int>::value, "");
}
{ // implicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>, int, int>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>, int, int>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>, int, int>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>, int, int>::value, "");
}
}

View File

@@ -0,0 +1,62 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// pair(const T1& x, const T2& y);
#include <utility>
struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
int value;
};
struct ImplicitT {
constexpr ImplicitT(int x) : value(x) {}
constexpr ImplicitT(ImplicitT const& o) : value(o.value) {}
int value;
};
struct ExplicitNothrowT {
explicit ExplicitNothrowT(ExplicitNothrowT const&) noexcept {}
};
struct ImplicitNothrowT {
ImplicitNothrowT(ImplicitNothrowT const&) noexcept {}
};
int main() {
{ // explicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
ExplicitT const&, ExplicitT const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
ExplicitNothrowT const&, ExplicitT const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
ExplicitT const&, ExplicitNothrowT const&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
ExplicitNothrowT const&, ExplicitNothrowT const&>::value, "");
}
{ // implicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
ImplicitT const&, ImplicitT const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
ImplicitNothrowT const&, ImplicitT const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
ImplicitT const&, ImplicitNothrowT const&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
ImplicitNothrowT const&, ImplicitNothrowT const&>::value, "");
}
}

View File

@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// template <class U, class V> EXPLICIT constexpr pair(const pair<U, V>& p);
#include <utility>
struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
int value;
};
struct ImplicitT {
constexpr ImplicitT(int x) : value(x) {}
constexpr ImplicitT(ImplicitT const& o) : value(o.value) {}
int value;
};
struct ExplicitNothrowT {
explicit ExplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
struct ImplicitNothrowT {
ImplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
int main() {
{ // explicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
std::pair<int, int> const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
std::pair<int, int> const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
std::pair<int, int> const&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
std::pair<int, int> const&>::value, "");
}
{ // implicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
std::pair<int, int> const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
std::pair<int, int> const&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
std::pair<int, int> const&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
std::pair<int, int> const&>::value, "");
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// constexpr pair();
#include <utility>
#include <type_traits>
struct ThrowingDefault {
ThrowingDefault() { }
};
struct NonThrowingDefault {
NonThrowingDefault() noexcept { }
};
int main() {
static_assert(!std::is_nothrow_default_constructible<std::pair<ThrowingDefault, ThrowingDefault>>::value, "");
static_assert(!std::is_nothrow_default_constructible<std::pair<NonThrowingDefault, ThrowingDefault>>::value, "");
static_assert(!std::is_nothrow_default_constructible<std::pair<ThrowingDefault, NonThrowingDefault>>::value, "");
static_assert( std::is_nothrow_default_constructible<std::pair<NonThrowingDefault, NonThrowingDefault>>::value, "");
}

View File

@@ -20,6 +20,6 @@ int main()
{
typedef std::pair<int, double> P;
std::tuple_element<2, P>::type foo; // expected-note {{requested here}}
// expected-error@utility:* {{static_assert failed "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"}}
// expected-error-re@utility:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < 2')?}} "Index out of bounds in std::tuple_element<std::pair<T1, T2>>"}}
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// template <class... Args1, class... Args2>
// pair(piecewise_construct_t, tuple<Args1...> first_args,
// tuple<Args2...> second_args);
#include <tuple>
#include <type_traits>
#include <utility>
#include "archetypes.hpp"
int main() {
using NonThrowingConvert = NonThrowingTypes::ConvertingType;
using ThrowingConvert = NonTrivialTypes::ConvertingType;
static_assert(!std::is_nothrow_constructible<std::pair<ThrowingConvert, ThrowingConvert>,
std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<NonThrowingConvert, ThrowingConvert>,
std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ThrowingConvert, NonThrowingConvert>,
std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<NonThrowingConvert, NonThrowingConvert>,
std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
// <utility>
// template <class T1, class T2> struct pair
// template <class U, class V> pair(pair<U, V>&& p);
#include <type_traits>
#include <utility>
struct ExplicitT {
constexpr explicit ExplicitT(int x) : value(x) {}
int value;
};
struct ImplicitT {
constexpr ImplicitT(int x) : value(x) {}
int value;
};
struct ExplicitNothrowT {
explicit ExplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
struct ImplicitNothrowT {
ImplicitNothrowT(int x) noexcept : value(x) {}
int value;
};
int main() {
{ // explicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
std::pair<int, int>&&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
std::pair<int, int>&&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
std::pair<int, int>&&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
std::pair<int, int>&&>::value, "");
}
{ // implicit noexcept test
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
std::pair<int, int>&&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
std::pair<int, int>&&>::value, "");
static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
std::pair<int, int>&&>::value, "");
static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
std::pair<int, int>&&>::value, "");
}
}

View File

@@ -31,6 +31,6 @@ int main()
{
typedef std::variant<int, double> T;
std::variant_alternative<2, T>::type foo; // expected-note {{requested here}}
// expected-error@variant:* {{static_assert failed "Index out of bounds in std::variant_alternative<>"}}
// expected-error-re@variant:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < sizeof...\(_Types\)')?}} "Index out of bounds in std::variant_alternative<>"}}
}
}

View File

@@ -24,7 +24,8 @@ struct make_variant_imp;
template <size_t ...Indices>
struct make_variant_imp<std::integer_sequence<size_t, Indices...>> {
using type = std::variant<decltype((Indices, char(0)))...>;
template <size_t> using AlwaysChar = char;
using type = std::variant<AlwaysChar<Indices>...>;
};
template <size_t N>

View File

@@ -34,7 +34,7 @@ template <class PopulationIterator, class SampleIterator> void test() {
}
int main() {
// expected-error@algorithm:* {{static_assert failed "SampleIterator must meet the requirements of RandomAccessIterator"}}
// expected-error-re@algorithm:* {{static_assert failed{{( due to requirement '.*')?}} "SampleIterator must meet the requirements of RandomAccessIterator"}}
// expected-error@algorithm:* 2 {{does not provide a subscript operator}}
// expected-error@algorithm:* {{invalid operands}}
test<input_iterator<int *>, output_iterator<int *> >();

View File

@@ -16,6 +16,7 @@
// find_end(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Pred pred);
#include <algorithm>
#include <functional>
#include <cassert>
#include "test_macros.h"

View File

@@ -59,7 +59,7 @@ void checkLongLongTypes() {
static_assert((0 != ATOMIC_LLONG_LOCK_FREE) == ExpectLockFree, "");
}
int main()
void run()
{
// structs and unions can't be defined in the template invocation.
// Work around this with a typedef.
@@ -134,3 +134,5 @@ int main()
static_assert(std::atomic<void*>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE));
static_assert(std::atomic<std::nullptr_t>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE));
}
int main() { run(); }

View File

@@ -0,0 +1,79 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// <map>
// template <class Key, class T, class Compare, class Allocator, class Predicate>
// void erase_if(map<Key, T, Compare, Allocator>& c, Predicate pred);
#include <map>
#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
using Init = std::initializer_list<int>;
template <typename M>
M make (Init vals)
{
M ret;
for (int v : vals)
ret[v] = v + 10;
return ret;
}
template <typename M, typename Pred>
void
test0(Init vals, Pred p, Init expected)
{
M s = make<M> (vals);
ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
std::erase_if(s, p);
assert(s == make<M>(expected));
}
template <typename S>
void test()
{
auto is1 = [](auto v) { return v.first == 1;};
auto is2 = [](auto v) { return v.first == 2;};
auto is3 = [](auto v) { return v.first == 3;};
auto is4 = [](auto v) { return v.first == 4;};
auto True = [](auto) { return true; };
auto False = [](auto) { return false; };
test0<S>({}, is1, {});
test0<S>({1}, is1, {});
test0<S>({1}, is2, {1});
test0<S>({1,2}, is1, {2});
test0<S>({1,2}, is2, {1});
test0<S>({1,2}, is3, {1,2});
test0<S>({1,2,3}, is1, {2,3});
test0<S>({1,2,3}, is2, {1,3});
test0<S>({1,2,3}, is3, {1,2});
test0<S>({1,2,3}, is4, {1,2,3});
test0<S>({1,2,3}, True, {});
test0<S>({1,2,3}, False, {1,2,3});
}
int main()
{
test<std::map<int, int>>();
test<std::map<int, int, std::less<int>, min_allocator<std::pair<const int, int>>>> ();
test<std::map<int, int, std::less<int>, test_allocator<std::pair<const int, int>>>> ();
test<std::map<long, short>>();
test<std::map<short, double>>();
}

View File

@@ -0,0 +1,89 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// <map>
// template <class Key, class T, class Compare, class Allocator, class Predicate>
// void erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred);
#include <map>
#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
using Init = std::initializer_list<int>;
template <typename M>
M make (Init vals)
{
M ret;
for (int v : vals)
ret.insert(typename M::value_type(v, v + 10));
return ret;
}
template <typename M, typename Pred>
void
test0(Init vals, Pred p, Init expected)
{
M s = make<M> (vals);
ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
std::erase_if(s, p);
assert(s == make<M>(expected));
}
template <typename S>
void test()
{
auto is1 = [](auto v) { return v.first == 1;};
auto is2 = [](auto v) { return v.first == 2;};
auto is3 = [](auto v) { return v.first == 3;};
auto is4 = [](auto v) { return v.first == 4;};
auto True = [](auto) { return true; };
auto False = [](auto) { return false; };
test0<S>({}, is1, {});
test0<S>({1}, is1, {});
test0<S>({1}, is2, {1});
test0<S>({1,2}, is1, {2});
test0<S>({1,2}, is2, {1});
test0<S>({1,2}, is3, {1,2});
test0<S>({1,1}, is1, {});
test0<S>({1,1}, is3, {1,1});
test0<S>({1,2,3}, is1, {2,3});
test0<S>({1,2,3}, is2, {1,3});
test0<S>({1,2,3}, is3, {1,2});
test0<S>({1,2,3}, is4, {1,2,3});
test0<S>({1,1,1}, is1, {});
test0<S>({1,1,1}, is2, {1,1,1});
test0<S>({1,1,2}, is1, {2});
test0<S>({1,1,2}, is2, {1,1});
test0<S>({1,1,2}, is3, {1,1,2});
test0<S>({1,2,2}, is1, {2,2});
test0<S>({1,2,2}, is2, {1});
test0<S>({1,2,2}, is3, {1,2,2});
test0<S>({1,2,3}, True, {});
test0<S>({1,2,3}, False, {1,2,3});
}
int main()
{
test<std::multimap<int, int>>();
test<std::multimap<int, int, std::less<int>, min_allocator<std::pair<const int, int>>>> ();
test<std::multimap<int, int, std::less<int>, test_allocator<std::pair<const int, int>>>> ();
test<std::multimap<long, short>>();
test<std::multimap<short, double>>();
}

View File

@@ -0,0 +1,78 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// <set>
// template <class T, class Compare, class Allocator, class Predicate>
// void erase_if(multiset<T, Compare, Allocator>& c, Predicate pred);
#include <set>
#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
template <class S, class Pred>
void
test0(S s, Pred p, S expected)
{
ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
std::erase_if(s, p);
assert(s == expected);
}
template <typename S>
void test()
{
auto is1 = [](auto v) { return v == 1;};
auto is2 = [](auto v) { return v == 2;};
auto is3 = [](auto v) { return v == 3;};
auto is4 = [](auto v) { return v == 4;};
auto True = [](auto) { return true; };
auto False = [](auto) { return false; };
test0(S(), is1, S());
test0(S({1}), is1, S());
test0(S({1}), is2, S({1}));
test0(S({1,2}), is1, S({2}));
test0(S({1,2}), is2, S({1}));
test0(S({1,2}), is3, S({1,2}));
test0(S({1,1}), is1, S());
test0(S({1,1}), is3, S({1,1}));
test0(S({1,2,3}), is1, S({2,3}));
test0(S({1,2,3}), is2, S({1,3}));
test0(S({1,2,3}), is3, S({1,2}));
test0(S({1,2,3}), is4, S({1,2,3}));
test0(S({1,1,1}), is1, S());
test0(S({1,1,1}), is2, S({1,1,1}));
test0(S({1,1,2}), is1, S({2}));
test0(S({1,1,2}), is2, S({1,1}));
test0(S({1,1,2}), is3, S({1,1,2}));
test0(S({1,2,2}), is1, S({2,2}));
test0(S({1,2,2}), is2, S({1}));
test0(S({1,2,2}), is3, S({1,2,2}));
test0(S({1,2,3}), True, S());
test0(S({1,2,3}), False, S({1,2,3}));
}
int main()
{
test<std::multiset<int>>();
test<std::multiset<int, std::less<int>, min_allocator<int>>> ();
test<std::multiset<int, std::less<int>, test_allocator<int>>> ();
test<std::multiset<long>>();
test<std::multiset<double>>();
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
// <set>
// template <class T, class Compare, class Allocator, class Predicate>
// void erase_if(set<T, Compare, Allocator>& c, Predicate pred);
#include <set>
#include "test_macros.h"
#include "test_allocator.h"
#include "min_allocator.h"
template <class S, class Pred>
void
test0(S s, Pred p, S expected)
{
ASSERT_SAME_TYPE(void, decltype(std::erase_if(s, p)));
std::erase_if(s, p);
assert(s == expected);
}
template <typename S>
void test()
{
auto is1 = [](auto v) { return v == 1;};
auto is2 = [](auto v) { return v == 2;};
auto is3 = [](auto v) { return v == 3;};
auto is4 = [](auto v) { return v == 4;};
auto True = [](auto) { return true; };
auto False = [](auto) { return false; };
test0(S(), is1, S());
test0(S({1}), is1, S());
test0(S({1}), is2, S({1}));
test0(S({1,2}), is1, S({2}));
test0(S({1,2}), is2, S({1}));
test0(S({1,2}), is3, S({1,2}));
test0(S({1,2,3}), is1, S({2,3}));
test0(S({1,2,3}), is2, S({1,3}));
test0(S({1,2,3}), is3, S({1,2}));
test0(S({1,2,3}), is4, S({1,2,3}));
test0(S({1,2,3}), True, S());
test0(S({1,2,3}), False, S({1,2,3}));
}
int main()
{
test<std::set<int>>();
test<std::set<int, std::less<int>, min_allocator<int>>> ();
test<std::set<int, std::less<int>, test_allocator<int>>> ();
test<std::set<long>>();
test<std::set<double>>();
}

View File

@@ -42,7 +42,7 @@ int main()
typedef std::array<T, 0> C;
C c = {};
T* p = c.data();
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
}
{
typedef double T;
@@ -50,14 +50,14 @@ int main()
C c = {{}};
const T* p = c.data();
static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
}
{
typedef std::max_align_t T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}
@@ -66,6 +66,6 @@ int main()
typedef std::array<T, 0> C;
C c = {};
T* p = c.data();
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
}
}

View File

@@ -48,14 +48,14 @@ int main()
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
}
{
typedef std::max_align_t T;
typedef std::array<T, 0> C;
const C c = {};
const T* p = c.data();
assert(p != nullptr);
LIBCPP_ASSERT(p != nullptr);
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}

View File

@@ -31,6 +31,6 @@ int main()
typedef std::array<T, 3> C;
C c = {1, 2, 3.5};
std::get<3>(c) = 5.5; // expected-note {{requested here}}
// expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}}
// expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::get<> (std::array)"}}
}
}

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